summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/char/char.c475
-rw-r--r--src/char/char.h3
-rw-r--r--src/char/int_auction.c38
-rw-r--r--src/char/int_guild.c6
-rw-r--r--src/char/int_homun.c14
-rw-r--r--src/char/int_mail.c18
-rw-r--r--src/char/int_quest.c24
-rw-r--r--src/char/inter.c4
-rw-r--r--src/char/inter.h3
-rw-r--r--src/common/HPM.c10
-rw-r--r--src/common/console.c12
-rw-r--r--src/common/core.c10
-rw-r--r--src/common/db.c1
-rw-r--r--src/common/ers.c21
-rw-r--r--src/common/ers.h6
-rw-r--r--src/common/malloc.c146
-rw-r--r--src/common/malloc.h16
-rw-r--r--src/common/mmo.h16
-rw-r--r--src/common/mutex.c2
-rw-r--r--src/common/random.c2
-rw-r--r--src/common/socket.c72
-rw-r--r--src/common/socket.h14
-rw-r--r--src/common/sql.c149
-rw-r--r--src/common/sql.h192
-rw-r--r--src/common/strlib.h10
-rw-r--r--src/common/timer.c37
-rw-r--r--src/common/timer.h41
-rw-r--r--src/config/const.h11
-rw-r--r--src/login/account_sql.c82
-rw-r--r--src/login/ipban_sql.c6
-rw-r--r--src/login/login.c26
-rw-r--r--src/map/atcommand.c675
-rw-r--r--src/map/battle.c5439
-rw-r--r--src/map/battle.h53
-rw-r--r--src/map/battleground.c530
-rw-r--r--src/map/battleground.h67
-rw-r--r--src/map/buyingstore.c34
-rw-r--r--src/map/chat.c40
-rw-r--r--src/map/chrif.c95
-rw-r--r--src/map/clif.c1526
-rw-r--r--src/map/clif.h79
-rw-r--r--src/map/duel.c4
-rw-r--r--src/map/elemental.c67
-rw-r--r--src/map/guild.c82
-rw-r--r--src/map/homunculus.c40
-rw-r--r--src/map/instance.c529
-rw-r--r--src/map/instance.h76
-rw-r--r--src/map/intif.c82
-rw-r--r--src/map/irc-bot.c30
-rw-r--r--src/map/irc-bot.h3
-rw-r--r--src/map/itemdb.c760
-rw-r--r--src/map/itemdb.h196
-rw-r--r--src/map/log.c60
-rw-r--r--src/map/mail.c46
-rw-r--r--src/map/mail.h29
-rw-r--r--src/map/map.c2279
-rw-r--r--src/map/map.h472
-rw-r--r--src/map/mapreg_sql.c22
-rw-r--r--src/map/mercenary.c22
-rw-r--r--src/map/mob.c312
-rw-r--r--src/map/npc.c620
-rw-r--r--src/map/npc.h12
-rw-r--r--src/map/npc_chat.c8
-rw-r--r--src/map/packets.h341
-rw-r--r--src/map/packets_struct.h80
-rw-r--r--src/map/party.c302
-rw-r--r--src/map/party.h121
-rw-r--r--src/map/path.c38
-rw-r--r--src/map/pc.c3083
-rw-r--r--src/map/pc.h529
-rw-r--r--src/map/pc_groups.c13
-rw-r--r--src/map/pc_groups.h1
-rw-r--r--src/map/pet.c126
-rw-r--r--src/map/quest.c12
-rw-r--r--src/map/script.c2959
-rw-r--r--src/map/script.h127
-rw-r--r--src/map/searchstore.c6
-rw-r--r--src/map/skill.c3688
-rw-r--r--src/map/skill.h28
-rw-r--r--src/map/status.c4180
-rw-r--r--src/map/status.h772
-rw-r--r--src/map/storage.c150
-rw-r--r--src/map/storage.h73
-rw-r--r--src/map/trade.c89
-rw-r--r--src/map/trade.h28
-rw-r--r--src/map/unit.c405
-rw-r--r--src/map/vending.c30
-rw-r--r--src/plugins/Makefile.in6
-rw-r--r--src/plugins/db2sql.c138
89 files changed, 18990 insertions, 14091 deletions
diff --git a/src/char/char.c b/src/char/char.c
index f4212a076..7dfb6861c 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -66,6 +66,7 @@ char skill_homunculus_db[256] = "skill_homunculus";
char mercenary_db[256] = "mercenary";
char mercenary_owner_db[256] = "mercenary_owner";
char ragsrvinfo_db[256] = "ragsrvinfo";
+char interreg_db[32] = "interreg";
// show loading/saving messages
int save_log = 1;
@@ -81,7 +82,8 @@ struct mmo_map_server {
uint32 ip;
uint16 port;
int users;
- unsigned short map[MAX_MAP_PER_SERVER];
+ unsigned short *map;
+ unsigned short maps;
} server[MAX_MAP_SERVERS];
int char_fd=-1;
@@ -206,7 +208,7 @@ void set_char_charselect(int account_id)
character->pincode_enable = *pincode->charselect + *pincode->enabled;
if(character->waiting_disconnect != INVALID_TIMER) {
- delete_timer(character->waiting_disconnect, chardb_waiting_disconnect);
+ iTimer->delete_timer(character->waiting_disconnect, chardb_waiting_disconnect);
character->waiting_disconnect = INVALID_TIMER;
}
@@ -247,7 +249,7 @@ void set_char_online(int map_id, int char_id, int account_id)
//Get rid of disconnect timer
if(character->waiting_disconnect != INVALID_TIMER) {
- delete_timer(character->waiting_disconnect, chardb_waiting_disconnect);
+ iTimer->delete_timer(character->waiting_disconnect, chardb_waiting_disconnect);
character->waiting_disconnect = INVALID_TIMER;
}
@@ -292,7 +294,7 @@ void set_char_offline(int char_id, int account_id)
server[character->server].users--;
if(character->waiting_disconnect != INVALID_TIMER){
- delete_timer(character->waiting_disconnect, chardb_waiting_disconnect);
+ iTimer->delete_timer(character->waiting_disconnect, chardb_waiting_disconnect);
character->waiting_disconnect = INVALID_TIMER;
}
@@ -327,7 +329,7 @@ static int char_db_setoffline(DBKey key, DBData *data, va_list ap)
character->char_id = -1;
character->server = -1;
if(character->waiting_disconnect != INVALID_TIMER){
- delete_timer(character->waiting_disconnect, chardb_waiting_disconnect);
+ iTimer->delete_timer(character->waiting_disconnect, chardb_waiting_disconnect);
character->waiting_disconnect = INVALID_TIMER;
}
} else if (character->server == server)
@@ -712,31 +714,31 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
StrBuf->Printf(&buf, ", `card%d`", j);
StrBuf->Printf(&buf, " FROM `%s` WHERE `%s`='%d'", tablename, selectoption, id);
- stmt = SqlStmt_Malloc(sql_handle);
- if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StrBuf->Value(&buf))
- || SQL_ERROR == SqlStmt_Execute(stmt) )
+ stmt = SQL->StmtMalloc(sql_handle);
+ if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
+ || SQL_ERROR == SQL->StmtExecute(stmt) )
{
SqlStmt_ShowDebug(stmt);
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
StrBuf->Destroy(&buf);
return 1;
}
- SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &item.id, 0, NULL, NULL);
- SqlStmt_BindColumn(stmt, 1, SQLDT_SHORT, &item.nameid, 0, NULL, NULL);
- SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT, &item.amount, 0, NULL, NULL);
- SqlStmt_BindColumn(stmt, 3, SQLDT_USHORT, &item.equip, 0, NULL, NULL);
- SqlStmt_BindColumn(stmt, 4, SQLDT_CHAR, &item.identify, 0, NULL, NULL);
- SqlStmt_BindColumn(stmt, 5, SQLDT_CHAR, &item.refine, 0, NULL, NULL);
- SqlStmt_BindColumn(stmt, 6, SQLDT_CHAR, &item.attribute, 0, NULL, NULL);
- SqlStmt_BindColumn(stmt, 7, SQLDT_UINT, &item.expire_time, 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &item.id, 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT, &item.nameid, 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT, &item.amount, 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 3, SQLDT_USHORT, &item.equip, 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 4, SQLDT_CHAR, &item.identify, 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 5, SQLDT_CHAR, &item.refine, 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 6, SQLDT_CHAR, &item.attribute, 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &item.expire_time, 0, NULL, NULL);
for( j = 0; j < MAX_SLOTS; ++j )
- SqlStmt_BindColumn(stmt, 8+j, SQLDT_SHORT, &item.card[j], 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 8+j, SQLDT_SHORT, &item.card[j], 0, NULL, NULL);
// bit array indicating which inventory items have already been matched
flag = (bool*) aCalloc(max, sizeof(bool));
- while( SQL_SUCCESS == SqlStmt_NextRow(stmt) )
+ while( SQL_SUCCESS == SQL->StmtNextRow(stmt) )
{
found = false;
// search for the presence of the item in the char's inventory
@@ -790,7 +792,7 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
}
}
}
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
StrBuf->Clear(&buf);
StrBuf->Printf(&buf, "INSERT INTO `%s`(`%s`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `unique_id`", tablename, selectoption);
@@ -856,32 +858,32 @@ int inventory_to_sql(const struct item items[], int max, int id) {
StrBuf->Printf(&buf, ", `card%d`", j);
StrBuf->Printf(&buf, " FROM `%s` WHERE `char_id`='%d'", inventory_db, id);
- stmt = SqlStmt_Malloc(sql_handle);
- if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StrBuf->Value(&buf))
- || SQL_ERROR == SqlStmt_Execute(stmt) )
+ stmt = SQL->StmtMalloc(sql_handle);
+ if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
+ || SQL_ERROR == SQL->StmtExecute(stmt) )
{
SqlStmt_ShowDebug(stmt);
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
StrBuf->Destroy(&buf);
return 1;
}
- SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &item.id, 0, NULL, NULL);
- SqlStmt_BindColumn(stmt, 1, SQLDT_SHORT, &item.nameid, 0, NULL, NULL);
- SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT, &item.amount, 0, NULL, NULL);
- SqlStmt_BindColumn(stmt, 3, SQLDT_USHORT, &item.equip, 0, NULL, NULL);
- SqlStmt_BindColumn(stmt, 4, SQLDT_CHAR, &item.identify, 0, NULL, NULL);
- SqlStmt_BindColumn(stmt, 5, SQLDT_CHAR, &item.refine, 0, NULL, NULL);
- SqlStmt_BindColumn(stmt, 6, SQLDT_CHAR, &item.attribute, 0, NULL, NULL);
- SqlStmt_BindColumn(stmt, 7, SQLDT_UINT, &item.expire_time, 0, NULL, NULL);
- SqlStmt_BindColumn(stmt, 8, SQLDT_CHAR, &item.favorite, 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &item.id, 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT, &item.nameid, 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT, &item.amount, 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 3, SQLDT_USHORT, &item.equip, 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 4, SQLDT_CHAR, &item.identify, 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 5, SQLDT_CHAR, &item.refine, 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 6, SQLDT_CHAR, &item.attribute, 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &item.expire_time, 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 8, SQLDT_CHAR, &item.favorite, 0, NULL, NULL);
for( j = 0; j < MAX_SLOTS; ++j )
- SqlStmt_BindColumn(stmt, 9+j, SQLDT_SHORT, &item.card[j], 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 9+j, SQLDT_SHORT, &item.card[j], 0, NULL, NULL);
// bit array indicating which inventory items have already been matched
flag = (bool*) aCalloc(max, sizeof(bool));
- while( SQL_SUCCESS == SqlStmt_NextRow(stmt) ) {
+ while( SQL_SUCCESS == SQL->StmtNextRow(stmt) ) {
found = false;
// search for the presence of the item in the char's inventory
for( i = 0; i < max; ++i ) {
@@ -930,7 +932,7 @@ int inventory_to_sql(const struct item items[], int max, int id) {
}
}
}
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
StrBuf->Clear(&buf);
StrBuf->Printf(&buf, "INSERT INTO `%s` (`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `favorite`, `unique_id`", inventory_db);
@@ -983,7 +985,7 @@ int mmo_chars_fromsql(struct char_session_data* sd, uint8* buf)
int j = 0, i;
char last_map[MAP_NAME_LENGTH_EXT];
- stmt = SqlStmt_Malloc(sql_handle);
+ stmt = SQL->StmtMalloc(sql_handle);
if( stmt == NULL ) {
SqlStmt_ShowDebug(stmt);
return 0;
@@ -994,59 +996,59 @@ int mmo_chars_fromsql(struct char_session_data* sd, uint8* buf)
sd->found_char[i] = -1;
// read char data
- if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT "
+ if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT "
"`char_id`,`char_num`,`name`,`class`,`base_level`,`job_level`,`base_exp`,`job_exp`,`zeny`,"
"`str`,`agi`,`vit`,`int`,`dex`,`luk`,`max_hp`,`hp`,`max_sp`,`sp`,"
"`status_point`,`skill_point`,`option`,`karma`,`manner`,`hair`,`hair_color`,"
"`clothes_color`,`weapon`,`shield`,`head_top`,`head_mid`,`head_bottom`,`last_map`,`rename`,`delete_date`,"
"`robe`,`slotchange`"
" FROM `%s` WHERE `account_id`='%d' AND `char_num` < '%d'", char_db, sd->account_id, MAX_CHARS)
- || SQL_ERROR == SqlStmt_Execute(stmt)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &p.char_id, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_UCHAR, &p.slot, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_STRING, &p.name, sizeof(p.name), NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_SHORT, &p.class_, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_UINT, &p.base_level, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 5, SQLDT_UINT, &p.job_level, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 6, SQLDT_UINT, &p.base_exp, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 7, SQLDT_UINT, &p.job_exp, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 8, SQLDT_INT, &p.zeny, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 9, SQLDT_SHORT, &p.str, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 10, SQLDT_SHORT, &p.agi, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 11, SQLDT_SHORT, &p.vit, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 12, SQLDT_SHORT, &p.int_, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 13, SQLDT_SHORT, &p.dex, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 14, SQLDT_SHORT, &p.luk, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 15, SQLDT_INT, &p.max_hp, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 16, SQLDT_INT, &p.hp, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 17, SQLDT_INT, &p.max_sp, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 18, SQLDT_INT, &p.sp, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 19, SQLDT_UINT, &p.status_point, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 20, SQLDT_UINT, &p.skill_point, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 21, SQLDT_UINT, &p.option, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 22, SQLDT_UCHAR, &p.karma, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 23, SQLDT_SHORT, &p.manner, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 24, SQLDT_SHORT, &p.hair, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 25, SQLDT_SHORT, &p.hair_color, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 26, SQLDT_SHORT, &p.clothes_color, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 27, SQLDT_SHORT, &p.weapon, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 28, SQLDT_SHORT, &p.shield, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 29, SQLDT_SHORT, &p.head_top, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 30, SQLDT_SHORT, &p.head_mid, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 31, SQLDT_SHORT, &p.head_bottom, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 32, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 33, SQLDT_USHORT, &p.rename, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 34, SQLDT_UINT32, &p.delete_date, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 35, SQLDT_SHORT, &p.robe, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 36, SQLDT_USHORT, &p.slotchange, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtExecute(stmt)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &p.char_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_UCHAR, &p.slot, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_STRING, &p.name, sizeof(p.name), NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_SHORT, &p.class_, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_UINT, &p.base_level, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_UINT, &p.job_level, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_UINT, &p.base_exp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &p.job_exp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_INT, &p.zeny, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_SHORT, &p.str, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 10, SQLDT_SHORT, &p.agi, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 11, SQLDT_SHORT, &p.vit, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 12, SQLDT_SHORT, &p.int_, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 13, SQLDT_SHORT, &p.dex, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 14, SQLDT_SHORT, &p.luk, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 15, SQLDT_INT, &p.max_hp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 16, SQLDT_INT, &p.hp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 17, SQLDT_INT, &p.max_sp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 18, SQLDT_INT, &p.sp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 19, SQLDT_UINT, &p.status_point, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 20, SQLDT_UINT, &p.skill_point, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 21, SQLDT_UINT, &p.option, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 22, SQLDT_UCHAR, &p.karma, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 23, SQLDT_SHORT, &p.manner, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 24, SQLDT_SHORT, &p.hair, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 25, SQLDT_SHORT, &p.hair_color, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 26, SQLDT_SHORT, &p.clothes_color, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 27, SQLDT_SHORT, &p.weapon, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_SHORT, &p.shield, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_SHORT, &p.head_top, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p.head_mid, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p.head_bottom, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_USHORT, &p.rename, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_UINT32, &p.delete_date, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_SHORT, &p.robe, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_USHORT, &p.slotchange, 0, NULL, NULL)
)
{
SqlStmt_ShowDebug(stmt);
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
return 0;
}
- for( i = 0; i < MAX_CHARS && SQL_SUCCESS == SqlStmt_NextRow(stmt); i++ ) {
+ for( i = 0; i < MAX_CHARS && SQL_SUCCESS == SQL->StmtNextRow(stmt); i++ ) {
p.last_point.map = mapindex_name2id(last_map);
sd->found_char[p.slot] = p.char_id;
j += mmo_char_tobuf(WBUFP(buf, j), &p);
@@ -1054,7 +1056,7 @@ int mmo_chars_fromsql(struct char_session_data* sd, uint8* buf)
memset(sd->new_name,0,sizeof(sd->new_name));
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
return j;
}
@@ -1083,7 +1085,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
if (save_log) ShowInfo("Char load request (%d)\n", char_id);
- stmt = SqlStmt_Malloc(sql_handle);
+ stmt = SQL->StmtMalloc(sql_handle);
if( stmt == NULL )
{
SqlStmt_ShowDebug(stmt);
@@ -1091,7 +1093,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
}
// read char data
- if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT "
+ if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT "
"`char_id`,`account_id`,`char_num`,`name`,`class`,`base_level`,`job_level`,`base_exp`,`job_exp`,`zeny`,"
"`str`,`agi`,`vit`,`int`,`dex`,`luk`,`max_hp`,`hp`,`max_sp`,`sp`,"
"`status_point`,`skill_point`,`option`,`karma`,`manner`,`party_id`,`guild_id`,`pet_id`,`homun_id`,`elemental_id`,`hair`,"
@@ -1099,72 +1101,72 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
"`save_map`,`save_x`,`save_y`,`partner_id`,`father`,`mother`,`child`,`fame`,`rename`,`delete_date`,`robe`,`slotchange`,"
"`char_opt`"
" FROM `%s` WHERE `char_id`=? LIMIT 1", char_db)
- || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
- || SQL_ERROR == SqlStmt_Execute(stmt)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &p->char_id, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_INT, &p->account_id, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_UCHAR, &p->slot, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_STRING, &p->name, sizeof(p->name), NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_SHORT, &p->class_, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 5, SQLDT_UINT, &p->base_level, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 6, SQLDT_UINT, &p->job_level, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 7, SQLDT_UINT, &p->base_exp, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 8, SQLDT_UINT, &p->job_exp, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 9, SQLDT_INT, &p->zeny, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 10, SQLDT_SHORT, &p->str, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 11, SQLDT_SHORT, &p->agi, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 12, SQLDT_SHORT, &p->vit, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 13, SQLDT_SHORT, &p->int_, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 14, SQLDT_SHORT, &p->dex, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 15, SQLDT_SHORT, &p->luk, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 16, SQLDT_INT, &p->max_hp, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 17, SQLDT_INT, &p->hp, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 18, SQLDT_INT, &p->max_sp, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 19, SQLDT_INT, &p->sp, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 20, SQLDT_UINT, &p->status_point, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 21, SQLDT_UINT, &p->skill_point, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 22, SQLDT_UINT, &p->option, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 23, SQLDT_UCHAR, &p->karma, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 24, SQLDT_SHORT, &p->manner, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 25, SQLDT_INT, &p->party_id, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 26, SQLDT_INT, &p->guild_id, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 27, SQLDT_INT, &p->pet_id, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 28, SQLDT_INT, &p->hom_id, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 29, SQLDT_INT, &p->ele_id, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 30, SQLDT_SHORT, &p->hair, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 31, SQLDT_SHORT, &p->hair_color, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 32, SQLDT_SHORT, &p->clothes_color, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 33, SQLDT_SHORT, &p->weapon, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 34, SQLDT_SHORT, &p->shield, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 35, SQLDT_SHORT, &p->head_top, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 36, SQLDT_SHORT, &p->head_mid, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 37, SQLDT_SHORT, &p->head_bottom, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 38, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 39, SQLDT_SHORT, &p->last_point.x, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 40, SQLDT_SHORT, &p->last_point.y, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 41, SQLDT_STRING, &save_map, sizeof(save_map), NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 42, SQLDT_SHORT, &p->save_point.x, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 43, SQLDT_SHORT, &p->save_point.y, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 44, SQLDT_INT, &p->partner_id, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 45, SQLDT_INT, &p->father, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 46, SQLDT_INT, &p->mother, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 47, SQLDT_INT, &p->child, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 48, SQLDT_INT, &p->fame, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 49, SQLDT_USHORT, &p->rename, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 50, SQLDT_UINT32, &p->delete_date, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 51, SQLDT_SHORT, &p->robe, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 52, SQLDT_USHORT, &p->slotchange, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 53, SQLDT_UINT, &opt, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
+ || SQL_ERROR == SQL->StmtExecute(stmt)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &p->char_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_INT, &p->account_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UCHAR, &p->slot, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_STRING, &p->name, sizeof(p->name), NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_SHORT, &p->class_, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_UINT, &p->base_level, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_UINT, &p->job_level, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &p->base_exp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_UINT, &p->job_exp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_INT, &p->zeny, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 10, SQLDT_SHORT, &p->str, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 11, SQLDT_SHORT, &p->agi, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 12, SQLDT_SHORT, &p->vit, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 13, SQLDT_SHORT, &p->int_, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 14, SQLDT_SHORT, &p->dex, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 15, SQLDT_SHORT, &p->luk, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 16, SQLDT_INT, &p->max_hp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 17, SQLDT_INT, &p->hp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 18, SQLDT_INT, &p->max_sp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 19, SQLDT_INT, &p->sp, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 20, SQLDT_UINT, &p->status_point, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 21, SQLDT_UINT, &p->skill_point, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 22, SQLDT_UINT, &p->option, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 23, SQLDT_UCHAR, &p->karma, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 24, SQLDT_SHORT, &p->manner, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 25, SQLDT_INT, &p->party_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 26, SQLDT_INT, &p->guild_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 27, SQLDT_INT, &p->pet_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_INT, &p->hom_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_INT, &p->ele_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p->hair, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p->hair_color, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_SHORT, &p->clothes_color, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_SHORT, &p->weapon, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_SHORT, &p->shield, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_SHORT, &p->head_top, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_SHORT, &p->head_mid, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 37, SQLDT_SHORT, &p->head_bottom, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 38, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 39, SQLDT_SHORT, &p->last_point.x, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 40, SQLDT_SHORT, &p->last_point.y, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 41, SQLDT_STRING, &save_map, sizeof(save_map), NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 42, SQLDT_SHORT, &p->save_point.x, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 43, SQLDT_SHORT, &p->save_point.y, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 44, SQLDT_INT, &p->partner_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 45, SQLDT_INT, &p->father, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 46, SQLDT_INT, &p->mother, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 47, SQLDT_INT, &p->child, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 48, SQLDT_INT, &p->fame, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 49, SQLDT_USHORT, &p->rename, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 50, SQLDT_UINT32, &p->delete_date, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 51, SQLDT_SHORT, &p->robe, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 52, SQLDT_USHORT, &p->slotchange, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 53, SQLDT_UINT, &opt, 0, NULL, NULL)
)
{
SqlStmt_ShowDebug(stmt);
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
return 0;
}
- if( SQL_ERROR == SqlStmt_NextRow(stmt) )
+ if( SQL_ERROR == SQL->StmtNextRow(stmt) )
{
ShowError("Requested non-existant character id: %d!\n", char_id);
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
return 0;
}
p->last_point.map = mapindex_name2id(last_map);
@@ -1186,21 +1188,21 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
if (!load_everything) // For quick selection of data when displaying the char menu
{
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
return 1;
}
//read memo data
//`memo` (`memo_id`,`char_id`,`map`,`x`,`y`)
- if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `map`,`x`,`y` FROM `%s` WHERE `char_id`=? ORDER by `memo_id` LIMIT %d", memo_db, MAX_MEMOPOINTS)
- || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
- || SQL_ERROR == SqlStmt_Execute(stmt)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &point_map, sizeof(point_map), NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_SHORT, &tmp_point.x, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT, &tmp_point.y, 0, NULL, NULL) )
+ if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `map`,`x`,`y` FROM `%s` WHERE `char_id`=? ORDER by `memo_id` LIMIT %d", memo_db, MAX_MEMOPOINTS)
+ || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
+ || SQL_ERROR == SQL->StmtExecute(stmt)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_STRING, &point_map, sizeof(point_map), NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT, &tmp_point.x, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT, &tmp_point.y, 0, NULL, NULL) )
SqlStmt_ShowDebug(stmt);
- for( i = 0; i < MAX_MEMOPOINTS && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i ) {
+ for( i = 0; i < MAX_MEMOPOINTS && SQL_SUCCESS == SQL->StmtNextRow(stmt); ++i ) {
tmp_point.map = mapindex_name2id(point_map);
memcpy(&p->memo_point[i], &tmp_point, sizeof(tmp_point));
}
@@ -1214,25 +1216,25 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
StrBuf->Printf(&buf, ", `card%d`", i);
StrBuf->Printf(&buf, " FROM `%s` WHERE `char_id`=? LIMIT %d", inventory_db, MAX_INVENTORY);
- if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StrBuf->Value(&buf))
- || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
- || SQL_ERROR == SqlStmt_Execute(stmt)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &tmp_item.id, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_SHORT, &tmp_item.nameid, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT, &tmp_item.amount, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_USHORT, &tmp_item.equip, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_CHAR, &tmp_item.identify, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 5, SQLDT_CHAR, &tmp_item.refine, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 6, SQLDT_CHAR, &tmp_item.attribute, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 7, SQLDT_UINT, &tmp_item.expire_time, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 8, SQLDT_CHAR, &tmp_item.favorite, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 9, SQLDT_ULONGLONG, &tmp_item.unique_id, 0, NULL, NULL) )
+ if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
+ || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
+ || SQL_ERROR == SQL->StmtExecute(stmt)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &tmp_item.id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT, &tmp_item.nameid, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT, &tmp_item.amount, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_USHORT, &tmp_item.equip, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_CHAR, &tmp_item.identify, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_CHAR, &tmp_item.refine, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_CHAR, &tmp_item.attribute, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &tmp_item.expire_time, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_CHAR, &tmp_item.favorite, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_ULONGLONG, &tmp_item.unique_id, 0, NULL, NULL) )
SqlStmt_ShowDebug(stmt);
for( i = 0; i < MAX_SLOTS; ++i )
- if( SQL_ERROR == SqlStmt_BindColumn(stmt, 10+i, SQLDT_SHORT, &tmp_item.card[i], 0, NULL, NULL) )
+ if( SQL_ERROR == SQL->StmtBindColumn(stmt, 10+i, SQLDT_SHORT, &tmp_item.card[i], 0, NULL, NULL) )
SqlStmt_ShowDebug(stmt);
- for( i = 0; i < MAX_INVENTORY && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i )
+ for( i = 0; i < MAX_INVENTORY && SQL_SUCCESS == SQL->StmtNextRow(stmt); ++i )
memcpy(&p->inventory[i], &tmp_item, sizeof(tmp_item));
strcat(t_msg, " inventory");
@@ -1245,24 +1247,24 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
StrBuf->Printf(&buf, ", `card%d`", j);
StrBuf->Printf(&buf, " FROM `%s` WHERE `char_id`=? LIMIT %d", cart_db, MAX_CART);
- if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StrBuf->Value(&buf))
- || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
- || SQL_ERROR == SqlStmt_Execute(stmt)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &tmp_item.id, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_SHORT, &tmp_item.nameid, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT, &tmp_item.amount, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_USHORT, &tmp_item.equip, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_CHAR, &tmp_item.identify, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 5, SQLDT_CHAR, &tmp_item.refine, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 6, SQLDT_CHAR, &tmp_item.attribute, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 7, SQLDT_UINT, &tmp_item.expire_time, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 8, SQLDT_ULONGLONG, &tmp_item.unique_id, 0, NULL, NULL) )
+ if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
+ || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
+ || SQL_ERROR == SQL->StmtExecute(stmt)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &tmp_item.id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT, &tmp_item.nameid, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT, &tmp_item.amount, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_USHORT, &tmp_item.equip, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_CHAR, &tmp_item.identify, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_CHAR, &tmp_item.refine, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_CHAR, &tmp_item.attribute, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &tmp_item.expire_time, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_ULONGLONG, &tmp_item.unique_id, 0, NULL, NULL) )
SqlStmt_ShowDebug(stmt);
for( i = 0; i < MAX_SLOTS; ++i )
- if( SQL_ERROR == SqlStmt_BindColumn(stmt, 9+i, SQLDT_SHORT, &tmp_item.card[i], 0, NULL, NULL) )
+ if( SQL_ERROR == SQL->StmtBindColumn(stmt, 9+i, SQLDT_SHORT, &tmp_item.card[i], 0, NULL, NULL) )
SqlStmt_ShowDebug(stmt);
- for( i = 0; i < MAX_CART && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i )
+ for( i = 0; i < MAX_CART && SQL_SUCCESS == SQL->StmtNextRow(stmt); ++i )
memcpy(&p->cart[i], &tmp_item, sizeof(tmp_item));
strcat(t_msg, " cart");
@@ -1272,18 +1274,18 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
//read skill
//`skill` (`char_id`, `id`, `lv`)
- if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `id`, `lv`,`flag` FROM `%s` WHERE `char_id`=? LIMIT %d", skill_db, MAX_SKILL)
- || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
- || SQL_ERROR == SqlStmt_Execute(stmt)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_USHORT, &tmp_skill.id , 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_UCHAR , &tmp_skill.lv , 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_UCHAR , &tmp_skill.flag, 0, NULL, NULL) )
+ if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `id`, `lv`,`flag` FROM `%s` WHERE `char_id`=? LIMIT %d", skill_db, MAX_SKILL)
+ || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
+ || SQL_ERROR == SQL->StmtExecute(stmt)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_USHORT, &tmp_skill.id , 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_UCHAR , &tmp_skill.lv , 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UCHAR , &tmp_skill.flag, 0, NULL, NULL) )
SqlStmt_ShowDebug(stmt);
if( tmp_skill.flag != SKILL_FLAG_PERM_GRANTED )
tmp_skill.flag = SKILL_FLAG_PERMANENT;
- for( i = 0; i < MAX_SKILL && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i ) {
+ for( i = 0; i < MAX_SKILL && SQL_SUCCESS == SQL->StmtNextRow(stmt); ++i ) {
if( skillid2idx[tmp_skill.id] )
memcpy(&p->skill[skillid2idx[tmp_skill.id]], &tmp_skill, sizeof(tmp_skill));
else
@@ -1293,31 +1295,31 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
//read friends
//`friends` (`char_id`, `friend_account`, `friend_id`)
- if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT c.`account_id`, c.`char_id`, c.`name` FROM `%s` c LEFT JOIN `%s` f ON f.`friend_account` = c.`account_id` AND f.`friend_id` = c.`char_id` WHERE f.`char_id`=? LIMIT %d", char_db, friend_db, MAX_FRIENDS)
- || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
- || SQL_ERROR == SqlStmt_Execute(stmt)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &tmp_friend.account_id, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_INT, &tmp_friend.char_id, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_STRING, &tmp_friend.name, sizeof(tmp_friend.name), NULL, NULL) )
+ if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT c.`account_id`, c.`char_id`, c.`name` FROM `%s` c LEFT JOIN `%s` f ON f.`friend_account` = c.`account_id` AND f.`friend_id` = c.`char_id` WHERE f.`char_id`=? LIMIT %d", char_db, friend_db, MAX_FRIENDS)
+ || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
+ || SQL_ERROR == SQL->StmtExecute(stmt)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &tmp_friend.account_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_INT, &tmp_friend.char_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_STRING, &tmp_friend.name, sizeof(tmp_friend.name), NULL, NULL) )
SqlStmt_ShowDebug(stmt);
- for( i = 0; i < MAX_FRIENDS && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i )
+ for( i = 0; i < MAX_FRIENDS && SQL_SUCCESS == SQL->StmtNextRow(stmt); ++i )
memcpy(&p->friends[i], &tmp_friend, sizeof(tmp_friend));
strcat(t_msg, " friends");
#ifdef HOTKEY_SAVING
//read hotkeys
//`hotkey` (`char_id`, `hotkey`, `type`, `itemskill_id`, `skill_lvl`
- if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `hotkey`, `type`, `itemskill_id`, `skill_lvl` FROM `%s` WHERE `char_id`=?", hotkey_db)
- || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
- || SQL_ERROR == SqlStmt_Execute(stmt)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &hotkey_num, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_UCHAR, &tmp_hotkey.type, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_UINT, &tmp_hotkey.id, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_USHORT, &tmp_hotkey.lv, 0, NULL, NULL) )
+ if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `hotkey`, `type`, `itemskill_id`, `skill_lvl` FROM `%s` WHERE `char_id`=?", hotkey_db)
+ || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
+ || SQL_ERROR == SQL->StmtExecute(stmt)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &hotkey_num, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_UCHAR, &tmp_hotkey.type, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UINT, &tmp_hotkey.id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_USHORT, &tmp_hotkey.lv, 0, NULL, NULL) )
SqlStmt_ShowDebug(stmt);
- while( SQL_SUCCESS == SqlStmt_NextRow(stmt) )
+ while( SQL_SUCCESS == SQL->StmtNextRow(stmt) )
{
if( hotkey_num >= 0 && hotkey_num < MAX_HOTKEYS )
memcpy(&p->hotkeys[hotkey_num], &tmp_hotkey, sizeof(tmp_hotkey));
@@ -1333,7 +1335,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
if (save_log) ShowInfo("Loaded char (%d - %s): %s\n", char_id, p->name, t_msg); //ok. all data load successfuly!
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
StrBuf->Destroy(&buf);
/* load options into proper vars */
@@ -2024,7 +2026,9 @@ static void char_auth_ok(int fd, struct char_session_data *sd)
{ //Character already online. KICK KICK KICK
mapif_disconnectplayer(server[character->server].fd, character->account_id, character->char_id, 2);
if (character->waiting_disconnect == INVALID_TIMER)
- character->waiting_disconnect = add_timer(gettick()+20000, chardb_waiting_disconnect, character->account_id, 0);
+ character->waiting_disconnect = iTimer->add_timer(iTimer->gettick()+20000, chardb_waiting_disconnect, character->account_id, 0);
+ if (character)
+ character->pincode_enable = -1;
WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x81;
WFIFOB(fd,2) = 8;
@@ -2101,7 +2105,7 @@ void loginif_on_ready(void)
loginif_check_shutdown();
//Send online accounts to login server.
- send_accounts_tologin(INVALID_TIMER, gettick(), 0, 0);
+ send_accounts_tologin(INVALID_TIMER, iTimer->gettick(), 0, 0);
// if no map-server already connected, display a message...
ARR_FIND( 0, ARRAYLENGTH(server), i, server[i].fd > 0 && server[i].map[0] );
@@ -2382,7 +2386,7 @@ int parse_fromlogin(int fd) {
{ //Kick it from the map server it is on.
mapif_disconnectplayer(server[character->server].fd, character->account_id, character->char_id, 2);
if (character->waiting_disconnect == INVALID_TIMER)
- character->waiting_disconnect = add_timer(gettick()+AUTH_TIMEOUT, chardb_waiting_disconnect, character->account_id, 0);
+ character->waiting_disconnect = iTimer->add_timer(iTimer->gettick()+AUTH_TIMEOUT, chardb_waiting_disconnect, character->account_id, 0);
}
else
{// Manual kick from char server.
@@ -2451,12 +2455,12 @@ int send_accounts_tologin(int tid, unsigned int tick, int id, intptr_t data);
void do_init_loginif(void)
{
// establish char-login connection if not present
- add_timer_func_list(check_connect_login_server, "check_connect_login_server");
- add_timer_interval(gettick() + 1000, check_connect_login_server, 0, 0, 10 * 1000);
+ iTimer->add_timer_func_list(check_connect_login_server, "check_connect_login_server");
+ iTimer->add_timer_interval(iTimer->gettick() + 1000, check_connect_login_server, 0, 0, 10 * 1000);
// send a list of all online account IDs to login server
- add_timer_func_list(send_accounts_tologin, "send_accounts_tologin");
- add_timer_interval(gettick() + 1000, send_accounts_tologin, 0, 0, 3600 * 1000); //Sync online accounts every hour
+ iTimer->add_timer_func_list(send_accounts_tologin, "send_accounts_tologin");
+ iTimer->add_timer_interval(iTimer->gettick() + 1000, send_accounts_tologin, 0, 0, 3600 * 1000); //Sync online accounts every hour
}
void do_final_loginif(void)
@@ -2628,7 +2632,7 @@ int search_mapserver(unsigned short map, uint32 ip, uint16 port);
/// Initializes a server structure.
void mapif_server_init(int id)
{
- memset(&server[id], 0, sizeof(server[id]));
+ //memset(&server[id], 0, sizeof(server[id]));
server[id].fd = -1;
}
@@ -2655,7 +2659,7 @@ void mapif_server_reset(int id)
WBUFL(buf,4) = htonl(server[id].ip);
WBUFW(buf,8) = htons(server[id].port);
j = 0;
- for(i = 0; i < MAX_MAP_PER_SERVER; i++)
+ for(i = 0; i < server[id].maps; i++)
if (server[id].map[i])
WBUFW(buf,10+(j++)*4) = server[id].map[i];
if (j > 0) {
@@ -2725,8 +2729,11 @@ int parse_frommap(int fd)
case 0x2afa: // Receiving map names list from the map-server
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
-
- memset(server[id].map, 0, sizeof(server[id].map));
+ if( server[id].map != NULL ) { aFree(server[id].map); server[id].map = NULL; }
+
+ server[id].maps = ( RFIFOW(fd, 2) - 4 ) / 4;
+ CREATE(server[id].map, unsigned short, server[id].maps);
+
j = 0;
for(i = 4; i < RFIFOW(fd,2); i += 4) {
server[id].map[j] = RFIFOW(fd,i);
@@ -3392,10 +3399,14 @@ int parse_frommap(int fd)
if( RFIFOREST(fd) < RFIFOW(fd,4) )
return 0;/* packet wasn't fully received yet (still fragmented) */
else {
- int sfd;/* stat server fd */
+ int sfd;/* stat server fd */
+ struct hSockOpt opt;
RFIFOSKIP(fd, 2);/* we skip first 2 bytes which are the 0x3008, so we end up with a buffer equal to the one we send */
- if( (sfd = make_connection(host2ip("stats.hercules.ws"),(uint16)25427,true) ) == -1 ) {
+ opt.silent = 1;
+ opt.setTimeo = 1;
+
+ if( (sfd = make_connection(host2ip("stats.hercules.ws"),(uint16)25427,&opt) ) == -1 ) {
RFIFOSKIP(fd, RFIFOW(fd,2) );/* skip this packet */
RFIFOFLUSH(fd);
break;/* connection not possible, we drop the report */
@@ -4275,7 +4286,6 @@ int parse_char(int fd)
server[i].ip = ntohl(RFIFOL(fd,54));
server[i].port = ntohs(RFIFOW(fd,58));
server[i].users = 0;
- memset(server[i].map, 0, sizeof(server[i].map));
session[fd]->func_parse = parse_frommap;
session[fd]->flag.server = 1;
realloc_fifo(fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
@@ -4486,12 +4496,12 @@ int check_connect_login_server(int tid, unsigned int tick, int id, intptr_t data
return 0;
ShowInfo("Attempt to connect to login-server...\n");
- login_fd = make_connection(login_ip, login_port, false);
- if (login_fd == -1)
- { //Try again later. [Skotlex]
+
+ if ( (login_fd = make_connection(login_ip, login_port, NULL)) == -1) { //Try again later. [Skotlex]
login_fd = 0;
return 0;
}
+
session[login_fd]->func_parse = parse_fromlogin;
session[login_fd]->flag.server = 1;
realloc_fifo(login_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
@@ -4679,6 +4689,10 @@ void sql_config_read(const char* cfgName)
safestrncpy(mercenary_db,w2,sizeof(mercenary_db));
else if(!strcmpi(w1,"mercenary_owner_db"))
safestrncpy(mercenary_owner_db,w2,sizeof(mercenary_owner_db));
+ else if(!strcmpi(w1,"ragsrvinfo_db"))
+ safestrncpy(ragsrvinfo_db,w2,sizeof(ragsrvinfo_db));
+ else if(!strcmpi(w1,"interreg_db"))
+ safestrncpy(interreg_db,w2,sizeof(interreg_db));
//support the import command, just like any other config
else if(!strcmpi(w1,"import"))
sql_config_read(w2);
@@ -4858,8 +4872,8 @@ int char_config_read(const char* cfgName)
return 0;
}
-void do_final(void)
-{
+void do_final(void) {
+ int i;
ShowStatus("Terminating...\n");
set_all_offline(-1);
@@ -4879,8 +4893,7 @@ void do_final(void)
online_char_db->destroy(online_char_db, NULL);
auth_db->destroy(auth_db, NULL);
- if( char_fd != -1 )
- {
+ if( char_fd != -1 ) {
do_close(char_fd);
char_fd = -1;
}
@@ -4888,6 +4901,10 @@ void do_final(void)
SQL->Free(sql_handle);
mapindex_final();
+ for(i = 0; i < MAX_MAP_SERVERS; i++ )
+ if( server[i].map )
+ aFree(server[i].map);
+
ShowStatus("Finished.\n");
}
@@ -4923,11 +4940,17 @@ void do_shutdown(void)
int do_init(int argc, char **argv) {
+ int i;
memset(&skillid2idx, 0, sizeof(skillid2idx));
+
+ for(i = 0; i < MAX_MAP_SERVERS; i++ )
+ server[i].map = NULL;
+
//Read map indexes
mapindex_init();
start_point.map = mapindex_name2id("new_zone01");
+
pincode_defaults();
char_config_read((argc < 2) ? CHAR_CONF_NAME : argv[1]);
@@ -4969,15 +4992,15 @@ int do_init(int argc, char **argv) {
do_init_mapif();
// periodically update the overall user count on all mapservers + login server
- add_timer_func_list(broadcast_user_count, "broadcast_user_count");
- add_timer_interval(gettick() + 1000, broadcast_user_count, 0, 0, 5 * 1000);
+ iTimer->add_timer_func_list(broadcast_user_count, "broadcast_user_count");
+ iTimer->add_timer_interval(iTimer->gettick() + 1000, broadcast_user_count, 0, 0, 5 * 1000);
// Timer to clear (online_char_db)
- add_timer_func_list(chardb_waiting_disconnect, "chardb_waiting_disconnect");
+ iTimer->add_timer_func_list(chardb_waiting_disconnect, "chardb_waiting_disconnect");
// Online Data timers (checking if char still connected)
- add_timer_func_list(online_data_cleanup, "online_data_cleanup");
- add_timer_interval(gettick() + 1000, online_data_cleanup, 0, 0, 600 * 1000);
+ iTimer->add_timer_func_list(online_data_cleanup, "online_data_cleanup");
+ iTimer->add_timer_interval(iTimer->gettick() + 1000, online_data_cleanup, 0, 0, 600 * 1000);
//Cleaning the tables for NULL entrys @ startup [Sirius]
//Chardb clean
diff --git a/src/char/char.h b/src/char/char.h
index b48ea359c..1a9441868 100644
--- a/src/char/char.h
+++ b/src/char/char.h
@@ -45,7 +45,7 @@ struct online_char_data {
DBMap* online_char_db; // int account_id -> struct online_char_data*
-#define MAX_MAP_SERVERS 30
+#define MAX_MAP_SERVERS 2
#define DEFAULT_AUTOSAVE_INTERVAL 300*1000
@@ -103,6 +103,7 @@ extern char skill_homunculus_db[256];
extern char mercenary_db[256];
extern char mercenary_owner_db[256];
extern char ragsrvinfo_db[256];
+extern char interreg_db[32];
extern int db_use_sqldbs; // added for sql item_db read for char server [Valaris]
diff --git a/src/char/int_auction.c b/src/char/int_auction.c
index 977638aad..bf5ea1700 100644
--- a/src/char/int_auction.c
+++ b/src/char/int_auction.c
@@ -56,17 +56,17 @@ void auction_save(struct auction_data *auction)
StrBuf->Printf(&buf, ", `card%d` = '%d'", j, auction->item.card[j]);
StrBuf->Printf(&buf, " WHERE `auction_id` = '%d'", auction->auction_id);
- stmt = SqlStmt_Malloc(sql_handle);
- if( SQL_SUCCESS != SqlStmt_PrepareStr(stmt, StrBuf->Value(&buf))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, auction->seller_name, strnlen(auction->seller_name, NAME_LENGTH))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, auction->buyer_name, strnlen(auction->buyer_name, NAME_LENGTH))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_STRING, auction->item_name, strnlen(auction->item_name, ITEM_NAME_LENGTH))
- || SQL_SUCCESS != SqlStmt_Execute(stmt) )
+ stmt = SQL->StmtMalloc(sql_handle);
+ if( SQL_SUCCESS != SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, auction->seller_name, strnlen(auction->seller_name, NAME_LENGTH))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, auction->buyer_name, strnlen(auction->buyer_name, NAME_LENGTH))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 2, SQLDT_STRING, auction->item_name, strnlen(auction->item_name, ITEM_NAME_LENGTH))
+ || SQL_SUCCESS != SQL->StmtExecute(stmt) )
{
SqlStmt_ShowDebug(stmt);
}
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
StrBuf->Destroy(&buf);
}
@@ -95,12 +95,12 @@ unsigned int auction_create(struct auction_data *auction)
updateLastUid(auction->item.unique_id);
dbUpdateUid(sql_handle);
- stmt = SqlStmt_Malloc(sql_handle);
- if( SQL_SUCCESS != SqlStmt_PrepareStr(stmt, StrBuf->Value(&buf))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, auction->seller_name, strnlen(auction->seller_name, NAME_LENGTH))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, auction->buyer_name, strnlen(auction->buyer_name, NAME_LENGTH))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_STRING, auction->item_name, strnlen(auction->item_name, ITEM_NAME_LENGTH))
- || SQL_SUCCESS != SqlStmt_Execute(stmt) )
+ stmt = SQL->StmtMalloc(sql_handle);
+ if( SQL_SUCCESS != SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, auction->seller_name, strnlen(auction->seller_name, NAME_LENGTH))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, auction->buyer_name, strnlen(auction->buyer_name, NAME_LENGTH))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 2, SQLDT_STRING, auction->item_name, strnlen(auction->item_name, ITEM_NAME_LENGTH))
+ || SQL_SUCCESS != SQL->StmtExecute(stmt) )
{
SqlStmt_ShowDebug(stmt);
auction->auction_id = 0;
@@ -114,8 +114,8 @@ unsigned int auction_create(struct auction_data *auction)
auction->item.identify = 1;
auction->item.expire_time = 0;
- auction->auction_id = (unsigned int)SqlStmt_LastInsertId(stmt);
- auction->auction_end_timer = add_timer( gettick() + tick , auction_end_timer, auction->auction_id, 0);
+ auction->auction_id = (unsigned int)SQL->StmtLastInsertId(stmt);
+ auction->auction_end_timer = iTimer->add_timer( iTimer->gettick() + tick , auction_end_timer, auction->auction_id, 0);
ShowInfo("New Auction %u | time left %u ms | By %s.\n", auction->auction_id, tick, auction->seller_name);
CREATE(auction_, struct auction_data, 1);
@@ -123,7 +123,7 @@ unsigned int auction_create(struct auction_data *auction)
idb_put(auction_db_, auction_->auction_id, auction_);
}
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
StrBuf->Destroy(&buf);
return auction->auction_id;
@@ -170,7 +170,7 @@ void auction_delete(struct auction_data *auction)
Sql_ShowDebug(sql_handle);
if( auction->auction_end_timer != INVALID_TIMER )
- delete_timer(auction->auction_end_timer, auction_end_timer);
+ iTimer->delete_timer(auction->auction_end_timer, auction_end_timer);
idb_remove(auction_db_, auction_id);
}
@@ -182,7 +182,7 @@ void inter_auctions_fromsql(void)
struct item *item;
char *data;
StringBuf buf;
- unsigned int tick = gettick(), endtick;
+ unsigned int tick = iTimer->gettick(), endtick;
time_t now = time(NULL);
StrBuf->Init(&buf);
@@ -234,7 +234,7 @@ void inter_auctions_fromsql(void)
else
endtick = tick + 10000; // 10 Second's to process ended auctions
- auction->auction_end_timer = add_timer(endtick, auction_end_timer, auction->auction_id, 0);
+ auction->auction_end_timer = iTimer->add_timer(endtick, auction_end_timer, auction->auction_id, 0);
idb_put(auction_db_, auction->auction_id, auction);
}
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index e1e012725..a9bce9cbe 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -86,7 +86,7 @@ static int guild_save_timer(int tid, unsigned int tick, int id, intptr_t data)
state = guild_db_->size(guild_db_);
if( state < 1 ) state = 1; //Calculate the time slot for the next save.
- add_timer(tick + autosave_interval/state, guild_save_timer, 0, 0);
+ iTimer->add_timer(tick + autosave_interval/state, guild_save_timer, 0, 0);
return 0;
}
@@ -729,8 +729,8 @@ int inter_guild_sql_init(void)
//Read exp file
sv->readdb("db", DBPATH"exp_guild.txt", ',', 1, 1, 100, exp_guild_parse_row);
- add_timer_func_list(guild_save_timer, "guild_save_timer");
- add_timer(gettick() + 10000, guild_save_timer, 0, 0);
+ iTimer->add_timer_func_list(guild_save_timer, "guild_save_timer");
+ iTimer->add_timer(iTimer->gettick() + 10000, guild_save_timer, 0, 0);
return 0;
}
diff --git a/src/char/int_homun.c b/src/char/int_homun.c
index 6e4f63849..143277f05 100644
--- a/src/char/int_homun.c
+++ b/src/char/int_homun.c
@@ -121,25 +121,25 @@ bool mapif_homunculus_save(struct s_homunculus* hd)
SqlStmt* stmt;
int i;
- stmt = SqlStmt_Malloc(sql_handle);
- if( SQL_ERROR == SqlStmt_Prepare(stmt, "REPLACE INTO `%s` (`homun_id`, `id`, `lv`) VALUES (%d, ?, ?)", skill_homunculus_db, hd->hom_id) )
+ stmt = SQL->StmtMalloc(sql_handle);
+ if( SQL_ERROR == SQL->StmtPrepare(stmt, "REPLACE INTO `%s` (`homun_id`, `id`, `lv`) VALUES (%d, ?, ?)", skill_homunculus_db, hd->hom_id) )
SqlStmt_ShowDebug(stmt);
for( i = 0; i < MAX_HOMUNSKILL; ++i )
{
if( hd->hskill[i].id > 0 && hd->hskill[i].lv != 0 )
{
- SqlStmt_BindParam(stmt, 0, SQLDT_USHORT, &hd->hskill[i].id, 0);
- SqlStmt_BindParam(stmt, 1, SQLDT_USHORT, &hd->hskill[i].lv, 0);
- if( SQL_ERROR == SqlStmt_Execute(stmt) )
+ SQL->StmtBindParam(stmt, 0, SQLDT_USHORT, &hd->hskill[i].id, 0);
+ SQL->StmtBindParam(stmt, 1, SQLDT_USHORT, &hd->hskill[i].lv, 0);
+ if( SQL_ERROR == SQL->StmtExecute(stmt) )
{
SqlStmt_ShowDebug(stmt);
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
flag = false;
break;
}
}
}
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
}
}
diff --git a/src/char/int_mail.c b/src/char/int_mail.c
index 9181b7db6..e4b88b5bf 100644
--- a/src/char/int_mail.c
+++ b/src/char/int_mail.c
@@ -122,20 +122,20 @@ int mail_savemessage(struct mail_message* msg)
dbUpdateUid(sql_handle);
// prepare and execute query
- stmt = SqlStmt_Malloc(sql_handle);
- if( SQL_SUCCESS != SqlStmt_PrepareStr(stmt, StrBuf->Value(&buf))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, msg->send_name, strnlen(msg->send_name, NAME_LENGTH))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, msg->dest_name, strnlen(msg->dest_name, NAME_LENGTH))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_STRING, msg->title, strnlen(msg->title, MAIL_TITLE_LENGTH))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 3, SQLDT_STRING, msg->body, strnlen(msg->body, MAIL_BODY_LENGTH))
- || SQL_SUCCESS != SqlStmt_Execute(stmt) )
+ stmt = SQL->StmtMalloc(sql_handle);
+ if( SQL_SUCCESS != SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, msg->send_name, strnlen(msg->send_name, NAME_LENGTH))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, msg->dest_name, strnlen(msg->dest_name, NAME_LENGTH))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 2, SQLDT_STRING, msg->title, strnlen(msg->title, MAIL_TITLE_LENGTH))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 3, SQLDT_STRING, msg->body, strnlen(msg->body, MAIL_BODY_LENGTH))
+ || SQL_SUCCESS != SQL->StmtExecute(stmt) )
{
SqlStmt_ShowDebug(stmt);
msg->id = 0;
} else
- msg->id = (int)SqlStmt_LastInsertId(stmt);
+ msg->id = (int)SQL->StmtLastInsertId(stmt);
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
StrBuf->Destroy(&buf);
return msg->id;
diff --git a/src/char/int_quest.c b/src/char/int_quest.c
index d771543cc..af8f83a5d 100644
--- a/src/char/int_quest.c
+++ b/src/char/int_quest.c
@@ -26,7 +26,7 @@ int mapif_quests_fromsql(int char_id, struct quest questlog[])
struct quest tmp_quest;
SqlStmt * stmt;
- stmt = SqlStmt_Malloc(sql_handle);
+ stmt = SQL->StmtMalloc(sql_handle);
if( stmt == NULL )
{
SqlStmt_ShowDebug(stmt);
@@ -35,21 +35,21 @@ int mapif_quests_fromsql(int char_id, struct quest questlog[])
memset(&tmp_quest, 0, sizeof(struct quest));
- if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `quest_id`, `state`, `time`, `count1`, `count2`, `count3` FROM `%s` WHERE `char_id`=? LIMIT %d", quest_db, MAX_QUEST_DB)
- || SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
- || SQL_ERROR == SqlStmt_Execute(stmt)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &tmp_quest.quest_id, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_INT, &tmp_quest.state, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_UINT, &tmp_quest.time, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_INT, &tmp_quest.count[0], 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_INT, &tmp_quest.count[1], 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 5, SQLDT_INT, &tmp_quest.count[2], 0, NULL, NULL) )
+ if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `quest_id`, `state`, `time`, `count1`, `count2`, `count3` FROM `%s` WHERE `char_id`=? LIMIT %d", quest_db, MAX_QUEST_DB)
+ || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
+ || SQL_ERROR == SQL->StmtExecute(stmt)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &tmp_quest.quest_id, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_INT, &tmp_quest.state, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UINT, &tmp_quest.time, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_INT, &tmp_quest.count[0], 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_INT, &tmp_quest.count[1], 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_INT, &tmp_quest.count[2], 0, NULL, NULL) )
SqlStmt_ShowDebug(stmt);
- for( i = 0; i < MAX_QUEST_DB && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i )
+ for( i = 0; i < MAX_QUEST_DB && SQL_SUCCESS == SQL->StmtNextRow(stmt); ++i )
memcpy(&questlog[i], &tmp_quest, sizeof(tmp_quest));
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
return i;
}
diff --git a/src/char/inter.c b/src/char/inter.c
index a1b075a14..1ff2bca61 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -946,7 +946,7 @@ int check_ttl_wisdata_sub(DBKey key, DBData *data, va_list ap)
int check_ttl_wisdata(void)
{
- unsigned long tick = gettick();
+ unsigned long tick = iTimer->gettick();
int i;
do {
@@ -1039,7 +1039,7 @@ int mapif_parse_WisRequest(int fd)
memcpy(wd->src, RFIFOP(fd, 4), NAME_LENGTH);
memcpy(wd->dst, RFIFOP(fd,28), NAME_LENGTH);
memcpy(wd->msg, RFIFOP(fd,52), wd->len);
- wd->tick = gettick();
+ wd->tick = iTimer->gettick();
idb_put(wis_db, wd->id, wd);
mapif_wis_message(wd);
}
diff --git a/src/char/inter.h b/src/char/inter.h
index de27b0473..f6663813a 100644
--- a/src/char/inter.h
+++ b/src/char/inter.h
@@ -7,6 +7,7 @@
struct accreg;
#include "../common/sql.h"
+#include "char.h"
int inter_init_sql(const char *file);
void inter_final(void);
@@ -32,7 +33,7 @@ uint64 inter_chk_lastuid(int8 flag, uint64 value);
#define dbUpdateUid(handler_)\
{ \
uint64 unique_id_ = inter_chk_lastuid(0, 0); \
- if (unique_id_ && SQL_ERROR == SQL->Query(handler_, "UPDATE `interreg` SET `value`='%"PRIu64"' WHERE `varname`='unique_id'", unique_id_)) \
+ if (unique_id_ && SQL_ERROR == SQL->Query(handler_, "UPDATE `%s` SET `value`='%"PRIu64"' WHERE `varname`='unique_id'", interreg_db, unique_id_)) \
Sql_ShowDebug(handler_);\
}
#else
diff --git a/src/common/HPM.c b/src/common/HPM.c
index 28ea8f413..9283360dc 100644
--- a/src/common/HPM.c
+++ b/src/common/HPM.c
@@ -265,7 +265,7 @@ void hplugins_share_defaults(void) {
HPM->share((void*)get_svn_revision,"get_svn_revision");
HPM->share((void*)get_git_hash,"get_git_hash");
HPM->share(DB, "DB");
- HPM->share(malloclib, "malloclib");
+ HPM->share(iMalloc, "iMalloc");
/* socket */
HPM->share(RFIFOSKIP,"RFIFOSKIP");
HPM->share(WFIFOSET,"WFIFOSET");
@@ -281,12 +281,8 @@ void hplugins_share_defaults(void) {
/* sql */
HPM->share(SQL,"SQL");
/* timer */
- HPM->share(gettick,"gettick");
- HPM->share(add_timer,"add_timer");
- HPM->share(add_timer_interval,"add_timer_interval");
- HPM->share(add_timer_func_list,"add_timer_func_list");
- HPM->share(delete_timer,"delete_timer");
- HPM->share(get_uptime,"get_uptime");
+ HPM->share(iTimer,"iTimer");
+
}
CPCMD(plugins) {
if( HPM->plugin_count == 0 ) {
diff --git a/src/common/console.c b/src/common/console.c
index ba93b8e09..08daec04e 100644
--- a/src/common/console.c
+++ b/src/common/console.c
@@ -85,6 +85,9 @@ CPCMD(exit) {
CPCMD(ers_report) {
ers_report();
}
+CPCMD(mem_report) {
+ memmgr_report(line?atoi(line):0);
+}
CPCMD(help) {
unsigned int i = 0;
for ( i = 0; i < console->cmd_list_count; i++ ) {
@@ -98,7 +101,7 @@ CPCMD(help) {
}
/* [Ind/Hercules] */
CPCMD(malloc_usage) {
- unsigned int val = (unsigned int)malloclib->usage();
+ unsigned int val = (unsigned int)iMalloc->usage();
ShowInfo("malloc_usage: %.2f MB\n",(double)(val)/1024);
}
#define CP_DEF_C(x) { #x , NULL , NULL, NULL }
@@ -115,6 +118,7 @@ void console_load_defaults(void) {
CP_DEF(help),
CP_DEF_C(server),
CP_DEF_S(ers_report,server),
+ CP_DEF_S(mem_report,server),
CP_DEF_S(malloc_usage,server),
CP_DEF_S(exit,server),
};
@@ -227,8 +231,10 @@ void console_parse_sub(char *line) {
char *tok;
char sublist[CP_CMD_LENGTH * 5];
unsigned int i, len = 0;
+
memcpy(bline, line, 200);
tok = strtok(line, " ");
+
for ( i = 0; i < console->cmd_list_count; i++ ) {
if( strcmpi(tok,console->cmd_list[i]->cmd) == 0 )
break;
@@ -363,8 +369,8 @@ void console_parse_init(void) {
exit(EXIT_FAILURE);
}
- add_timer_func_list(console->parse_timer, "console_parse_timer");
- add_timer_interval(gettick() + 1000, console->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */
+ iTimer->add_timer_func_list(console->parse_timer, "console_parse_timer");
+ iTimer->add_timer_interval(iTimer->gettick() + 1000, console->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */
}
#endif /* CONSOLE_INPUT */
diff --git a/src/common/core.c b/src/common/core.c
index 0959e6fc9..c53d2243b 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -307,7 +307,7 @@ int main (int argc, char **argv) {
}
core_defaults();
- malloclib->init();// needed for Show* in display_title() [FlavioJS]
+ iMalloc->init();// needed for Show* in display_title() [FlavioJS]
console->display_title();
@@ -329,7 +329,7 @@ int main (int argc, char **argv) {
cevents_init();
#endif
- timer_init();
+ iTimer->init();
console->init();
@@ -343,7 +343,7 @@ int main (int argc, char **argv) {
{// Main runtime cycle
int next;
while (runflag != CORE_ST_STOP) {
- next = do_timer(gettick_nocache());
+ next = iTimer->do_timer(iTimer->gettick_nocache());
do_sockets(next);
}
}
@@ -354,14 +354,14 @@ int main (int argc, char **argv) {
#ifndef MINICORE
HPM->final();
#endif
- timer_final();
+ iTimer->final();
socket_final();
DB->final();
mempool_final();
rathread_final();
#endif
- malloclib->final();
+ iMalloc->final();
return 0;
}
diff --git a/src/common/db.c b/src/common/db.c
index 561371787..99c758a8d 100644
--- a/src/common/db.c
+++ b/src/common/db.c
@@ -2611,6 +2611,7 @@ void* db_data2ptr(DBData *data)
void db_init(void) {
db_iterator_ers = ers_new(sizeof(struct DBIterator_impl),"db.c::db_iterator_ers",ERS_OPT_NONE);
db_alloc_ers = ers_new(sizeof(struct DBMap_impl),"db.c::db_alloc_ers",ERS_OPT_NONE);
+ ers_chunk_size(db_alloc_ers, 50);
DB_COUNTSTAT(db_init);
}
diff --git a/src/common/ers.c b/src/common/ers.c
index 69b7609d6..22269a51f 100644
--- a/src/common/ers.c
+++ b/src/common/ers.c
@@ -84,6 +84,9 @@ typedef struct ers_cache
// Objects in-use count
unsigned int UsedObjs;
+ // Default = ERS_BLOCK_ENTRIES, can be adjusted for performance for individual cache sizes.
+ unsigned int ChunkSize;
+
// Linked list
struct ers_cache *Next, *Prev;
} ers_cache_t;
@@ -136,6 +139,7 @@ static ers_cache_t *ers_find_cache(unsigned int size)
cache->Used = 0;
cache->UsedObjs = 0;
cache->Max = 0;
+ cache->ChunkSize = ERS_BLOCK_ENTRIES;
if (CacheList == NULL)
{
@@ -200,10 +204,10 @@ static void *ers_obj_alloc_entry(ERS self)
RECREATE(instance->Cache->Blocks, unsigned char *, instance->Cache->Max);
}
- CREATE(instance->Cache->Blocks[instance->Cache->Used], unsigned char, instance->Cache->ObjectSize * ERS_BLOCK_ENTRIES);
+ CREATE(instance->Cache->Blocks[instance->Cache->Used], unsigned char, instance->Cache->ObjectSize * instance->Cache->ChunkSize);
instance->Cache->Used++;
- instance->Cache->Free = ERS_BLOCK_ENTRIES -1;
+ instance->Cache->Free = instance->Cache->ChunkSize -1;
ret = &instance->Cache->Blocks[instance->Cache->Used - 1][instance->Cache->Free * instance->Cache->ObjectSize + sizeof(struct ers_list)];
}
@@ -286,6 +290,18 @@ static void ers_obj_destroy(ERS self)
aFree(instance);
}
+void ers_cache_size(ERS self, unsigned int new_size) {
+ struct ers_instance_t *instance = (struct ers_instance_t *)self;
+
+ if (instance == NULL) {//change as per piotrhalaczkiewicz comment
+ ShowError("ers_cache_size: NULL object, skipping...\n");
+ return;
+ }
+
+ instance->Cache->ChunkSize = new_size;
+}
+
+
ERS ers_new(uint32 size, char *name, enum ERSOptions options)
{
struct ers_instance_t *instance;
@@ -299,6 +315,7 @@ ERS ers_new(uint32 size, char *name, enum ERSOptions options)
instance->VTable.free = ers_obj_free_entry;
instance->VTable.entry_size = ers_obj_entry_size;
instance->VTable.destroy = ers_obj_destroy;
+ instance->VTable.chunk_size = ers_cache_size;
instance->Name = ( options & ERS_OPT_FREE_NAME ) ? aStrdup(name) : name;
instance->Options = options;
diff --git a/src/common/ers.h b/src/common/ers.h
index 4871d8d50..51701d778 100644
--- a/src/common/ers.h
+++ b/src/common/ers.h
@@ -119,6 +119,8 @@ typedef struct eri {
*/
void (*destroy)(struct eri *self);
+ /* */
+ void (*chunk_size) (struct eri *self, unsigned int new_size);
} *ERS;
#ifdef DISABLE_ERS
@@ -127,6 +129,7 @@ typedef struct eri {
# define ers_free(obj,entry) aFree(entry)
# define ers_entry_size(obj) (size_t)0
# define ers_destroy(obj)
+# define ers_chunk_size(obj,size)
// Disable the public functions
# define ers_new(size,name,options) NULL
# define ers_report()
@@ -138,6 +141,7 @@ typedef struct eri {
# define ers_free(obj,entry) (obj)->free((obj),(entry))
# define ers_entry_size(obj) (obj)->entry_size(obj)
# define ers_destroy(obj) (obj)->destroy(obj)
+# define ers_chunk_size(obj,size) (obj)->chunk_size(obj,size)
/**
* Get a new instance of the manager that handles the specified entry size.
@@ -154,7 +158,7 @@ ERS ers_new(uint32 size, char *name, enum ERSOptions options);
/**
* Print a report about the current state of the Entry Reusage System.
* Shows information about the global system and each entry manager.
- * The number of entries are checked and a warning is shown if extra reusable
+ * The number of entries are checked and a warning is shown if extra reusable
* entries are found.
* The extra entries are included in the count of reusable entries.
*/
diff --git a/src/common/malloc.c b/src/common/malloc.c
index 592027f56..d629aa63f 100644
--- a/src/common/malloc.c
+++ b/src/common/malloc.c
@@ -200,6 +200,8 @@ static struct unit_head_large *unit_head_large_first = NULL;
static struct block* block_malloc(unsigned short hash);
static void block_free(struct block* p);
static size_t memmgr_usage_bytes;
+static size_t memmgr_usage_bytes_t;
+
#define block2unit(p, n) ((struct unit_head*)(&(p)->data[ p->unit_size * (n) ]))
#define memmgr_assert(v) do { if(!(v)) { ShowError("Memory manager: assertion '" #v "' failed!\n"); } } while(0)
@@ -245,6 +247,7 @@ void* _mmalloc(size_t size, const char *file, int line, const char *func )
/* At that time, the distinction by assigning NULL to unit_head.block */
if(hash2size(size_hash) > BLOCK_DATA_SIZE - sizeof(struct unit_head)) {
struct unit_head_large* p = (struct unit_head_large*)MALLOC(sizeof(struct unit_head_large)+size,file,line,func);
+ memmgr_usage_bytes_t += size+sizeof(struct unit_head_large);
if(p != NULL) {
p->size = size;
p->unit_head.block = NULL;
@@ -332,7 +335,7 @@ void* _mmalloc(size_t size, const char *file, int line, const char *func )
void* _mcalloc(size_t num, size_t size, const char *file, int line, const char *func )
{
- void *p = malloclib->malloc(num * size,file,line,func);
+ void *p = iMalloc->malloc(num * size,file,line,func);
memset(p,0,num * size);
return p;
}
@@ -341,7 +344,7 @@ void* _mrealloc(void *memblock, size_t size, const char *file, int line, const c
{
size_t old_size;
if(memblock == NULL) {
- return malloclib->malloc(size,file,line,func);
+ return iMalloc->malloc(size,file,line,func);
}
old_size = ((struct unit_head *)((char *)memblock - sizeof(struct unit_head) + sizeof(long)))->size;
@@ -353,11 +356,11 @@ void* _mrealloc(void *memblock, size_t size, const char *file, int line, const c
return memblock;
} else {
// Size Large
- void *p = malloclib->malloc(size,file,line,func);
+ void *p = iMalloc->malloc(size,file,line,func);
if(p != NULL) {
memcpy(p,memblock,old_size);
}
- malloclib->free(memblock,file,line,func);
+ iMalloc->free(memblock,file,line,func);
return p;
}
}
@@ -368,7 +371,7 @@ char* _mstrdup(const char *p, const char *file, int line, const char *func )
return NULL;
} else {
size_t len = strlen(p);
- char *string = (char *)malloclib->malloc(len + 1,file,line,func);
+ char *string = (char *)iMalloc->malloc(len + 1,file,line,func);
memcpy(string,p,len+1);
return string;
}
@@ -401,6 +404,7 @@ void _mfree(void *ptr, const char *file, int line, const char *func )
head_large->next->prev = head_large->prev;
}
memmgr_usage_bytes -= head_large->size;
+ memmgr_usage_bytes_t -= head_large->size + sizeof(struct unit_head_large);
#ifdef DEBUG_MEMMGR
// set freed memory to 0xfd
memset(ptr, 0xfd, head_large->size);
@@ -457,6 +461,7 @@ static struct block* block_malloc(unsigned short hash)
} else {
/* Newly allocated space for the block */
p = (struct block*)MALLOC(sizeof(struct block) * (BLOCK_ALLOC), __FILE__, __LINE__, __func__ );
+ memmgr_usage_bytes_t += sizeof(struct block) * (BLOCK_ALLOC);
if(p == NULL) {
ShowFatalError("Memory manager::block_alloc failed.\n");
exit(EXIT_FAILURE);
@@ -621,7 +626,7 @@ static void memmgr_final (void)
memmgr_log (buf);
#endif /* LOG_MEMMGR */
// get block pointer and free it [celest]
- malloclib->free(ptr, ALC_MARK);
+ iMalloc->free(ptr, ALC_MARK);
}
}
}
@@ -650,6 +655,86 @@ static void memmgr_final (void)
}
#endif /* LOG_MEMMGR */
}
+/* [Ind/Hercules] */
+void memmgr_report (int extra) {
+ struct block *block = block_first;
+ struct unit_head_large *large = unit_head_large_first;
+ unsigned int count = 0, size = 0;
+ int j;
+ unsigned short msize = 1024;
+ struct {
+ const char *file;
+ unsigned short line;
+ unsigned int size;
+ unsigned int count;
+ } data[100];
+ memset(&data, 0, sizeof(data));
+
+ if( extra != 0 )
+ msize = extra;
+
+ while (block) {
+ if (block->unit_used) {
+ int i;
+ for (i = 0; i < block->unit_maxused; i++) {
+ struct unit_head *head = block2unit(block, i);
+ if( head->block != NULL && head->size > msize ) {
+ for( j = 0; j < 100; j++ ) {
+ if( data[j].file == head->file && data[j].line == head->line ) {
+ data[j].size += head->size;
+ data[j].count += 1;
+ break;
+ } else if( data[j].size == 0 ) {
+ data[j].file = head->file;
+ data[j].line = head->line;
+ data[j].size = head->size;
+ data[j].count += 1;
+ break;
+ }
+ }
+ size += (unsigned int)head->size;
+ count++;
+ }
+ }
+ }
+ block = block->block_next;
+ }
+
+ while(large) {
+ if( large->size > msize ) {
+ for( j = 0; j < 100; j++ ) {
+ if( data[j].file == large->unit_head.file && data[j].line == large->unit_head.line ) {
+ data[j].size += large->size;
+ data[j].count += 1;
+ break;
+ } else if( data[j].size == 0 ) {
+ data[j].file = large->unit_head.file;
+ data[j].line = large->unit_head.line;
+ data[j].size = large->size;
+ data[j].count += 1;
+ break;
+ }
+ }
+ size += (unsigned int)large->size;
+ count++;
+ }
+ large = large->next;
+ }
+ for( j = 0; j < 100; j++ ) {
+ if( data[j].size != 0 ) {
+ ShowMessage("[malloc] : "CL_WHITE"%s"CL_RESET":"CL_WHITE"%d"CL_RESET" %d instances => %.2f MB\n",data[j].file,data[j].line,data[j].count,(double)((data[j].size)/1024)/1024);
+ }
+ }
+ ShowMessage("[malloc] : reporting %u instances | %.2f MB\n",count,(double)((size)/1024)/1024);
+ ShowMessage("[malloc] : internal usage %.2f MB | %.2f MB\n",(double)((memmgr_usage_bytes_t-memmgr_usage_bytes)/1024)/1024,(double)((memmgr_usage_bytes_t)/1024)/1024);
+
+ if( extra ) {
+ ShowMessage("[malloc] : unit_head_large: %d bytes\n",sizeof(struct unit_head_large));
+ ShowMessage("[malloc] : unit_head: %d bytes\n",sizeof(struct unit_head));
+ ShowMessage("[malloc] : block: %d bytes\n",sizeof(struct block));
+ }
+
+}
static void memmgr_init (void)
{
@@ -677,8 +762,7 @@ void malloc_memory_check(void)
/// Returns true if a pointer is valid.
/// The check is best-effort, false positives are possible.
-bool malloc_verify_ptr(void* ptr)
-{
+bool malloc_verify_ptr(void* ptr) {
#ifdef USE_MEMMGR
return memmgr_verify(ptr) && MEMORY_VERIFY(ptr);
#else
@@ -687,8 +771,7 @@ bool malloc_verify_ptr(void* ptr)
}
-size_t malloc_usage (void)
-{
+size_t malloc_usage (void) {
#ifdef USE_MEMMGR
return memmgr_usage ();
#else
@@ -696,16 +779,16 @@ size_t malloc_usage (void)
#endif
}
-void malloc_final (void)
-{
+void malloc_final (void) {
#ifdef USE_MEMMGR
memmgr_final ();
#endif
MEMORY_CHECK();
}
-void malloc_init (void)
-{
+void malloc_init (void) {
+ memmgr_usage_bytes_t = 0;
+ memmgr_usage_bytes = 0;
#if defined(DMALLOC) && defined(CYGWIN)
// http://dmalloc.com/docs/latest/online/dmalloc_19.html
dmalloc_debug_setup(getenv("DMALLOC_OPTIONS"));
@@ -720,27 +803,26 @@ void malloc_init (void)
#endif
}
-void malloc_defaults()
-{
- malloclib = &malloclib_s;
- malloclib->init = malloc_init;
- malloclib->final = malloc_final;
- malloclib->memory_check = malloc_memory_check;
- malloclib->usage = malloc_usage;
- malloclib->verify_ptr = malloc_verify_ptr;
+void malloc_defaults(void) {
+ iMalloc = &iMalloc_s;
+ iMalloc->init = malloc_init;
+ iMalloc->final = malloc_final;
+ iMalloc->memory_check = malloc_memory_check;
+ iMalloc->usage = malloc_usage;
+ iMalloc->verify_ptr = malloc_verify_ptr;
// Athena's built-in Memory Manager
#ifdef USE_MEMMGR
- malloclib->malloc = _mmalloc;
- malloclib->calloc = _mcalloc;
- malloclib->realloc = _mrealloc;
- malloclib->astrdup = _mstrdup;
- malloclib->free = _mfree;
+ iMalloc->malloc = _mmalloc;
+ iMalloc->calloc = _mcalloc;
+ iMalloc->realloc = _mrealloc;
+ iMalloc->astrdup = _mstrdup;
+ iMalloc->free = _mfree;
#else
- malloclib->malloc = aMalloc_;
- malloclib->calloc = aCalloc_;
- malloclib->realloc = aRealloc_;
- malloclib->astrdup = aStrdup_;
- malloclib->free = aFree_;
+ iMalloc->malloc = aMalloc_;
+ iMalloc->calloc = aCalloc_;
+ iMalloc->realloc = aRealloc_;
+ iMalloc->astrdup = aStrdup_;
+ iMalloc->free = aFree_;
#endif
}
diff --git a/src/common/malloc.h b/src/common/malloc.h
index 34a26b56e..834781905 100644
--- a/src/common/malloc.h
+++ b/src/common/malloc.h
@@ -30,11 +30,11 @@
#undef LOG_MEMMGR
#endif
-# define aMalloc(n) malloclib->malloc (n,ALC_MARK)
-# define aCalloc(m,n) malloclib->calloc (m,n,ALC_MARK)
-# define aRealloc(p,n) malloclib->realloc (p,n,ALC_MARK)
-# define aStrdup(p) malloclib->astrdup (p,ALC_MARK)
-# define aFree(p) malloclib->free (p,ALC_MARK)
+# define aMalloc(n) iMalloc->malloc (n,ALC_MARK)
+# define aCalloc(m,n) iMalloc->calloc (m,n,ALC_MARK)
+# define aRealloc(p,n) iMalloc->realloc (p,n,ALC_MARK)
+# define aStrdup(p) iMalloc->astrdup (p,ALC_MARK)
+# define aFree(p) iMalloc->free (p,ALC_MARK)
/////////////// Buffer Creation /////////////////
// Full credit for this goes to Shinomori [Ajarn]
@@ -78,7 +78,9 @@ struct malloc_interface {
size_t (*usage) (void);
void (*init) (void);
void (*final) (void);
-} malloclib_s;
+} iMalloc_s;
-struct malloc_interface *malloclib;
+void memmgr_report (int extra);
+
+struct malloc_interface *iMalloc;
#endif /* _MALLOC_H_ */
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 172b27b15..6e5dae099 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -54,6 +54,13 @@
// Comment the following line if your client is NOT ragexeRE (required because of conflicting packets in ragexe vs ragexeRE).
#define PACKETVER_RE
+// Client support for experimental RagexeRE UI present in 2012-04-10 and 2012-04-18
+#ifdef PACKETVER_RE
+#if (PACKETVER == 20120410) || (PACKETVER == 20120418)
+ #define PARTY_RECRUIT
+#endif
+#endif
+
// Comment the following line to disable sc_data saving. [Skotlex]
#define ENABLE_SC_SAVING
@@ -72,7 +79,6 @@
#define MAX_HOTKEYS 38
#endif
-#define MAX_MAP_PER_SERVER 1500 // Increased to allow creation of Instance Maps
#define MAX_INVENTORY 100
//Max number of characters per account. Note that changing this setting alone is not enough if the client is not hexed to support more characters as well.
#define MAX_CHARS 9
@@ -84,7 +90,7 @@
#define MAX_ZENY 1000000000
#define MAX_FAME 1000000000
#define MAX_CART 100
-#define MAX_SKILL 1477
+#define MAX_SKILL 1478
#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
@@ -104,7 +110,7 @@
#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_DB 2410 // 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]
@@ -527,6 +533,10 @@ struct guild {
/* TODO: still used for something?|: */
unsigned short save_flag; // for TXT saving
+
+ short *instance;
+ unsigned short instances;
+
void *channel;
};
diff --git a/src/common/mutex.c b/src/common/mutex.c
index 6b4f55119..6bb1efdab 100644
--- a/src/common/mutex.c
+++ b/src/common/mutex.c
@@ -201,7 +201,7 @@ void racond_wait( racond c, ramutex m, sysint timeout_ticks){
pthread_cond_wait( &c->hCond, &m->hMutex );
}else{
struct timespec wtime;
- int64 exact_timeout = gettick() + timeout_ticks;
+ int64 exact_timeout = iTimer->gettick() + timeout_ticks;
wtime.tv_sec = exact_timeout/1000;
wtime.tv_nsec = (exact_timeout%1000)*1000000;
diff --git a/src/common/random.c b/src/common/random.c
index 5c048c7eb..a7d432e34 100644
--- a/src/common/random.c
+++ b/src/common/random.c
@@ -17,7 +17,7 @@
/// Initializes the random number generator with an appropriate seed.
void rnd_init(void)
{
- uint32 seed = gettick();
+ uint32 seed = iTimer->gettick();
seed += (uint32)time(NULL);
#if defined(WIN32)
seed += GetCurrentProcessId();
diff --git a/src/common/socket.c b/src/common/socket.c
index 5126d231b..15b20b16f 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -280,9 +280,10 @@ void set_nonblocking(int fd, unsigned long yes)
ShowError("set_nonblocking: Failed to set socket #%d to non-blocking mode (%s) - Please report this!!!\n", fd, error_msg());
}
-void setsocketopts(int fd)
-{
+void setsocketopts(int fd, struct hSockOpt *opt) {
int yes = 1; // reuse fix
+ struct linger lopt;
+
#if !defined(WIN32)
// set SO_REAUSEADDR to true, unix only. on windows this option causes
// the previous owner of the socket to give up, which is not desirable
@@ -297,15 +298,22 @@ void setsocketopts(int fd)
// The RO protocol is mainly single-packet request/response, plus the FIFO model already does packet grouping anyway.
sSetsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&yes, sizeof(yes));
+ if( opt && opt->setTimeo ) {
+ struct timeval timeout;
+
+ timeout.tv_sec = 5;
+ timeout.tv_usec = 0;
+
+ sSetsockopt(fd,SOL_SOCKET,SO_RCVTIMEO,(char *)&timeout,sizeof(timeout));
+ sSetsockopt(fd,SOL_SOCKET,SO_SNDTIMEO,(char *)&timeout,sizeof(timeout));
+ }
+
// force the socket into no-wait, graceful-close mode (should be the default, but better make sure)
//(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/closesocket_2.asp)
- {
- struct linger opt;
- opt.l_onoff = 0; // SO_DONTLINGER
- opt.l_linger = 0; // Do not care
- if( sSetsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&opt, sizeof(opt)) )
+ lopt.l_onoff = 0; // SO_DONTLINGER
+ lopt.l_linger = 0; // Do not care
+ if( sSetsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&lopt, sizeof(lopt)) )
ShowWarning("setsocketopts: Unable to set SO_LINGER mode for connection #%d!\n", fd);
- }
}
/*======================================
@@ -404,8 +412,7 @@ void flush_fifos(void)
/*======================================
* CORE : Connection functions
*--------------------------------------*/
-int connect_client(int listen_fd)
-{
+int connect_client(int listen_fd) {
int fd;
struct sockaddr_in client_address;
socklen_t len;
@@ -417,20 +424,18 @@ int connect_client(int listen_fd)
ShowError("connect_client: accept failed (%s)!\n", error_msg());
return -1;
}
- if( fd == 0 )
- {// reserved
+ if( fd == 0 ) { // reserved
ShowError("connect_client: Socket #0 is reserved - Please report this!!!\n");
sClose(fd);
return -1;
}
- if( fd >= FD_SETSIZE )
- {// socket number too big
+ if( fd >= FD_SETSIZE ) { // socket number too big
ShowError("connect_client: New socket #%d is greater than can we handle! Increase the value of FD_SETSIZE (currently %d) for your OS to fix this!\n", fd, FD_SETSIZE);
sClose(fd);
return -1;
}
- setsocketopts(fd);
+ setsocketopts(fd,NULL);
set_nonblocking(fd, 1);
#ifndef MINICORE
@@ -457,25 +462,22 @@ int make_listen_bind(uint32 ip, uint16 port)
fd = sSocket(AF_INET, SOCK_STREAM, 0);
- if( fd == -1 )
- {
+ if( fd == -1 ) {
ShowError("make_listen_bind: socket creation failed (%s)!\n", error_msg());
exit(EXIT_FAILURE);
}
- if( fd == 0 )
- {// reserved
+ if( fd == 0 ) { // reserved
ShowError("make_listen_bind: Socket #0 is reserved - Please report this!!!\n");
sClose(fd);
return -1;
}
- if( fd >= FD_SETSIZE )
- {// socket number too big
+ if( fd >= FD_SETSIZE ) { // socket number too big
ShowError("make_listen_bind: New socket #%d is greater than can we handle! Increase the value of FD_SETSIZE (currently %d) for your OS to fix this!\n", fd, FD_SETSIZE);
sClose(fd);
return -1;
}
- setsocketopts(fd);
+ setsocketopts(fd,NULL);
set_nonblocking(fd, 1);
server_address.sin_family = AF_INET;
@@ -503,7 +505,7 @@ int make_listen_bind(uint32 ip, uint16 port)
return fd;
}
-int make_connection(uint32 ip, uint16 port, bool silent) {
+int make_connection(uint32 ip, uint16 port, struct hSockOpt *opt) {
struct sockaddr_in remote_address;
int fd;
int result;
@@ -514,31 +516,29 @@ int make_connection(uint32 ip, uint16 port, bool silent) {
ShowError("make_connection: socket creation failed (%s)!\n", error_msg());
return -1;
}
- if( fd == 0 )
- {// reserved
+ if( fd == 0 ) {// reserved
ShowError("make_connection: Socket #0 is reserved - Please report this!!!\n");
sClose(fd);
return -1;
}
- if( fd >= FD_SETSIZE )
- {// socket number too big
+ if( fd >= FD_SETSIZE ) {// socket number too big
ShowError("make_connection: New socket #%d is greater than can we handle! Increase the value of FD_SETSIZE (currently %d) for your OS to fix this!\n", fd, FD_SETSIZE);
sClose(fd);
return -1;
}
- setsocketopts(fd);
+ setsocketopts(fd,opt);
remote_address.sin_family = AF_INET;
remote_address.sin_addr.s_addr = htonl(ip);
remote_address.sin_port = htons(port);
- if( !silent )
+ if( !( opt && opt->silent ) )
ShowStatus("Connecting to %d.%d.%d.%d:%i\n", CONVIP(ip), port);
result = sConnect(fd, (struct sockaddr *)(&remote_address), sizeof(struct sockaddr_in));
if( result == SOCKET_ERROR ) {
- if( !silent )
+ if( !( opt && opt->silent ) )
ShowError("make_connection: connect failed (socket #%d, %s)!\n", fd, error_msg());
do_close(fd);
return -1;
@@ -947,9 +947,9 @@ static int connect_check_(uint32 ip)
if( hist->ddos )
{// flagged as DDoS
return (connect_ok == 2 ? 1 : 0);
- } else if( DIFF_TICK(gettick(),hist->tick) < ddos_interval )
+ } else if( DIFF_TICK(iTimer->gettick(),hist->tick) < ddos_interval )
{// connection within ddos_interval
- hist->tick = gettick();
+ hist->tick = iTimer->gettick();
if( hist->count++ >= ddos_count )
{// DDoS attack detected
hist->ddos = 1;
@@ -959,7 +959,7 @@ static int connect_check_(uint32 ip)
return connect_ok;
} else
{// not within ddos_interval, clear data
- hist->tick = gettick();
+ hist->tick = iTimer->gettick();
hist->count = 0;
return connect_ok;
}
@@ -970,7 +970,7 @@ static int connect_check_(uint32 ip)
CREATE(hist, ConnectHistory, 1);
memset(hist, 0, sizeof(ConnectHistory));
hist->ip = ip;
- hist->tick = gettick();
+ hist->tick = iTimer->gettick();
hist->next = connect_history[ip&0xFFFF];
connect_history[ip&0xFFFF] = hist;
return connect_ok;
@@ -1331,8 +1331,8 @@ void socket_init(void)
#ifndef MINICORE
// Delete old connection history every 5 minutes
memset(connect_history, 0, sizeof(connect_history));
- add_timer_func_list(connect_check_clear, "connect_check_clear");
- add_timer_interval(gettick()+1000, connect_check_clear, 0, 0, 5*60*1000);
+ iTimer->add_timer_func_list(connect_check_clear, "connect_check_clear");
+ iTimer->add_timer_interval(iTimer->gettick()+1000, connect_check_clear, 0, 0, 5*60*1000);
#endif
ShowInfo("Server supports up to '"CL_WHITE"%u"CL_RESET"' concurrent connections.\n", rlim_cur);
diff --git a/src/common/socket.h b/src/common/socket.h
index 4879cb109..b58cbdccf 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#ifndef _SOCKET_H_
#define _SOCKET_H_
@@ -48,6 +49,9 @@
} \
} while(0)
+/* [Ind/Hercules] */
+#define RFIFO2PTR(fd,len) (void*)(session[fd]->rdata + len)
+
// buffer I/O macros
#define RBUFP(p,pos) (((uint8*)(p)) + (pos))
#define RBUFB(p,pos) (*(uint8*)RBUFP((p),(pos)))
@@ -94,6 +98,10 @@ struct socket_data
void* session_data; // stores application-specific data related to the session
};
+struct hSockOpt {
+ unsigned int silent : 1;
+ unsigned int setTimeo : 1;
+};
// Data prototype declaration
@@ -113,7 +121,7 @@ extern bool session_isActive(int fd);
// Function prototype declaration
int make_listen_bind(uint32 ip, uint16 port);
-int make_connection(uint32 ip, uint16 port, bool silent);
+int make_connection(uint32 ip, uint16 port, struct hSockOpt *opt);
int realloc_fifo(int fd, unsigned int rfifo_size, unsigned int wfifo_size);
int realloc_writefifo(int fd, size_t addition);
int WFIFOSET(int fd, size_t len);
diff --git a/src/common/sql.c b/src/common/sql.c
index 391211183..441b860da 100644
--- a/src/common/sql.c
+++ b/src/common/sql.c
@@ -116,9 +116,9 @@ int Sql_GetTimeout(Sql* self, uint32* out_timeout)
size_t len;
if( SQL_SUCCESS == SQL->NextRow(self) &&
SQL_SUCCESS == SQL->GetData(self, 1, &data, &len) ) {
- *out_timeout = (uint32)strtoul(data, NULL, 10);
- SQL->FreeResult(self);
- return SQL_SUCCESS;
+ *out_timeout = (uint32)strtoul(data, NULL, 10);
+ SQL->FreeResult(self);
+ return SQL_SUCCESS;
}
SQL->FreeResult(self);
}
@@ -210,7 +210,7 @@ static int Sql_P_Keepalive(Sql* self)
// establish keepalive
ping_interval = timeout - 30; // 30-second reserve
//add_timer_func_list(Sql_P_KeepaliveTimer, "Sql_P_KeepaliveTimer");
- return add_timer_interval(gettick() + ping_interval*1000, Sql_P_KeepaliveTimer, 0, (intptr_t)self, ping_interval*1000);
+ return iTimer->add_timer_interval(iTimer->gettick() + ping_interval*1000, Sql_P_KeepaliveTimer, 0, (intptr_t)self, ping_interval*1000);
}
@@ -404,7 +404,7 @@ void Sql_Free(Sql* self)
{
SQL->FreeResult(self);
StrBuf->Destroy(&self->buf);
- if( self->keepalive != INVALID_TIMER ) delete_timer(self->keepalive, Sql_P_KeepaliveTimer);
+ if( self->keepalive != INVALID_TIMER ) iTimer->delete_timer(self->keepalive, Sql_P_KeepaliveTimer);
aFree(self);
}
}
@@ -447,7 +447,7 @@ static int Sql_P_BindSqlDataType(MYSQL_BIND* bind, enum SqlDataType buffer_type,
case SQLDT_NULL: bind->buffer_type = MYSQL_TYPE_NULL;
buffer_len = 0;// FIXME length = ? [FlavioJS]
break;
- // fixed size
+ // fixed size
case SQLDT_UINT8: bind->is_unsigned = 1;
case SQLDT_INT8: bind->buffer_type = MYSQL_TYPE_TINY;
buffer_len = 1;
@@ -464,7 +464,7 @@ static int Sql_P_BindSqlDataType(MYSQL_BIND* bind, enum SqlDataType buffer_type,
case SQLDT_INT64: bind->buffer_type = MYSQL_TYPE_LONGLONG;
buffer_len = 8;
break;
- // platform dependent size
+ // platform dependent size
case SQLDT_UCHAR: bind->is_unsigned = 1;
case SQLDT_CHAR: bind->buffer_type = Sql_P_SizeToMysqlIntType(sizeof(char));
buffer_len = sizeof(char);
@@ -485,14 +485,14 @@ static int Sql_P_BindSqlDataType(MYSQL_BIND* bind, enum SqlDataType buffer_type,
case SQLDT_LONGLONG: bind->buffer_type = Sql_P_SizeToMysqlIntType(sizeof(int64));
buffer_len = sizeof(int64);
break;
- // floating point
+ // floating point
case SQLDT_FLOAT: bind->buffer_type = MYSQL_TYPE_FLOAT;
buffer_len = 4;
break;
case SQLDT_DOUBLE: bind->buffer_type = MYSQL_TYPE_DOUBLE;
buffer_len = 8;
break;
- // other
+ // other
case SQLDT_STRING:
case SQLDT_ENUM: bind->buffer_type = MYSQL_TYPE_STRING;
break;
@@ -524,25 +524,25 @@ static void Sql_P_ShowDebugMysqlFieldInfo(const char* prefix, enum enum_field_ty
ShowDebug("%stype=%s%u, length=%d\n", prefix, sign, type, length);
return;
#define SHOW_DEBUG_OF(x) case x: type_string = #x; break
- SHOW_DEBUG_OF(MYSQL_TYPE_TINY);
- SHOW_DEBUG_OF(MYSQL_TYPE_SHORT);
- SHOW_DEBUG_OF(MYSQL_TYPE_LONG);
- SHOW_DEBUG_OF(MYSQL_TYPE_INT24);
- SHOW_DEBUG_OF(MYSQL_TYPE_LONGLONG);
- SHOW_DEBUG_OF(MYSQL_TYPE_DECIMAL);
- SHOW_DEBUG_OF(MYSQL_TYPE_FLOAT);
- SHOW_DEBUG_OF(MYSQL_TYPE_DOUBLE);
- SHOW_DEBUG_OF(MYSQL_TYPE_TIMESTAMP);
- SHOW_DEBUG_OF(MYSQL_TYPE_DATE);
- SHOW_DEBUG_OF(MYSQL_TYPE_TIME);
- SHOW_DEBUG_OF(MYSQL_TYPE_DATETIME);
- SHOW_DEBUG_OF(MYSQL_TYPE_YEAR);
- SHOW_DEBUG_OF(MYSQL_TYPE_STRING);
- SHOW_DEBUG_OF(MYSQL_TYPE_VAR_STRING);
- SHOW_DEBUG_OF(MYSQL_TYPE_BLOB);
- SHOW_DEBUG_OF(MYSQL_TYPE_SET);
- SHOW_DEBUG_OF(MYSQL_TYPE_ENUM);
- SHOW_DEBUG_OF(MYSQL_TYPE_NULL);
+ SHOW_DEBUG_OF(MYSQL_TYPE_TINY);
+ SHOW_DEBUG_OF(MYSQL_TYPE_SHORT);
+ SHOW_DEBUG_OF(MYSQL_TYPE_LONG);
+ SHOW_DEBUG_OF(MYSQL_TYPE_INT24);
+ SHOW_DEBUG_OF(MYSQL_TYPE_LONGLONG);
+ SHOW_DEBUG_OF(MYSQL_TYPE_DECIMAL);
+ SHOW_DEBUG_OF(MYSQL_TYPE_FLOAT);
+ SHOW_DEBUG_OF(MYSQL_TYPE_DOUBLE);
+ SHOW_DEBUG_OF(MYSQL_TYPE_TIMESTAMP);
+ SHOW_DEBUG_OF(MYSQL_TYPE_DATE);
+ SHOW_DEBUG_OF(MYSQL_TYPE_TIME);
+ SHOW_DEBUG_OF(MYSQL_TYPE_DATETIME);
+ SHOW_DEBUG_OF(MYSQL_TYPE_YEAR);
+ SHOW_DEBUG_OF(MYSQL_TYPE_STRING);
+ SHOW_DEBUG_OF(MYSQL_TYPE_VAR_STRING);
+ SHOW_DEBUG_OF(MYSQL_TYPE_BLOB);
+ SHOW_DEBUG_OF(MYSQL_TYPE_SET);
+ SHOW_DEBUG_OF(MYSQL_TYPE_ENUM);
+ SHOW_DEBUG_OF(MYSQL_TYPE_NULL);
#undef SHOW_DEBUG_TYPE_OF
}
ShowDebug("%stype=%s%s, length=%d%s\n", prefix, sign, type_string, length, length_postfix);
@@ -610,7 +610,7 @@ int SqlStmt_Prepare(SqlStmt* self, const char* query, ...)
va_list args;
va_start(args, query);
- res = SqlStmt_PrepareV(self, query, args);
+ res = SQL->StmtPrepareV(self, query, args);
va_end(args);
return res;
@@ -624,7 +624,7 @@ int SqlStmt_PrepareV(SqlStmt* self, const char* query, va_list args)
if( self == NULL )
return SQL_ERROR;
- SqlStmt_FreeResult(self);
+ SQL->StmtFreeResult(self);
StrBuf->Clear(&self->buf);
StrBuf->Vprintf(&self->buf, query, args);
if( mysql_stmt_prepare(self->stmt, StrBuf->Value(&self->buf), (unsigned long)StrBuf->Length(&self->buf)) )
@@ -646,7 +646,7 @@ int SqlStmt_PrepareStr(SqlStmt* self, const char* query)
if( self == NULL )
return SQL_ERROR;
- SqlStmt_FreeResult(self);
+ SQL->StmtFreeResult(self);
StrBuf->Clear(&self->buf);
StrBuf->AppendStr(&self->buf, query);
if( mysql_stmt_prepare(self->stmt, StrBuf->Value(&self->buf), (unsigned long)StrBuf->Length(&self->buf)) )
@@ -677,14 +677,14 @@ size_t SqlStmt_NumParams(SqlStmt* self)
int SqlStmt_BindParam(SqlStmt* self, size_t idx, enum SqlDataType buffer_type, void* buffer, size_t buffer_len)
{
if( self == NULL )
- return SQL_ERROR;
+ return SQL_ERROR;
if( !self->bind_params )
{// initialize the bindings
size_t i;
size_t count;
- count = SqlStmt_NumParams(self);
+ count = SQL->StmtNumParams(self);
if( self->max_params < count )
{
self->max_params = count;
@@ -709,7 +709,7 @@ int SqlStmt_Execute(SqlStmt* self)
if( self == NULL )
return SQL_ERROR;
- SqlStmt_FreeResult(self);
+ SQL->StmtFreeResult(self);
if( (self->bind_params && mysql_stmt_bind_param(self->stmt, self->params)) ||
mysql_stmt_execute(self->stmt) )
{
@@ -772,7 +772,7 @@ int SqlStmt_BindColumn(SqlStmt* self, size_t idx, enum SqlDataType buffer_type,
size_t i;
size_t cols;
- cols = SqlStmt_NumColumns(self);
+ cols = SQL->StmtNumColumns(self);
if( self->max_columns < cols )
{
self->max_columns = cols;
@@ -843,7 +843,7 @@ int SqlStmt_NextRow(SqlStmt* self)
}
// find truncated column
- cols = SqlStmt_NumColumns(self);
+ cols = SQL->StmtNumColumns(self);
for( i = 0; i < cols; ++i )
{
column = &self->columns[i];
@@ -868,7 +868,7 @@ int SqlStmt_NextRow(SqlStmt* self)
}
// propagate column lengths and clear unused parts of string/enum/blob buffers
- cols = SqlStmt_NumColumns(self);
+ cols = SQL->StmtNumColumns(self);
for( i = 0; i < cols; ++i )
{
length = self->column_lengths[i].length;
@@ -946,21 +946,21 @@ void SqlStmt_Free(SqlStmt* self)
void hercules_mysql_error_handler(unsigned int ecode) {
static unsigned int retry = 1;
switch( ecode ) {
- case 2003:/* Can't connect to MySQL (this error only happens here when failing to reconnect) */
- if( mysql_reconnect_type == 1 ) {
- if( ++retry > mysql_reconnect_count ) {
- ShowFatalError("MySQL has been unreachable for too long, %d reconnects were attempted. Shutting Down\n", retry);
- exit(EXIT_FAILURE);
- }
+ case 2003:/* Can't connect to MySQL (this error only happens here when failing to reconnect) */
+ if( mysql_reconnect_type == 1 ) {
+ if( ++retry > mysql_reconnect_count ) {
+ ShowFatalError("MySQL has been unreachable for too long, %d reconnects were attempted. Shutting Down\n", retry);
+ exit(EXIT_FAILURE);
}
- break;
+ }
+ break;
}
}
void Sql_inter_server_read(const char* cfgName, bool first) {
int i;
char line[1024], w1[1024], w2[1024];
FILE* fp;
-
+
fp = fopen(cfgName, "r");
if(fp == NULL) {
if( first ) {
@@ -970,22 +970,22 @@ void Sql_inter_server_read(const char* cfgName, bool first) {
ShowError("File not found: %s\n", cfgName);
return;
}
-
+
while(fgets(line, sizeof(line), fp)) {
i = sscanf(line, "%[^:]: %[^\r\n]", w1, w2);
if(i != 2)
continue;
-
+
if(!strcmpi(w1,"mysql_reconnect_type")) {
mysql_reconnect_type = atoi(w2);
switch( mysql_reconnect_type ) {
- case 1:
- case 2:
- break;
- default:
- ShowError("%s::mysql_reconnect_type is set to %d which is not valid, defaulting to 1...\n", cfgName, mysql_reconnect_type);
- mysql_reconnect_type = 1;
- break;
+ case 1:
+ case 2:
+ break;
+ default:
+ ShowError("%s::mysql_reconnect_type is set to %d which is not valid, defaulting to 1...\n", cfgName, mysql_reconnect_type);
+ mysql_reconnect_type = 1;
+ break;
}
} else if(!strcmpi(w1,"mysql_reconnect_count")) {
mysql_reconnect_count = atoi(w2);
@@ -995,7 +995,7 @@ void Sql_inter_server_read(const char* cfgName, bool first) {
Sql_inter_server_read(w2,false);
}
fclose(fp);
-
+
return;
}
@@ -1003,7 +1003,7 @@ void Sql_HerculesUpdateCheck(Sql* self) {
char line[22];// "yyyy-mm-dd--hh-mm" (17) + ".sql" (4) + 1
FILE* ifp;/* index fp */
unsigned int performed = 0;
-
+
if( !( ifp = fopen("sql-files/upgrades/index.txt", "r") ) ) {
ShowError("SQL upgrade index was not found!\n");
return;
@@ -1013,22 +1013,22 @@ void Sql_HerculesUpdateCheck(Sql* self) {
char path[41];// "sql-files/upgrades/" (19) + "yyyy-mm-dd--hh-mm" (17) + ".sql" (4) + 1
char timestamp[11];// "1360186680" (10) + 1
FILE* ufp;/* upgrade fp */
-
+
if( line[0] == '\n' || ( line[0] == '/' && line[1] == '/' ) )/* skip \n and "//" comments */
continue;
-
+
sprintf(path,"sql-files/upgrades/%s",line);
-
+
if( !( ufp = fopen(path, "r") ) ) {
ShowError("SQL upgrade file %s was not found!\n",path);
continue;
}
-
+
if( fgetc(ufp) != '#' )
continue;
-
+
fseek (ufp,1,SEEK_SET);/* woo. skip the # */
-
+
if( fgets(timestamp,sizeof(timestamp),ufp) ) {
unsigned int timestampui = atol(timestamp);
if( SQL_ERROR == SQL->Query(self, "SELECT 1 FROM `sql_updates` WHERE `timestamp` = '%u' LIMIT 1", timestampui) )
@@ -1038,12 +1038,12 @@ void Sql_HerculesUpdateCheck(Sql* self) {
performed++;
}
}
-
+
fclose(ufp);
}
-
+
fclose(ifp);
-
+
if( performed ) {
ShowSQL("If you did apply these updates or would like to be skip, insert a new entry in your sql_updates table with the timestamp of each file\n");
}
@@ -1054,7 +1054,7 @@ void Sql_Init(void) {
}
void sql_defaults(void) {
SQL = &sql_s;
-
+
SQL->Connect = Sql_Connect;
SQL->GetTimeout = Sql_GetTimeout;
SQL->GetColumnNames = Sql_GetColumnNames;
@@ -1074,4 +1074,21 @@ void sql_defaults(void) {
SQL->ShowDebug_ = Sql_ShowDebug_;
SQL->Free = Sql_Free;
SQL->Malloc = Sql_Malloc;
+
+ /* SqlStmt defaults [Susu] */
+ SQL->StmtBindColumn = SqlStmt_BindColumn;
+ SQL->StmtBindParam = SqlStmt_BindParam;
+ SQL->StmtExecute = SqlStmt_Execute;
+ SQL->StmtFree = SqlStmt_Free;
+ SQL->StmtFreeResult = SqlStmt_FreeResult;
+ SQL->StmtLastInsertId = SqlStmt_LastInsertId;
+ SQL->StmtMalloc = SqlStmt_Malloc;
+ SQL->StmtNextRow = SqlStmt_NextRow;
+ SQL->StmtNumColumns = SqlStmt_NumColumns;
+ SQL->StmtNumParams = SqlStmt_NumParams;
+ SQL->StmtNumRows = SqlStmt_NumRows;
+ SQL->StmtPrepare = SqlStmt_Prepare;
+ SQL->StmtPrepareStr = SqlStmt_PrepareStr;
+ SQL->StmtPrepareV = SqlStmt_PrepareV;
+ SQL->StmtShowDebug_ = SqlStmt_ShowDebug_;
}
diff --git a/src/common/sql.h b/src/common/sql.h
index d5a0eda2c..535990649 100644
--- a/src/common/sql.h
+++ b/src/common/sql.h
@@ -142,145 +142,157 @@ struct sql_interface {
void (*Free) (Sql* self);
/// Allocates and initializes a new Sql handle.
struct Sql *(*Malloc) (void);
-} sql_s;
-struct sql_interface *SQL;
-void sql_defaults(void);
-#if defined(SQL_REMOVE_SHOWDEBUG)
- #define Sql_ShowDebug(self) (void)0
-#else
- #define Sql_ShowDebug(self) SQL->ShowDebug_(self, __FILE__, __LINE__)
-#endif
+ ///////////////////////////////////////////////////////////////////////////////
+ // Prepared Statements
+ ///////////////////////////////////////////////////////////////////////////////
+ // Parameters are placed in the statement by embedding question mark ('?')
+ // characters into the query at the appropriate positions.
+ // The markers are legal only in places where they represent data.
+ // The markers cannot be inside quotes. Quotes will be added automatically
+ // when they are required.
+ //
+ // example queries with parameters:
+ // 1) SELECT col FROM table WHERE id=?
+ // 2) INSERT INTO table(col1,col2) VALUES(?,?)
-///////////////////////////////////////////////////////////////////////////////
-// Prepared Statements
-///////////////////////////////////////////////////////////////////////////////
-// Parameters are placed in the statement by embedding question mark ('?')
-// characters into the query at the appropriate positions.
-// The markers are legal only in places where they represent data.
-// The markers cannot be inside quotes. Quotes will be added automatically
-// when they are required.
-//
-// example queries with parameters:
-// 1) SELECT col FROM table WHERE id=?
-// 2) INSERT INTO table(col1,col2) VALUES(?,?)
-/// Allocates and initializes a new SqlStmt handle.
-/// It uses the connection of the parent Sql handle.
-/// Queries in Sql and SqlStmt are independent and don't affect each other.
-///
-/// @return SqlStmt handle or NULL if an error occured
-struct SqlStmt* SqlStmt_Malloc(Sql* sql);
+ /*=====================================
+ SQL Statement interface [Susu]
+ *-------------------------------------*/
+ /// Allocates and initializes a new SqlStmt handle.
+ /// It uses the connection of the parent Sql handle.
+ /// Queries in Sql and SqlStmt are independent and don't affect each other.
+ ///
+ /// @return SqlStmt handle or NULL if an error occured
+ struct SqlStmt* (*StmtMalloc)(Sql* sql);
-/// Prepares the statement.
-/// Any previous result is freed and all parameter bindings are removed.
-/// The query is constructed as if it was sprintf.
-///
-/// @return SQL_SUCCESS or SQL_ERROR
-int SqlStmt_Prepare(SqlStmt* self, const char* query, ...);
-/// Prepares the statement.
-/// Any previous result is freed and all parameter bindings are removed.
-/// The query is constructed as if it was svprintf.
-///
-/// @return SQL_SUCCESS or SQL_ERROR
-int SqlStmt_PrepareV(SqlStmt* self, const char* query, va_list args);
+ /// Prepares the statement.
+ /// Any previous result is freed and all parameter bindings are removed.
+ /// The query is constructed as if it was sprintf.
+ ///
+ /// @return SQL_SUCCESS or SQL_ERROR
+ int (*StmtPrepare)(SqlStmt* self, const char* query, ...);
+ /// Prepares the statement.
+ /// Any previous result is freed and all parameter bindings are removed.
+ /// The query is constructed as if it was svprintf.
+ ///
+ /// @return SQL_SUCCESS or SQL_ERROR
+ int (*StmtPrepareV)(SqlStmt* self, const char* query, va_list args);
-/// Prepares the statement.
-/// Any previous result is freed and all parameter bindings are removed.
-/// The query is used directly.
-///
-/// @return SQL_SUCCESS or SQL_ERROR
-int SqlStmt_PrepareStr(SqlStmt* self, const char* query);
+ /// Prepares the statement.
+ /// Any previous result is freed and all parameter bindings are removed.
+ /// The query is used directly.
+ ///
+ /// @return SQL_SUCCESS or SQL_ERROR
+ int (*StmtPrepareStr)(SqlStmt* self, const char* query);
-/// Returns the number of parameters in the prepared statement.
-///
-/// @return Number or paramenters
-size_t SqlStmt_NumParams(SqlStmt* self);
+ /// Returns the number of parameters in the prepared statement.
+ ///
+ /// @return Number or paramenters
+ size_t (*StmtNumParams)(SqlStmt* self);
-/// Binds a parameter to a buffer.
-/// The buffer data will be used when the statement is executed.
-/// All parameters should have bindings.
-///
-/// @return SQL_SUCCESS or SQL_ERROR
-int SqlStmt_BindParam(SqlStmt* self, size_t idx, SqlDataType buffer_type, void* buffer, size_t buffer_len);
+ /// Binds a parameter to a buffer.
+ /// The buffer data will be used when the statement is executed.
+ /// All parameters should have bindings.
+ ///
+ /// @return SQL_SUCCESS or SQL_ERROR
+ int (*StmtBindParam)(SqlStmt* self, size_t idx, SqlDataType buffer_type, void* buffer, size_t buffer_len);
-/// Executes the prepared statement.
-/// Any previous result is freed and all column bindings are removed.
-///
-/// @return SQL_SUCCESS or SQL_ERROR
-int SqlStmt_Execute(SqlStmt* self);
+ /// Executes the prepared statement.
+ /// Any previous result is freed and all column bindings are removed.
+ ///
+ /// @return SQL_SUCCESS or SQL_ERROR
+ int (*StmtExecute)(SqlStmt* self);
-/// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE statement.
-///
-/// @return Value of the auto-increment column
-uint64 SqlStmt_LastInsertId(SqlStmt* self);
+ /// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE statement.
+ ///
+ /// @return Value of the auto-increment column
+ uint64 (*StmtLastInsertId)(SqlStmt* self);
-/// Returns the number of columns in each row of the result.
-///
-/// @return Number of columns
-size_t SqlStmt_NumColumns(SqlStmt* self);
+ /// Returns the number of columns in each row of the result.
+ ///
+ /// @return Number of columns
+ size_t (*StmtNumColumns)(SqlStmt* self);
+
+
+
+ /// Binds the result of a column to a buffer.
+ /// The buffer will be filled with data when the next row is fetched.
+ /// For string/enum buffer types there has to be enough space for the data
+ /// and the nul-terminator (an extra byte).
+ ///
+ /// @return SQL_SUCCESS or SQL_ERROR
+ int (*StmtBindColumn)(SqlStmt* self, size_t idx, SqlDataType buffer_type, void* buffer, size_t buffer_len, uint32* out_length, int8* out_is_null);
+
+
+
+ /// Returns the number of rows in the result.
+ ///
+ /// @return Number of rows
+ uint64 (*StmtNumRows)(SqlStmt* self);
-/// Binds the result of a column to a buffer.
-/// The buffer will be filled with data when the next row is fetched.
-/// For string/enum buffer types there has to be enough space for the data
-/// and the nul-terminator (an extra byte).
-///
-/// @return SQL_SUCCESS or SQL_ERROR
-int SqlStmt_BindColumn(SqlStmt* self, size_t idx, SqlDataType buffer_type, void* buffer, size_t buffer_len, uint32* out_length, int8* out_is_null);
+ /// Fetches the next row.
+ /// All column bindings will be filled with data.
+ ///
+ /// @return SQL_SUCCESS, SQL_ERROR or SQL_NO_DATA
+ int (*StmtNextRow)(SqlStmt* self);
-/// Returns the number of rows in the result.
-///
-/// @return Number of rows
-uint64 SqlStmt_NumRows(SqlStmt* self);
+ /// Frees the result of the statement execution.
+ void (*StmtFreeResult)(SqlStmt* self);
+ /// Frees a SqlStmt returned by SqlStmt_Malloc.
+ void (*StmtFree)(SqlStmt* self);
-/// Fetches the next row.
-/// All column bindings will be filled with data.
-///
-/// @return SQL_SUCCESS, SQL_ERROR or SQL_NO_DATA
-int SqlStmt_NextRow(SqlStmt* self);
+ void (*StmtShowDebug_)(SqlStmt* self, const char* debug_file, const unsigned long debug_line);
+} sql_s;
+
+struct sql_interface *SQL;
+void sql_defaults(void);
-/// Frees the result of the statement execution.
-void SqlStmt_FreeResult(SqlStmt* self);
+#if defined(SQL_REMOVE_SHOWDEBUG)
+#define Sql_ShowDebug(self) (void)0
+#else
+#define Sql_ShowDebug(self) SQL->ShowDebug_(self, __FILE__, __LINE__)
+#endif
void Sql_HerculesUpdateCheck(Sql* self);
#if defined(SQL_REMOVE_SHOWDEBUG)
- #define SqlStmt_ShowDebug(self) (void)0
+#define SqlStmt_ShowDebug(self) (void)0
#else
- #define SqlStmt_ShowDebug(self) SqlStmt_ShowDebug_(self, __FILE__, __LINE__)
+#define SqlStmt_ShowDebug(self) SQL->StmtShowDebug_(self, __FILE__, __LINE__)
#endif
/// Shows debug information (with statement).
-void SqlStmt_ShowDebug_(SqlStmt* self, const char* debug_file, const unsigned long debug_line);
-/// Frees a SqlStmt returned by SqlStmt_Malloc.
-void SqlStmt_Free(SqlStmt* self);
+
+
void Sql_Init(void);
diff --git a/src/common/strlib.h b/src/common/strlib.h
index 4a073c3bc..9b1875d45 100644
--- a/src/common/strlib.h
+++ b/src/common/strlib.h
@@ -8,9 +8,13 @@
#include "../common/cbasetypes.h"
#include <stdarg.h>
-#define __USE_GNU // required to enable strnlen on some platforms
-#include <string.h>
-#undef __USE_GNU
+#ifndef __USE_GNU
+ #define __USE_GNU // required to enable strnlen on some platforms
+ #include <string.h>
+ #undef __USE_GNU
+#else
+ #include <string.h>
+#endif
#ifdef WIN32
#define HAVE_STRTOK_R
diff --git a/src/common/timer.c b/src/common/timer.c
index edb46bd71..955a971c8 100644
--- a/src/common/timer.c
+++ b/src/common/timer.c
@@ -257,7 +257,7 @@ int timer_add_interval(unsigned int tick, TimerFunc func, int id, intptr_t data,
int tid;
if( interval < 1 ) {
- ShowError("timer_add_interval: invalid interval (tick=%u %p[%s] id=%d data=%d diff_tick=%d)\n", tick, func, search_timer_func_list(func), id, data, DIFF_TICK(tick, gettick()));
+ ShowError("timer_add_interval: invalid interval (tick=%u %p[%s] id=%d data=%d diff_tick=%d)\n", tick, func, search_timer_func_list(func), id, data, DIFF_TICK(tick, iTimer->gettick()));
return INVALID_TIMER;
}
@@ -300,7 +300,7 @@ int timer_do_delete(int tid, TimerFunc func) {
/// Adjusts a timer's expiration time.
/// Returns the new tick value, or -1 if it fails.
int timer_addtick(int tid, unsigned int tick) {
- return settick_timer(tid, timer_data[tid].tick+tick);
+ return iTimer->settick_timer(tid, timer_data[tid].tick+tick);
}
/// Modifies a timer's expiration time (an alternative to deleting a timer and starting a new one).
@@ -409,15 +409,26 @@ void timer_final(void) {
BHEAP_CLEAR(timer_heap);
if (free_timer_list) aFree(free_timer_list);
}
-void timer_defaults(void) {
- gettick = timer_gettick;
- gettick_nocache = timer_gettick_nocache;
- add_timer = timer_add;
- add_timer_interval = timer_add_interval;
- add_timer_func_list = timer_add_func_list;
- get_timer = timer_get;
- delete_timer = timer_do_delete;
- addtick_timer = timer_addtick;
- settick_timer = timer_settick;
- get_uptime = timer_get_uptime;
+/*=====================================
+* Default Functions : timer.h
+* Generated by HerculesInterfaceMaker
+* created by Susu
+*-------------------------------------*/
+void timer_defaults(void) {
+ iTimer = &iTimer_s;
+
+ /* funcs */
+ iTimer->gettick = timer_gettick;
+ iTimer->gettick_nocache = timer_gettick_nocache;
+ iTimer->add_timer = timer_add;
+ iTimer->add_timer_interval = timer_add_interval;
+ iTimer->add_timer_func_list = timer_add_func_list;
+ iTimer->get_timer = timer_get;
+ iTimer->delete_timer = timer_do_delete;
+ iTimer->addtick_timer = timer_addtick;
+ iTimer->settick_timer = timer_settick;
+ iTimer->get_uptime = timer_get_uptime;
+ iTimer->do_timer = do_timer;
+ iTimer->init = timer_init;
+ iTimer->final = timer_final;
}
diff --git a/src/common/timer.h b/src/common/timer.h
index 902679f51..50f1c354b 100644
--- a/src/common/timer.h
+++ b/src/common/timer.h
@@ -1,10 +1,8 @@
// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-
#ifndef _TIMER_H_
#define _TIMER_H_
-
#include "../common/cbasetypes.h"
#define DIFF_TICK(a,b) ((int)((a)-(b)))
@@ -34,27 +32,36 @@ struct TimerData {
intptr_t data;
};
-// Function prototype declaration
-int do_timer(unsigned int tick);
-void timer_init(void);
-void timer_final(void);
+/*=====================================
+* Interface : timer.h
+* Generated by HerculesInterfaceMaker
+* created by Susu
+*-------------------------------------*/
+struct timer_interface {
+
+ /* funcs */
+ unsigned int (*gettick) (void);
+ unsigned int (*gettick_nocache) (void);
+
+ int (*add_timer) (unsigned int tick, TimerFunc func, int id, intptr_t data);
+ int (*add_timer_interval) (unsigned int tick, TimerFunc func, int id, intptr_t data, int interval);
+ const struct TimerData *(*get_timer) (int tid);
+ int (*delete_timer) (int tid, TimerFunc func);
-/* Hercules Renewal Phase One */
-unsigned int (*gettick) (void);
-unsigned int (*gettick_nocache) (void);
+ int (*addtick_timer) (int tid, unsigned int tick);
+ int (*settick_timer) (int tid, unsigned int tick);
-int (*add_timer) (unsigned int tick, TimerFunc func, int id, intptr_t data);
-int (*add_timer_interval) (unsigned int tick, TimerFunc func, int id, intptr_t data, int interval);
-const struct TimerData *(*get_timer) (int tid);
-int (*delete_timer) (int tid, TimerFunc func);
+ int (*add_timer_func_list) (TimerFunc func, char* name);
-int (*addtick_timer) (int tid, unsigned int tick);
-int (*settick_timer) (int tid, unsigned int tick);
+ unsigned long (*get_uptime) (void);
-int (*add_timer_func_list) (TimerFunc func, char* name);
+ int (*do_timer) (unsigned int tick);
+ void (*init) (void);
+ void (*final) (void);
+} iTimer_s;
-unsigned long (*get_uptime) (void);
+struct timer_interface *iTimer;
void timer_defaults(void);
diff --git a/src/config/const.h b/src/config/const.h
index 53f24da6f..d8e397b1e 100644
--- a/src/config/const.h
+++ b/src/config/const.h
@@ -60,8 +60,8 @@
/* ATCMD_FUNC(mobinfo) HIT and FLEE calculations */
#ifdef RENEWAL
- #define MOB_FLEE(mob) ( mob->lv + mob->status.agi + mob->status.luk/5 + 100 )
- #define MOB_HIT(mob) ( mob->lv + mob->status.dex + mob->status.luk/3 + 175 )
+ #define MOB_FLEE(mob) ( mob->lv + mob->status.agi + 100 )
+ #define MOB_HIT(mob) ( mob->lv + mob->status.dex + 150 )
#else
#define MOB_FLEE(mob) ( mob->lv + mob->status.agi )
#define MOB_HIT(mob) ( mob->lv + mob->status.dex )
@@ -106,6 +106,13 @@
#undef CONSOLE_INPUT
#endif
+#ifdef RENEWAL
+ #define ITEMDB_SQL_COLUMNS 24
+#else
+ #define ITEMDB_SQL_COLUMNS 22
+#endif
+
+
/**
* End of File
**/
diff --git a/src/login/account_sql.c b/src/login/account_sql.c
index d3a7aafff..14dd8ad9d 100644
--- a/src/login/account_sql.c
+++ b/src/login/account_sql.c
@@ -583,7 +583,7 @@ static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int acc
static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, bool is_new)
{
Sql* sql_handle = db->accounts;
- SqlStmt* stmt = SqlStmt_Malloc(sql_handle);
+ SqlStmt* stmt = SQL->StmtMalloc(sql_handle);
bool result = false;
int i;
@@ -599,48 +599,48 @@ static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, boo
if( is_new )
{// insert into account table
- if( SQL_SUCCESS != SqlStmt_Prepare(stmt,
+ if( SQL_SUCCESS != SQL->StmtPrepare(stmt,
"INSERT INTO `%s` (`account_id`, `userid`, `user_pass`, `sex`, `email`, `group_id`, `state`, `unban_time`, `expiration_time`, `logincount`, `lastlogin`, `last_ip`, `birthdate`, `character_slots`, `pincode`, `pincode_change`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
db->account_db)
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_INT, (void*)&acc->account_id, sizeof(acc->account_id))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (void*)acc->userid, strlen(acc->userid))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_STRING, (void*)acc->pass, strlen(acc->pass))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 3, SQLDT_ENUM, (void*)&acc->sex, sizeof(acc->sex))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 4, SQLDT_STRING, (void*)&acc->email, strlen(acc->email))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 5, SQLDT_INT, (void*)&acc->group_id, sizeof(acc->group_id))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 6, SQLDT_UINT, (void*)&acc->state, sizeof(acc->state))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 7, SQLDT_LONG, (void*)&acc->unban_time, sizeof(acc->unban_time))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 8, SQLDT_INT, (void*)&acc->expiration_time, sizeof(acc->expiration_time))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 9, SQLDT_UINT, (void*)&acc->logincount, sizeof(acc->logincount))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 10, SQLDT_STRING, (void*)&acc->lastlogin, strlen(acc->lastlogin))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 11, SQLDT_STRING, (void*)&acc->last_ip, strlen(acc->last_ip))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 12, SQLDT_STRING, (void*)&acc->birthdate, strlen(acc->birthdate))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 13, SQLDT_UCHAR, (void*)&acc->char_slots, sizeof(acc->char_slots))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 14, SQLDT_STRING, (void*)&acc->pincode, strlen(acc->pincode))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 15, SQLDT_LONG, (void*)&acc->pincode_change, sizeof(acc->pincode_change))
- || SQL_SUCCESS != SqlStmt_Execute(stmt)
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_INT, (void*)&acc->account_id, sizeof(acc->account_id))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (void*)acc->userid, strlen(acc->userid))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 2, SQLDT_STRING, (void*)acc->pass, strlen(acc->pass))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 3, SQLDT_ENUM, (void*)&acc->sex, sizeof(acc->sex))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 4, SQLDT_STRING, (void*)&acc->email, strlen(acc->email))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 5, SQLDT_INT, (void*)&acc->group_id, sizeof(acc->group_id))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 6, SQLDT_UINT, (void*)&acc->state, sizeof(acc->state))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 7, SQLDT_LONG, (void*)&acc->unban_time, sizeof(acc->unban_time))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 8, SQLDT_INT, (void*)&acc->expiration_time, sizeof(acc->expiration_time))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 9, SQLDT_UINT, (void*)&acc->logincount, sizeof(acc->logincount))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 10, SQLDT_STRING, (void*)&acc->lastlogin, strlen(acc->lastlogin))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 11, SQLDT_STRING, (void*)&acc->last_ip, strlen(acc->last_ip))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 12, SQLDT_STRING, (void*)&acc->birthdate, strlen(acc->birthdate))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 13, SQLDT_UCHAR, (void*)&acc->char_slots, sizeof(acc->char_slots))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 14, SQLDT_STRING, (void*)&acc->pincode, strlen(acc->pincode))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 15, SQLDT_LONG, (void*)&acc->pincode_change, sizeof(acc->pincode_change))
+ || SQL_SUCCESS != SQL->StmtExecute(stmt)
) {
SqlStmt_ShowDebug(stmt);
break;
}
} else {// update account table
- if( SQL_SUCCESS != SqlStmt_Prepare(stmt, "UPDATE `%s` SET `userid`=?,`user_pass`=?,`sex`=?,`email`=?,`group_id`=?,`state`=?,`unban_time`=?,`expiration_time`=?,`logincount`=?,`lastlogin`=?,`last_ip`=?,`birthdate`=?,`character_slots`=?,`pincode`=?,`pincode_change`=? WHERE `account_id` = '%d'", db->account_db, acc->account_id)
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, (void*)acc->userid, strlen(acc->userid))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (void*)acc->pass, strlen(acc->pass))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_ENUM, (void*)&acc->sex, sizeof(acc->sex))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 3, SQLDT_STRING, (void*)acc->email, strlen(acc->email))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 4, SQLDT_INT, (void*)&acc->group_id, sizeof(acc->group_id))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 5, SQLDT_UINT, (void*)&acc->state, sizeof(acc->state))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 6, SQLDT_LONG, (void*)&acc->unban_time, sizeof(acc->unban_time))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 7, SQLDT_LONG, (void*)&acc->expiration_time, sizeof(acc->expiration_time))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 8, SQLDT_UINT, (void*)&acc->logincount, sizeof(acc->logincount))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 9, SQLDT_STRING, (void*)&acc->lastlogin, strlen(acc->lastlogin))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 10, SQLDT_STRING, (void*)&acc->last_ip, strlen(acc->last_ip))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 11, SQLDT_STRING, (void*)&acc->birthdate, strlen(acc->birthdate))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 12, SQLDT_UCHAR, (void*)&acc->char_slots, sizeof(acc->char_slots))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 13, SQLDT_STRING, (void*)&acc->pincode, strlen(acc->pincode))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 14, SQLDT_LONG, (void*)&acc->pincode_change, sizeof(acc->pincode_change))
- || SQL_SUCCESS != SqlStmt_Execute(stmt)
+ if( SQL_SUCCESS != SQL->StmtPrepare(stmt, "UPDATE `%s` SET `userid`=?,`user_pass`=?,`sex`=?,`email`=?,`group_id`=?,`state`=?,`unban_time`=?,`expiration_time`=?,`logincount`=?,`lastlogin`=?,`last_ip`=?,`birthdate`=?,`character_slots`=?,`pincode`=?,`pincode_change`=? WHERE `account_id` = '%d'", db->account_db, acc->account_id)
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, (void*)acc->userid, strlen(acc->userid))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (void*)acc->pass, strlen(acc->pass))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 2, SQLDT_ENUM, (void*)&acc->sex, sizeof(acc->sex))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 3, SQLDT_STRING, (void*)acc->email, strlen(acc->email))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 4, SQLDT_INT, (void*)&acc->group_id, sizeof(acc->group_id))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 5, SQLDT_UINT, (void*)&acc->state, sizeof(acc->state))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 6, SQLDT_LONG, (void*)&acc->unban_time, sizeof(acc->unban_time))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 7, SQLDT_LONG, (void*)&acc->expiration_time, sizeof(acc->expiration_time))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 8, SQLDT_UINT, (void*)&acc->logincount, sizeof(acc->logincount))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 9, SQLDT_STRING, (void*)&acc->lastlogin, strlen(acc->lastlogin))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 10, SQLDT_STRING, (void*)&acc->last_ip, strlen(acc->last_ip))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 11, SQLDT_STRING, (void*)&acc->birthdate, strlen(acc->birthdate))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 12, SQLDT_UCHAR, (void*)&acc->char_slots, sizeof(acc->char_slots))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 13, SQLDT_STRING, (void*)&acc->pincode, strlen(acc->pincode))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 14, SQLDT_LONG, (void*)&acc->pincode_change, sizeof(acc->pincode_change))
+ || SQL_SUCCESS != SQL->StmtExecute(stmt)
) {
SqlStmt_ShowDebug(stmt);
break;
@@ -654,16 +654,16 @@ static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, boo
break;
}
// insert new account regs
- if( SQL_SUCCESS != SqlStmt_Prepare(stmt, "INSERT INTO `%s` (`type`, `account_id`, `str`, `value`) VALUES ( 1 , '%d' , ? , ? );", db->accreg_db, acc->account_id) )
+ if( SQL_SUCCESS != SQL->StmtPrepare(stmt, "INSERT INTO `%s` (`type`, `account_id`, `str`, `value`) VALUES ( 1 , '%d' , ? , ? );", db->accreg_db, acc->account_id) )
{
SqlStmt_ShowDebug(stmt);
break;
}
for( i = 0; i < acc->account_reg2_num; ++i )
{
- if( SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, (void*)acc->account_reg2[i].str, strlen(acc->account_reg2[i].str))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (void*)acc->account_reg2[i].value, strlen(acc->account_reg2[i].value))
- || SQL_SUCCESS != SqlStmt_Execute(stmt)
+ if( SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, (void*)acc->account_reg2[i].str, strlen(acc->account_reg2[i].str))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (void*)acc->account_reg2[i].value, strlen(acc->account_reg2[i].value))
+ || SQL_SUCCESS != SQL->StmtExecute(stmt)
) {
SqlStmt_ShowDebug(stmt);
break;
@@ -682,7 +682,7 @@ static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, boo
// finally
result &= ( SQL_SUCCESS == SQL->QueryStr(sql_handle, (result == true) ? "COMMIT" : "ROLLBACK") );
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
return result;
}
diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c
index 701d3bc1d..fd9f1a4a1 100644
--- a/src/login/ipban_sql.c
+++ b/src/login/ipban_sql.c
@@ -86,8 +86,8 @@ void ipban_init(void)
if( login_config.ipban_cleanup_interval > 0 )
{ // set up periodic cleanup of connection history and active bans
- add_timer_func_list(ipban_cleanup, "ipban_cleanup");
- cleanup_timer_id = add_timer_interval(gettick()+10, ipban_cleanup, 0, 0, login_config.ipban_cleanup_interval*1000);
+ iTimer->add_timer_func_list(ipban_cleanup, "ipban_cleanup");
+ cleanup_timer_id = iTimer->add_timer_interval(iTimer->gettick()+10, ipban_cleanup, 0, 0, login_config.ipban_cleanup_interval*1000);
} else // make sure it gets cleaned up on login-server start regardless of interval-based cleanups
ipban_cleanup(0,0,0,0);
}
@@ -100,7 +100,7 @@ void ipban_final(void)
if( login_config.ipban_cleanup_interval > 0 )
// release data
- delete_timer(cleanup_timer_id, ipban_cleanup);
+ iTimer->delete_timer(cleanup_timer_id, ipban_cleanup);
ipban_cleanup(0,0,0,0); // always clean up on login-server stop
diff --git a/src/login/login.c b/src/login/login.c
index 2bfb9c730..e8f136ba9 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -119,7 +119,7 @@ struct online_login_data* add_online_user(int char_server, int account_id)
p->char_server = char_server;
if( p->waiting_disconnect != INVALID_TIMER )
{
- delete_timer(p->waiting_disconnect, waiting_disconnect_timer);
+ iTimer->delete_timer(p->waiting_disconnect, waiting_disconnect_timer);
p->waiting_disconnect = INVALID_TIMER;
}
return p;
@@ -132,7 +132,7 @@ void remove_online_user(int account_id)
if( p == NULL )
return;
if( p->waiting_disconnect != INVALID_TIMER )
- delete_timer(p->waiting_disconnect, waiting_disconnect_timer);
+ iTimer->delete_timer(p->waiting_disconnect, waiting_disconnect_timer);
idb_remove(online_db, account_id);
}
@@ -161,7 +161,7 @@ static int online_db_setoffline(DBKey key, DBData *data, va_list ap)
p->char_server = -1;
if( p->waiting_disconnect != INVALID_TIMER )
{
- delete_timer(p->waiting_disconnect, waiting_disconnect_timer);
+ iTimer->delete_timer(p->waiting_disconnect, waiting_disconnect_timer);
p->waiting_disconnect = INVALID_TIMER;
}
}
@@ -804,7 +804,7 @@ int parse_fromchar(int fd)
p->char_server = id;
if (p->waiting_disconnect != INVALID_TIMER)
{
- delete_timer(p->waiting_disconnect, waiting_disconnect_timer);
+ iTimer->delete_timer(p->waiting_disconnect, waiting_disconnect_timer);
p->waiting_disconnect = INVALID_TIMER;
}
}
@@ -913,12 +913,12 @@ int parse_fromchar(int fd)
int mmo_auth_new(const char* userid, const char* pass, const char sex, const char* last_ip) {
static int num_regs = 0; // registration counter
static unsigned int new_reg_tick = 0;
- unsigned int tick = gettick();
+ unsigned int tick = iTimer->gettick();
struct mmo_account acc;
//Account Registration Flood Protection by [Kevin]
if( new_reg_tick == 0 )
- new_reg_tick = gettick();
+ new_reg_tick = iTimer->gettick();
if( DIFF_TICK(tick, new_reg_tick) < 0 && num_regs >= allowed_regs ) {
ShowNotice("Account registration denied (registration limit exceeded)\n");
return 3;
@@ -1162,7 +1162,7 @@ void login_auth_ok(struct login_session_data* sd)
WBUFL(buf,2) = sd->account_id;
charif_sendallwos(-1, buf, 6);
if( data->waiting_disconnect == INVALID_TIMER )
- data->waiting_disconnect = add_timer(gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0);
+ data->waiting_disconnect = iTimer->add_timer(iTimer->gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0);
WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x81;
@@ -1229,7 +1229,7 @@ void login_auth_ok(struct login_session_data* sd)
data = add_online_user(-1, sd->account_id);
// schedule deletion of this node
- data->waiting_disconnect = add_timer(gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0);
+ data->waiting_disconnect = iTimer->add_timer(iTimer->gettick()+AUTH_TIMEOUT, waiting_disconnect_timer, sd->account_id, 0);
}
}
@@ -1836,7 +1836,7 @@ int do_init(int argc, char** argv)
// Online user database init
online_db = idb_alloc(DB_OPT_RELEASE_DATA);
- add_timer_func_list(waiting_disconnect_timer, "waiting_disconnect_timer");
+ iTimer->add_timer_func_list(waiting_disconnect_timer, "waiting_disconnect_timer");
// Interserver auth init
auth_db = idb_alloc(DB_OPT_RELEASE_DATA);
@@ -1845,13 +1845,13 @@ int do_init(int argc, char** argv)
set_defaultparse(parse_login);
// every 10 minutes cleanup online account db.
- add_timer_func_list(online_data_cleanup, "online_data_cleanup");
- add_timer_interval(gettick() + 600*1000, online_data_cleanup, 0, 0, 600*1000);
+ iTimer->add_timer_func_list(online_data_cleanup, "online_data_cleanup");
+ iTimer->add_timer_interval(iTimer->gettick() + 600*1000, online_data_cleanup, 0, 0, 600*1000);
// add timer to detect ip address change and perform update
if (login_config.ip_sync_interval) {
- add_timer_func_list(sync_ip_addresses, "sync_ip_addresses");
- add_timer_interval(gettick() + login_config.ip_sync_interval, sync_ip_addresses, 0, 0, login_config.ip_sync_interval);
+ iTimer->add_timer_func_list(sync_ip_addresses, "sync_ip_addresses");
+ iTimer->add_timer_interval(iTimer->gettick() + login_config.ip_sync_interval, sync_ip_addresses, 0, 0, login_config.ip_sync_interval);
}
// Account database init
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 65da7aa24..a1bc52924 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -403,17 +403,17 @@ ACMD(mapmove)
mapindex = mapindex_name2id(map_name);
if (mapindex)
- m = map_mapindex2mapid(mapindex);
+ m = iMap->mapindex2mapid(mapindex);
if (!mapindex) { // m < 0 means on different server! [Kevin]
clif->message(fd, msg_txt(1)); // Map not found.
return false;
}
- if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS) && pc_get_group_level(sd) < battle_config.gm_ignore_warpable_area)
- { //This is to prevent the pc_setpos call from printing an error.
+ if ((x || y) && iMap->getcell(m, x, y, CELL_CHKNOPASS) && pc->get_group_level(sd) < battle_config.gm_ignore_warpable_area)
+ { //This is to prevent the pc->setpos call from printing an error.
clif->message(fd, msg_txt(2));
- if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
+ if (!iMap->search_freecell(NULL, m, &x, &y, 10, 10, 1))
x = y = 0; //Invalid cell, use random spot.
}
if (map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
@@ -424,7 +424,7 @@ ACMD(mapmove)
clif->message(fd, msg_txt(248));
return false;
}
- if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
+ if (pc->setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
clif->message(fd, msg_txt(1)); // Map not found.
return false;
}
@@ -448,10 +448,10 @@ ACMD(where)
return false;
}
- pl_sd = map_nick2sd(atcmd_player_name);
+ pl_sd = iMap->nick2sd(atcmd_player_name);
if (pl_sd == NULL ||
strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
- (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc_get_group_level(pl_sd) > pc_get_group_level(sd) && !pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
+ (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc->get_group_level(pl_sd) > pc->get_group_level(sd) && !pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
) {
clif->message(fd, msg_txt(3)); // Character not found.
return false;
@@ -477,7 +477,7 @@ ACMD(jumpto)
return false;
}
- if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
+ if((pl_sd=iMap->nick2sd((char *)message)) == NULL && (pl_sd=iMap->charid2sd(atoi(message))) == NULL)
{
clif->message(fd, msg_txt(3)); // Character not found.
return false;
@@ -501,7 +501,7 @@ ACMD(jumpto)
return false;
}
- pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
+ pc->setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
clif->message(fd, atcmd_output);
@@ -532,14 +532,14 @@ ACMD(jump)
return false;
}
- if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
- { //This is to prevent the pc_setpos call from printing an error.
+ if ((x || y) && iMap->getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
+ { //This is to prevent the pc->setpos call from printing an error.
clif->message(fd, msg_txt(2));
- if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
+ if (!iMap->search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
x = y = 0; //Invalid cell, use random spot.
}
- pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
+ pc->setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
clif->message(fd, atcmd_output);
return true;
@@ -569,7 +569,7 @@ ACMD(who)
nullpo_retr(-1, sd);
if (strstr(command, "map") != NULL) {
- if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
+ if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = iMap->mapname2mapid(map_name)) < 0)
map_id = sd->bl.m;
} else {
sscanf(message, "%23s", player_name);
@@ -580,12 +580,12 @@ ACMD(who)
else if (strstr(command, "3") != NULL)
display_type = 3;
- level = pc_get_group_level(sd);
+ level = pc->get_group_level(sd);
StrBuf->Init(&buf);
iter = mapit_getallusers();
for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) {
- if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || (pl_sd->sc.option & OPTION_INVISIBLE)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level
+ if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || (pl_sd->sc.option & OPTION_INVISIBLE)) && pc->get_group_level(pl_sd) > level)) { // you can look only lower or same level
if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
|| (map_id >= 0 && pl_sd->bl.m != map_id))
continue;
@@ -595,7 +595,7 @@ ACMD(who)
if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
StrBuf->Printf(&buf, msg_txt(344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
StrBuf->Printf(&buf, msg_txt(347), pl_sd->status.base_level, pl_sd->status.job_level,
- job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
+ pc->job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
break;
}
case 3: {
@@ -608,7 +608,7 @@ ACMD(who)
break;
}
default: {
- struct party_data *p = party_search(pl_sd->status.party_id);
+ struct party_data *p = party->search(pl_sd->status.party_id);
struct guild *g = pl_sd->guild;
StrBuf->Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s "
@@ -674,12 +674,12 @@ ACMD(whogm)
match_text[j] = TOLOWER(match_text[j]);
count = 0;
- level = pc_get_group_level(sd);
+ level = pc->get_group_level(sd);
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
{
- pl_level = pc_get_group_level(pl_sd);
+ pl_level = pc->get_group_level(pl_sd);
if (!pl_level)
continue;
@@ -708,10 +708,10 @@ ACMD(whogm)
sprintf(atcmd_output, msg_txt(915), // BLvl: %d | Job: %s (Lvl: %d)
pl_sd->status.base_level,
- job_name(pl_sd->status.class_), pl_sd->status.job_level);
+ pc->job_name(pl_sd->status.class_), pl_sd->status.job_level);
clif->message(fd, atcmd_output);
- p = party_search(pl_sd->status.party_id);
+ p = party->search(pl_sd->status.party_id);
g = pl_sd->guild;
sprintf(atcmd_output,msg_txt(916), // Party: '%s' | Guild: '%s'
@@ -741,7 +741,7 @@ ACMD(save)
{
nullpo_retr(-1, sd);
- pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
+ pc->setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
if (sd->status.pet_id > 0 && sd->pd)
intif_save_petdata(sd->status.account_id, &sd->pd->pet);
@@ -761,7 +761,7 @@ ACMD(load)
nullpo_retr(-1, sd);
- m = map_mapindex2mapid(sd->status.save_point.map);
+ m = iMap->mapindex2mapid(sd->status.save_point.map);
if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(249)); // You are not authorized to warp to your save map.
return false;
@@ -771,7 +771,7 @@ ACMD(load)
return false;
}
- pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
+ pc->setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
clif->message(fd, msg_txt(7)); // Warping to save point..
return true;
@@ -816,8 +816,7 @@ ACMD(storage)
if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
return false;
- if (storage_storageopen(sd) == 1)
- { //Already open.
+ if (storage->open(sd) == 1) { //Already open.
clif->message(fd, msg_txt(250));
return false;
}
@@ -853,7 +852,7 @@ ACMD(guildstorage)
return false;
}
- storage_guild_storageopen(sd);
+ gstorage->open(sd);
clif->message(fd, msg_txt(920)); // Guild storage opened.
return true;
}
@@ -885,7 +884,7 @@ ACMD(option)
sd->sc.opt1 = param1;
sd->sc.opt2 = param2;
- pc_setoption(sd, param3);
+ pc->setoption(sd, param3);
clif->message(fd, msg_txt(9)); // Options changed.
@@ -911,10 +910,10 @@ ACMD(hide)
if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
{// register the player for ranking calculations
- sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
+ sd->pvp_timer = iTimer->add_timer( iTimer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0 );
}
//bugreport:2266
- map_foreachinmovearea(clif->insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
+ iMap->foreachinmovearea(clif->insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
} else {
sd->sc.option |= OPTION_INVISIBLE;
sd->vd.class_ = INVISIBLE_CLASS;
@@ -925,7 +924,7 @@ ACMD(hide)
if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
{// unregister the player for ranking
- delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
+ iTimer->delete_timer( sd->pvp_timer, pc->calc_pvprank_timer );
sd->pvp_timer = INVALID_TIMER;
}
}
@@ -951,7 +950,7 @@ ACMD(jobchange)
// Normal Jobs
for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ){
- if (strncmpi(message, job_name(i), 16) == 0) {
+ if (strncmpi(message, pc->job_name(i), 16) == 0) {
job = i;
found = true;
}
@@ -959,7 +958,7 @@ ACMD(jobchange)
// High Jobs, Babys and Third
for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ){
- if (strncmpi(message, job_name(i), 16) == 0) {
+ if (strncmpi(message, pc->job_name(i), 16) == 0) {
job = i;
found = true;
}
@@ -982,7 +981,7 @@ ACMD(jobchange)
if (pcdb_checkid(job))
{
- if (pc_jobchange(sd, job, upper) == 0)
+ if (pc->jobchange(sd, job, upper) == 0)
clif->message(fd, msg_txt(12)); // Your job has been changed.
else {
clif->message(fd, msg_txt(155)); // You are unable to change your job.
@@ -1095,7 +1094,7 @@ ACMD(heal)
if ( hp < 0 && sp <= 0 ) {
status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
- clif->damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
+ clif->damage(&sd->bl,&sd->bl, iTimer->gettick(), 0, 0, -hp, 0, 4, 0);
clif->message(fd, msg_txt(156)); // HP or/and SP modified.
return true;
}
@@ -1106,7 +1105,7 @@ ACMD(heal)
status_heal(&sd->bl, hp, 0, 0);
else {
status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
- clif->damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
+ clif->damage(&sd->bl,&sd->bl, iTimer->gettick(), 0, 0, -hp, 0, 4, 0);
}
}
@@ -1146,8 +1145,8 @@ ACMD(item)
if (number <= 0)
number = 1;
- if ((item_data = itemdb_searchname(item_name)) == NULL &&
- (item_data = itemdb_exists(atoi(item_name))) == NULL)
+ if ((item_data = itemdb->search_name(item_name)) == NULL &&
+ (item_data = itemdb->exists(atoi(item_name))) == NULL)
{
clif->message(fd, msg_txt(19)); // Invalid item ID or name.
return false;
@@ -1166,7 +1165,7 @@ ACMD(item)
item_tmp.nameid = item_id;
item_tmp.identify = 1;
- if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
+ if ((flag = pc->additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
clif->additem(sd, 0, 0, flag);
}
}
@@ -1204,8 +1203,8 @@ ACMD(item2)
number = 1;
item_id = 0;
- if ((item_data = itemdb_searchname(item_name)) != NULL ||
- (item_data = itemdb_exists(atoi(item_name))) != NULL)
+ if ((item_data = itemdb->search_name(item_name)) != NULL ||
+ (item_data = itemdb->exists(atoi(item_name))) != NULL)
item_id = item_data->nameid;
if (item_id > 500) {
@@ -1239,7 +1238,7 @@ ACMD(item2)
item_tmp.card[1] = c2;
item_tmp.card[2] = c3;
item_tmp.card[3] = c4;
- if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
+ if ((flag = pc->additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
clif->additem(sd, 0, 0, flag);
}
@@ -1263,7 +1262,7 @@ ACMD(itemreset)
for (i = 0; i < MAX_INVENTORY; i++) {
if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
- pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
+ pc->delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
}
}
clif->message(fd, msg_txt(20)); // All of your items have been removed.
@@ -1286,14 +1285,14 @@ ACMD(baselevelup)
}
if (level > 0) {
- if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
+ if (sd->status.base_level >= pc->maxbaselv(sd)) { // check for max level by Valaris
clif->message(fd, msg_txt(47)); // Base level can't go any higher.
return false;
} // End Addition
- if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
- level = pc_maxbaselv(sd) - sd->status.base_level;
+ if ((unsigned int)level > pc->maxbaselv(sd) || (unsigned int)level > pc->maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
+ level = pc->maxbaselv(sd) - sd->status.base_level;
for (i = 0; i < level; i++)
- status_point += pc_gets_status_point(sd->status.base_level + i);
+ status_point += pc->gets_status_point(sd->status.base_level + i);
sd->status.status_point += status_point;
sd->status.base_level += (unsigned int)level;
@@ -1309,9 +1308,9 @@ ACMD(baselevelup)
if ((unsigned int)level >= sd->status.base_level)
level = sd->status.base_level-1;
for (i = 0; i > -level; i--)
- status_point += pc_gets_status_point(sd->status.base_level + i - 1);
+ status_point += pc->gets_status_point(sd->status.base_level + i - 1);
if (sd->status.status_point < status_point)
- pc_resetstate(sd);
+ pc->resetstate(sd);
if (sd->status.status_point < status_point)
sd->status.status_point = 0;
else
@@ -1325,9 +1324,9 @@ ACMD(baselevelup)
clif->updatestatus(sd, SP_BASEEXP);
clif->updatestatus(sd, SP_NEXTBASEEXP);
status_calc_pc(sd, 0);
- pc_baselevelchanged(sd);
+ pc->baselevelchanged(sd);
if(sd->status.party_id)
- party_send_levelup(sd);
+ party->send_levelup(sd);
return true;
}
@@ -1346,12 +1345,12 @@ ACMD(joblevelup)
return false;
}
if (level > 0) {
- if (sd->status.job_level >= pc_maxjoblv(sd)) {
+ if (sd->status.job_level >= pc->maxjoblv(sd)) {
clif->message(fd, msg_txt(23)); // Job level can't go any higher.
return false;
}
- if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
- level = pc_maxjoblv(sd) - sd->status.job_level;
+ if ((unsigned int)level > pc->maxjoblv(sd) || (unsigned int)level > pc->maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
+ level = pc->maxjoblv(sd) - sd->status.job_level;
sd->status.job_level += (unsigned int)level;
sd->status.skill_point += level;
clif->misceffect(&sd->bl, 1);
@@ -1366,7 +1365,7 @@ ACMD(joblevelup)
level = sd->status.job_level-1;
sd->status.job_level -= (unsigned int)level;
if (sd->status.skill_point < level)
- pc_resetskill(sd,0); //Reset skills since we need to substract more points.
+ pc->resetskill(sd,0); //Reset skills since we need to substract more points.
if (sd->status.skill_point < level)
sd->status.skill_point = 0;
else
@@ -1469,7 +1468,7 @@ static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
TBL_PC* sd = (TBL_PC*)bl;
clif->pvpset(sd, 0, 0, 2);
if (sd->pvp_timer != INVALID_TIMER) {
- delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
+ iTimer->delete_timer(sd->pvp_timer, pc->calc_pvprank_timer);
sd->pvp_timer = INVALID_TIMER;
}
return 0;
@@ -1484,15 +1483,15 @@ ACMD(pvpoff)
return false;
}
- map_zone_change2(sd->bl.m,map[sd->bl.m].prev_zone);
+ iMap->zone_change2(sd->bl.m,map[sd->bl.m].prev_zone);
map[sd->bl.m].flag.pvp = 0;
if (!battle_config.pk_mode) {
clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP);
}
- map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
- map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
+ iMap->foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
+ iMap->foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
clif->message(fd, msg_txt(31)); // PvP: Off.
return true;
}
@@ -1504,7 +1503,7 @@ static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
{
TBL_PC* sd = (TBL_PC*)bl;
if (sd->pvp_timer == INVALID_TIMER) {
- sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
+ sd->pvp_timer = iTimer->add_timer(iTimer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0);
sd->pvp_rank = 0;
sd->pvp_lastusers = 0;
sd->pvp_point = 5;
@@ -1523,13 +1522,13 @@ ACMD(pvpon)
return false;
}
- map_zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME));
+ iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME));
map[sd->bl.m].flag.pvp = 1;
if (!battle_config.pk_mode) {// display pvp circle and rank
clif->map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP);
- map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
+ iMap->foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
}
clif->message(fd, msg_txt(32)); // PvP: On.
@@ -1549,11 +1548,11 @@ ACMD(gvgoff)
return false;
}
- map_zone_change2(sd->bl.m,map[sd->bl.m].prev_zone);
+ iMap->zone_change2(sd->bl.m,map[sd->bl.m].prev_zone);
map[sd->bl.m].flag.gvg = 0;
clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP);
- map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
+ iMap->foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
clif->message(fd, msg_txt(33)); // GvG: Off.
return true;
@@ -1571,7 +1570,7 @@ ACMD(gvgon)
return false;
}
- map_zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME));
+ iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME));
map[sd->bl.m].flag.gvg = 1;
clif->map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP);
@@ -1600,9 +1599,9 @@ ACMD(model)
if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
- pc_changelook(sd, LOOK_HAIR, hair_style);
- pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
- pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
+ pc->changelook(sd, LOOK_HAIR, hair_style);
+ pc->changelook(sd, LOOK_HAIR_COLOR, hair_color);
+ pc->changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
clif->message(fd, msg_txt(36)); // Appearence changed.
} else {
clif->message(fd, msg_txt(37)); // An invalid number was specified.
@@ -1629,7 +1628,7 @@ ACMD(dye)
}
if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
- pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
+ pc->changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
clif->message(fd, msg_txt(36)); // Appearence changed.
} else {
clif->message(fd, msg_txt(37)); // An invalid number was specified.
@@ -1656,7 +1655,7 @@ ACMD(hair_style)
}
if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
- pc_changelook(sd, LOOK_HAIR, hair_style);
+ pc->changelook(sd, LOOK_HAIR, hair_style);
clif->message(fd, msg_txt(36)); // Appearence changed.
} else {
clif->message(fd, msg_txt(37)); // An invalid number was specified.
@@ -1683,7 +1682,7 @@ ACMD(hair_color)
}
if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
- pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
+ pc->changelook(sd, LOOK_HAIR_COLOR, hair_color);
clif->message(fd, msg_txt(36)); // Appearence changed.
} else {
clif->message(fd, msg_txt(37)); // An invalid number was specified.
@@ -1864,7 +1863,7 @@ ACMD(go)
if (town >= 0 && town < ARRAYLENGTH(data))
{
- m = map_mapname2mapid(data[town].map);
+ m = iMap->mapname2mapid(data[town].map);
if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
clif->message(fd, msg_txt(247));
return false;
@@ -1873,7 +1872,7 @@ ACMD(go)
clif->message(fd, msg_txt(248));
return false;
}
- if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
+ if (pc->setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
clif->message(fd, msg_txt(0)); // Warped.
} else {
clif->message(fd, msg_txt(1)); // Map not found.
@@ -1964,7 +1963,7 @@ ACMD(monster)
count = 0;
range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
for (i = 0; i < number; i++) {
- map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
+ iMap->search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
count += (k != 0) ? 1 : 0;
}
@@ -2016,13 +2015,13 @@ ACMD(killmonster)
if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
map_id = sd->bl.m;
else {
- if ((map_id = map_mapname2mapid(map_name)) < 0)
+ if ((map_id = iMap->mapname2mapid(map_name)) < 0)
map_id = sd->bl.m;
}
drop_flag = strcmp(command+1, "killmonster2");
- map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
+ iMap->foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
clif->message(fd, msg_txt(165)); // All monsters killed!
@@ -2085,11 +2084,11 @@ ACMD(refine)
if (sd->status.inventory[i].refine != final_refine) {
sd->status.inventory[i].refine = final_refine;
current_position = sd->status.inventory[i].equip;
- pc_unequipitem(sd, i, 3);
+ pc->unequipitem(sd, i, 3);
clif->refine(fd, 0, i, sd->status.inventory[i].refine);
clif->delitem(sd, i, 1, 3);
clif->additem(sd, i, 1, 0);
- pc_equipitem(sd, i, current_position);
+ pc->equipitem(sd, i, current_position);
clif->misceffect(&sd->bl, 3);
count++;
}
@@ -2129,8 +2128,8 @@ ACMD(produce)
return false;
}
- if ( (item_data = itemdb_searchname(item_name)) == NULL &&
- (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
+ if ( (item_data = itemdb->search_name(item_name)) == NULL &&
+ (item_data = itemdb->exists(atoi(item_name))) == NULL ) {
clif->message(fd, msg_txt(170)); //This item is not an equipment.
return false;
}
@@ -2155,7 +2154,7 @@ ACMD(produce)
clif->produce_effect(sd, 0, item_id);
clif->misceffect(&sd->bl, 3);
- if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
+ if ((flag = pc->additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
clif->additem(sd, 0, 0, flag);
} else {
sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
@@ -2198,7 +2197,7 @@ ACMD(memo)
return false;
}
- pc_memo(sd, position);
+ pc->memo(sd, position);
return true;
}
@@ -2215,11 +2214,11 @@ ACMD(gat)
for (y = 2; y >= -2; y--) {
sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
- map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
- map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
- map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
- map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
- map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
+ iMap->getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
+ iMap->getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
+ iMap->getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
+ iMap->getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
+ iMap->getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
clif->message(fd, atcmd_output);
}
@@ -2361,12 +2360,12 @@ ACMD(zeny)
}
if(zeny > 0){
- if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
+ if((ret=pc->getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
clif->message(fd, msg_txt(149)); // Unable to increase the number/value.
}
else {
if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
- if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
+ if((ret=pc->payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
clif->message(fd, msg_txt(41)); // Unable to decrease the number/value.
}
if(!ret) clif->message(fd, msg_txt(176)); //ret=0 mean cmd success
@@ -2549,7 +2548,7 @@ ACMD(makeegg)
return false;
}
- if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
+ if ((item_data = itemdb->search_name(message)) != NULL) // for egg name
id = item_data->nameid;
else
if ((id = mobdb_searchname(message)) != 0) // for monster name
@@ -2701,13 +2700,13 @@ ACMD(recall) {
return false;
}
- if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
+ if((pl_sd=iMap->nick2sd((char *)message)) == NULL && (pl_sd=iMap->charid2sd(atoi(message))) == NULL)
{
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
- if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
+ if ( pc->get_group_level(sd) < pc->get_group_level(pl_sd) )
{
clif->message(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player.
return false;
@@ -2724,7 +2723,7 @@ ACMD(recall) {
if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
return false;
}
- pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
+ pc->setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
clif->message(fd, atcmd_output);
@@ -2838,7 +2837,7 @@ ACMD(char_ban)
tmtime->tm_min = tmtime->tm_min + minute;
tmtime->tm_sec = tmtime->tm_sec + second;
timestamp = mktime(tmtime);
- if( timestamp <= time(NULL) && !pc_can_use_command(sd, "@unban") ) {
+ if( timestamp <= time(NULL) && !pc->can_use_command(sd, "@unban") ) {
clif->message(fd,msg_txt(1023)); // You are not allowed to reduce the length of a ban.
return false;
}
@@ -2898,8 +2897,8 @@ ACMD(night)
{
nullpo_retr(-1, sd);
- if (night_flag != 1) {
- map_night_timer(night_timer_tid, 0, 0, 1);
+ if (iMap->night_flag != 1) {
+ pc->map_night_timer(pc->night_timer_tid, 0, 0, 1);
} else {
clif->message(fd, msg_txt(89)); // Night mode is already enabled.
return false;
@@ -2915,8 +2914,8 @@ ACMD(day)
{
nullpo_retr(-1, sd);
- if (night_flag != 0) {
- map_day_timer(day_timer_tid, 0, 0, 1);
+ if (iMap->night_flag != 0) {
+ pc->map_day_timer(pc->day_timer_tid, 0, 0, 1);
} else {
clif->message(fd, msg_txt(90)); // Day mode is already enabled.
return false;
@@ -2938,7 +2937,7 @@ ACMD(doom)
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
{
- if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
+ if (pl_sd->fd != fd && pc->get_group_level(sd) >= pc->get_group_level(pl_sd))
{
status_kill(&pl_sd->bl);
clif->specialeffect(&pl_sd->bl,450,AREA);
@@ -2965,7 +2964,7 @@ ACMD(doommap)
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
{
- if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
+ if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc->get_group_level(sd) >= pc->get_group_level(pl_sd))
{
status_kill(&pl_sd->bl);
clif->specialeffect(&pl_sd->bl,450,AREA);
@@ -3047,13 +3046,13 @@ ACMD(kick)
return false;
}
- if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
+ if((pl_sd=iMap->nick2sd((char *)message)) == NULL && (pl_sd=iMap->charid2sd(atoi(message))) == NULL)
{
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
- if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
+ if ( pc->get_group_level(sd) < pc->get_group_level(pl_sd) )
{
clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
return false;
@@ -3076,7 +3075,7 @@ ACMD(kickall)
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
{
- if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
+ if (pc->get_group_level(sd) >= pc->get_group_level(pl_sd)) { // you can kick only lower or same gm level
if (sd->status.account_id != pl_sd->status.account_id)
clif->GM_kick(NULL, pl_sd);
}
@@ -3094,7 +3093,7 @@ ACMD(kickall)
ACMD(allskill)
{
nullpo_retr(-1, sd);
- pc_allskillup(sd); // all skills
+ pc->allskillup(sd); // all skills
sd->status.skill_point = 0; // 0 skill points
clif->updatestatus(sd, SP_SKILLPOINT); // update
clif->message(fd, msg_txt(76)); // All skills have been added to your skill tree.
@@ -3134,12 +3133,12 @@ ACMD(questskill)
clif->message(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
return false;
}
- if (pc_checkskill2(sd, index) > 0) {
+ if (pc->checkskill2(sd, index) > 0) {
clif->message(fd, msg_txt(196)); // You already have this quest skill.
return false;
}
- pc_skill(sd, skill_id, 1, 0);
+ pc->skill(sd, skill_id, 1, 0);
clif->message(fd, msg_txt(70)); // You have learned the skill.
return true;
@@ -3177,7 +3176,7 @@ ACMD(lostskill)
clif->message(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
return false;
}
- if (pc_checkskill2(sd, index) == 0) {
+ if (pc->checkskill2(sd, index) == 0) {
clif->message(fd, msg_txt(201)); // You don't have this quest skill.
return false;
}
@@ -3210,7 +3209,7 @@ ACMD(spiritball)
}
if( sd->spiritball > 0 )
- pc_delspiritball(sd, sd->spiritball, 1);
+ pc->delspiritball(sd, sd->spiritball, 1);
sd->spiritball = number;
clif->spiritball(&sd->bl);
// no message, player can look the difference
@@ -3223,17 +3222,17 @@ ACMD(spiritball)
*------------------------------------------*/
ACMD(party)
{
- char party[NAME_LENGTH];
+ char party_name[NAME_LENGTH];
nullpo_retr(-1, sd);
- memset(party, '\0', sizeof(party));
+ memset(party_name, '\0', sizeof(party_name));
- if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
+ if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
clif->message(fd, msg_txt(1029)); // Please enter a party name (usage: @party <party_name>).
return false;
}
- party_create(sd, party, 0, 0);
+ party->create(sd, party_name, 0, 0);
return true;
}
@@ -3299,12 +3298,12 @@ ACMD(breakguild)
ACMD(agitstart)
{
nullpo_retr(-1, sd);
- if (agit_flag == 1) {
+ if (iMap->agit_flag == 1) {
clif->message(fd, msg_txt(73)); // War of Emperium is currently in progress.
return false;
}
- agit_flag = 1;
+ iMap->agit_flag = 1;
guild->agit_start();
clif->message(fd, msg_txt(72)); // War of Emperium has been initiated.
@@ -3317,12 +3316,12 @@ ACMD(agitstart)
ACMD(agitstart2)
{
nullpo_retr(-1, sd);
- if (agit2_flag == 1) {
+ if (iMap->agit2_flag == 1) {
clif->message(fd, msg_txt(404)); // "War of Emperium SE is currently in progress."
return false;
}
- agit2_flag = 1;
+ iMap->agit2_flag = 1;
guild->agit2_start();
clif->message(fd, msg_txt(403)); // "War of Emperium SE has been initiated."
@@ -3335,12 +3334,12 @@ ACMD(agitstart2)
ACMD(agitend)
{
nullpo_retr(-1, sd);
- if (agit_flag == 0) {
+ if (iMap->agit_flag == 0) {
clif->message(fd, msg_txt(75)); // War of Emperium is currently not in progress.
return false;
}
- agit_flag = 0;
+ iMap->agit_flag = 0;
guild->agit_end();
clif->message(fd, msg_txt(74)); // War of Emperium has been ended.
@@ -3353,12 +3352,12 @@ ACMD(agitend)
ACMD(agitend2)
{
nullpo_retr(-1, sd);
- if (agit2_flag == 0) {
+ if (iMap->agit2_flag == 0) {
clif->message(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress."
return false;
}
- agit2_flag = 0;
+ iMap->agit2_flag = 0;
guild->agit2_end();
clif->message(fd, msg_txt(405)); // "War of Emperium SE has been ended."
@@ -3372,7 +3371,7 @@ ACMD(mapexit)
{
nullpo_retr(-1, sd);
- do_shutdown();
+ iMap->do_shutdown();
return true;
}
@@ -3396,7 +3395,7 @@ ACMD(idsearch)
sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
clif->message(fd, atcmd_output);
- match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
+ match = itemdb->search_name_array(item_array, MAX_SEARCH, item_name);
if (match > MAX_SEARCH) {
sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
clif->message(fd, atcmd_output);
@@ -3433,7 +3432,7 @@ ACMD(recallall)
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
{
- if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
+ if (sd->status.account_id != pl_sd->status.account_id && pc->get_group_level(sd) >= pc->get_group_level(pl_sd))
{
if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
continue; // Don't waste time warping the character to the same place.
@@ -3441,10 +3440,10 @@ ACMD(recallall)
count++;
else {
if (pc_isdead(pl_sd)) { //Wake them up
- pc_setstand(pl_sd);
- pc_setrestartvalue(pl_sd,1);
+ pc->setstand(pl_sd);
+ pc->setrestartvalue(pl_sd,1);
}
- pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
+ pc->setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
}
}
}
@@ -3498,12 +3497,12 @@ ACMD(guildrecall)
{
if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
{
- if (pc_get_group_level(pl_sd) > pc_get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y))
+ if (pc->get_group_level(pl_sd) > pc->get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y))
continue; // Skip GMs greater than you... or chars already on the cell
if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
count++;
else
- pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
+ pc->setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
}
}
mapit->free(iter);
@@ -3543,8 +3542,8 @@ ACMD(partyrecall)
return false;
}
- if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
- (p = party_search(atoi(message))) == NULL)
+ if ((p = party->searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
+ (p = party->search(atoi(message))) == NULL)
{
clif->message(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
return false;
@@ -3557,12 +3556,12 @@ ACMD(partyrecall)
{
if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
{
- if (pc_get_group_level(pl_sd) > pc_get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y))
+ if (pc->get_group_level(pl_sd) > pc->get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y))
continue; // Skip GMs greater than you... or chars already on the cell
if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
count++;
else
- pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
+ pc->setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
}
}
mapit->free(iter);
@@ -3583,7 +3582,7 @@ ACMD(partyrecall)
ACMD(reloaditemdb)
{
nullpo_retr(-1, sd);
- itemdb_reload();
+ itemdb->reload();
clif->message(fd, msg_txt(97)); // Item database has been reloaded.
return true;
@@ -3634,7 +3633,7 @@ ACMD(reloadatcommand) {
config_destroy(&run_test);
- if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
+ if (conf_read_file(&run_test, iMap->ATCOMMAND_CONF_FILENAME)) {
clif->message(fd, msg_txt(1037)); // Error reading atcommand.conf, reload failed.
return false;
}
@@ -3654,7 +3653,7 @@ ACMD(reloadbattleconf)
struct Battle_Config prev_config;
memcpy(&prev_config, &battle_config, sizeof(prev_config));
- battle->config_read(BATTLE_CONF_FILENAME);
+ battle->config_read(iMap->BATTLE_CONF_FILENAME);
if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
|| prev_config.item_rate_common != battle_config.item_rate_common
@@ -3708,7 +3707,7 @@ ACMD(reloadstatusdb)
*------------------------------------------*/
ACMD(reloadpcdb)
{
- pc_readdb();
+ pc->readdb();
clif->message(fd, msg_txt(257));
return true;
}
@@ -3718,12 +3717,35 @@ ACMD(reloadpcdb)
*------------------------------------------*/
ACMD(reloadscript)
{
+ struct s_mapiterator* iter;
+ struct map_session_data* pl_sd;
+
nullpo_retr(-1, sd);
//atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
//atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
+ iter = mapit_getallusers();
+ for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) {
+ if (pl_sd->npc_id || pl_sd->npc_shopid) {
+ if (pl_sd->state.using_fake_npc) {
+ clif->clearunit_single(pl_sd->npc_id, CLR_OUTSIGHT, pl_sd->fd);
+ pl_sd->state.using_fake_npc = 0;
+ }
+ if (pl_sd->state.menu_or_input)
+ pl_sd->state.menu_or_input = 0;
+ if (pl_sd->npc_menu)
+ pl_sd->npc_menu = 0;
+
+ pl_sd->npc_id = 0;
+ pl_sd->npc_shopid = 0;
+ if (pl_sd->st && pl_sd->st->state != END)
+ pl_sd->st->state = END;
+ }
+ }
+ mapit->free(iter);
+
flush_fifos();
- map_reloadnpc(true); // reload config files seeking for npcs
+ iMap->reloadnpc(true); // reload config files seeking for npcs
script_reload();
npc_reload();
@@ -3766,9 +3788,9 @@ ACMD(mapinfo) {
if (mapname[0] == '\0') {
safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
- m_id = map_mapindex2mapid(sd->mapindex);
+ m_id = iMap->mapindex2mapid(sd->mapindex);
} else {
- m_id = map_mapname2mapid(mapname);
+ m_id = iMap->mapname2mapid(mapname);
}
if (m_id < 0) {
@@ -3786,7 +3808,7 @@ ACMD(mapinfo) {
if( pl_sd->mapindex == m_index ) {
if( pl_sd->state.vending )
vend_num++;
- else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
+ else if( (cd = (struct chat_data*)iMap->id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
chat_num++;
}
}
@@ -3940,7 +3962,7 @@ ACMD(mapinfo) {
for (i = 0; i < map[m_id].npc_num;)
{
nd = map[m_id].npc[i];
- switch(nd->ud.dir) {
+ switch(nd->dir) {
case 0: strcpy(direction, msg_txt(1101)); break; // North
case 1: strcpy(direction, msg_txt(1102)); break; // North West
case 2: strcpy(direction, msg_txt(1103)); break; // West
@@ -3966,7 +3988,7 @@ ACMD(mapinfo) {
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
{
- if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
+ if ((cd = (struct chat_data*)iMap->id2bl(pl_sd->chatID)) != NULL &&
pl_sd->mapindex == m_index &&
cd->usersd[0] == pl_sd)
{
@@ -4001,47 +4023,47 @@ ACMD(mount_peco)
return false;
}
- if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
+ if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc->checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
if( !(sd->sc.option&OPTION_DRAGON1) ) {
clif->message(sd->fd,msg_txt(1119)); // You have mounted your Dragon.
- pc_setoption(sd, sd->sc.option|OPTION_DRAGON1);
+ pc->setoption(sd, sd->sc.option|OPTION_DRAGON1);
} else {
clif->message(sd->fd,msg_txt(1120)); // You have released your Dragon.
- pc_setoption(sd, sd->sc.option&~OPTION_DRAGON1);
+ pc->setoption(sd, sd->sc.option&~OPTION_DRAGON1);
}
return true;
}
- if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 ) {
+ if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc->checkskill(sd,RA_WUGRIDER) > 0 ) {
if( !pc_isridingwug(sd) ) {
clif->message(sd->fd,msg_txt(1121)); // You have mounted your Warg.
- pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
+ pc->setoption(sd, sd->sc.option|OPTION_WUGRIDER);
} else {
clif->message(sd->fd,msg_txt(1122)); // You have released your Warg.
- pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
+ pc->setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
}
return true;
}
if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
if( !pc_ismadogear(sd) ) {
clif->message(sd->fd,msg_txt(1123)); // You have mounted your Mado Gear.
- pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
+ pc->setoption(sd, sd->sc.option|OPTION_MADOGEAR);
} else {
clif->message(sd->fd,msg_txt(1124)); // You have released your Mado Gear.
- pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
+ pc->setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
}
return true;
}
if (!pc_isriding(sd)) { // if actually no peco
- if (!pc_checkskill(sd, KN_RIDING)) {
+ if (!pc->checkskill(sd, KN_RIDING)) {
clif->message(fd, msg_txt(213)); // You can not mount a Peco Peco with your current job.
return false;
}
- pc_setoption(sd, sd->sc.option | OPTION_RIDING);
+ pc->setoption(sd, sd->sc.option | OPTION_RIDING);
clif->message(fd, msg_txt(102)); // You have mounted a Peco Peco.
} else {//Dismount
- pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
+ pc->setoption(sd, sd->sc.option & ~OPTION_RIDING);
clif->message(fd, msg_txt(214)); // You have released your Peco Peco.
}
@@ -4060,7 +4082,7 @@ ACMD(guildspy)
memset(guild_name, '\0', sizeof(guild_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
- if (!enable_spy)
+ if (!iMap->enable_spy)
{
clif->message(fd, msg_txt(1125)); // The mapserver has spy command support disabled.
return false;
@@ -4101,7 +4123,7 @@ ACMD(partyspy)
memset(party_name, '\0', sizeof(party_name));
memset(atcmd_output, '\0', sizeof(atcmd_output));
- if (!enable_spy)
+ if (!iMap->enable_spy)
{
clif->message(fd, msg_txt(1125)); // The mapserver has spy command support disabled.
return false;
@@ -4112,8 +4134,8 @@ ACMD(partyspy)
return false;
}
- if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
- (p = party_search(atoi(message))) != NULL) {
+ if ((p = party->searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
+ (p = party->search(atoi(message))) != NULL) {
if (sd->partyspy == p->party.party_id) {
sd->partyspy = 0;
sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
@@ -4175,9 +4197,9 @@ ACMD(nuke)
return false;
}
- if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
- if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
- skill->castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
+ if ((pl_sd = iMap->nick2sd(atcmd_player_name)) != NULL) {
+ if (pc->get_group_level(sd) >= pc->get_group_level(pl_sd)) { // you can kill only lower or same GM level
+ skill->castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, iTimer->gettick(), 0);
clif->message(fd, msg_txt(109)); // Player has been nuked!
} else {
clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
@@ -4209,7 +4231,7 @@ ACMD(tonpc)
}
if ((nd = npc_name2id(npcname)) != NULL) {
- if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
+ if (pc->setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
clif->message(fd, msg_txt(0)); // Warped.
else
return false;
@@ -4384,31 +4406,31 @@ ACMD(servertime)
clif->message(fd, temp);
if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
- if (night_flag == 0)
+ if (iMap->night_flag == 0)
clif->message(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
else
clif->message(fd, msg_txt(232)); // Game time: The game is in permanent night.
} else if (battle_config.night_duration == 0)
- if (night_flag == 1) { // we start with night
- timer_data = get_timer(day_timer_tid);
- sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
+ if (iMap->night_flag == 1) { // we start with night
+ timer_data = iTimer->get_timer(pc->day_timer_tid);
+ sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,iTimer->gettick())/1000)); // Game time: The game is actualy in night for %s.
clif->message(fd, temp);
clif->message(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
} else
clif->message(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
else if (battle_config.day_duration == 0)
- if (night_flag == 0) { // we start with day
- timer_data = get_timer(night_timer_tid);
- sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
+ if (iMap->night_flag == 0) { // we start with day
+ timer_data = iTimer->get_timer(pc->night_timer_tid);
+ sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,iTimer->gettick())/1000)); // Game time: The game is actualy in daylight for %s.
clif->message(fd, temp);
clif->message(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
} else
clif->message(fd, msg_txt(232)); // Game time: The game is in permanent night.
else {
- if (night_flag == 0) {
- timer_data = get_timer(night_timer_tid);
- timer_data2 = get_timer(day_timer_tid);
- sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
+ if (iMap->night_flag == 0) {
+ timer_data = iTimer->get_timer(pc->night_timer_tid);
+ timer_data2 = iTimer->get_timer(pc->day_timer_tid);
+ sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,iTimer->gettick())/1000)); // Game time: The game is actualy in daylight for %s.
clif->message(fd, temp);
if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
@@ -4418,9 +4440,9 @@ ACMD(servertime)
sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
clif->message(fd, temp);
} else {
- timer_data = get_timer(day_timer_tid);
- timer_data2 = get_timer(night_timer_tid);
- sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
+ timer_data = iTimer->get_timer(pc->day_timer_tid);
+ timer_data2 = iTimer->get_timer(pc->night_timer_tid);
+ sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,iTimer->gettick()) / 1000)); // Game time: The game is actualy in night for %s.
clif->message(fd, temp);
if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
sprintf(temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
@@ -4481,12 +4503,12 @@ ACMD(jail)
return false;
}
- if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
+ if ((pl_sd = iMap->nick2sd(atcmd_player_name)) == NULL) {
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
- if (pc_get_group_level(sd) < pc_get_group_level(pl_sd))
+ if (pc->get_group_level(sd) < pc->get_group_level(pl_sd))
{ // you can jail only lower or same GM
clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
return false;
@@ -4533,12 +4555,12 @@ ACMD(unjail)
return false;
}
- if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
+ if ((pl_sd = iMap->nick2sd(atcmd_player_name)) == NULL) {
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
- if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
+ if (pc->get_group_level(sd) < pc->get_group_level(pl_sd)) { // you can jail only lower or same GM
clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
return false;
@@ -4613,12 +4635,12 @@ ACMD(jailfor)
return false;
}
- if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
+ if ((pl_sd = iMap->nick2sd(atcmd_player_name)) == NULL) {
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
- if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
+ if (pc->get_group_level(pl_sd) > pc->get_group_level(sd)) {
clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
return false;
}
@@ -4738,7 +4760,7 @@ ACMD(disguise)
return false;
}
- pc_disguise(sd, id);
+ pc->disguise(sd, id);
clif->message(fd, msg_txt(122)); // Disguise applied.
return true;
@@ -4769,7 +4791,7 @@ ACMD(disguiseall)
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
- pc_disguise(pl_sd, mob_id);
+ pc->disguise(pl_sd, mob_id);
mapit->free(iter);
clif->message(fd, msg_txt(122)); // Disguise applied.
@@ -4817,7 +4839,7 @@ ACMD(disguiseguild)
for( i = 0; i < g->max_member; i++ )
if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
- pc_disguise(pl_sd, id);
+ pc->disguise(pl_sd, id);
clif->message(fd, msg_txt(122)); // Disguise applied.
return true;
@@ -4831,7 +4853,7 @@ ACMD(undisguise)
{
nullpo_retr(-1, sd);
if (sd->disguise != -1) {
- pc_disguise(sd, -1);
+ pc->disguise(sd, -1);
clif->message(fd, msg_txt(124)); // Undisguise applied.
} else {
clif->message(fd, msg_txt(125)); // You're not disguised.
@@ -4852,7 +4874,7 @@ ACMD(undisguiseall) {
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
if( pl_sd->disguise != -1 )
- pc_disguise(pl_sd, -1);
+ pc->disguise(pl_sd, -1);
mapit->free(iter);
clif->message(fd, msg_txt(124)); // Undisguise applied.
@@ -4885,7 +4907,7 @@ ACMD(undisguiseguild)
for(i = 0; i < g->max_member; i++)
if( (pl_sd = g->member[i].sd) && pl_sd->disguise != -1 )
- pc_disguise(pl_sd, -1);
+ pc->disguise(pl_sd, -1);
clif->message(fd, msg_txt(124)); // Undisguise applied.
@@ -4902,11 +4924,11 @@ ACMD(exp)
nullpo_retr(-1, sd);
memset(output, '\0', sizeof(output));
- nextb = pc_nextbaseexp(sd);
+ nextb = pc->nextbaseexp(sd);
if (nextb)
nextb = sd->status.base_exp*100.0/nextb;
- nextj = pc_nextjobexp(sd);
+ nextj = pc->nextjobexp(sd);
if (nextj)
nextj = sd->status.job_exp*100.0/nextj;
@@ -5042,7 +5064,7 @@ ACMD(killable)
clif->message(fd, msg_txt(242));
else {
clif->message(fd, msg_txt(288));
- map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
+ iMap->foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
}
return true;
}
@@ -5101,9 +5123,9 @@ ACMD(npcmove)
x = cap_value(x, 0, map[m].xs-1);
y = cap_value(y, 0, map[m].ys-1);
- map_foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
- map_moveblock(&nd->bl, x, y, gettick());
- map_foreachinrange(clif->insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
+ iMap->foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
+ iMap->moveblock(&nd->bl, x, y, iTimer->gettick());
+ iMap->foreachinrange(clif->insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
clif->message(fd, msg_txt(1155)); // NPC moved.
return true;
@@ -5158,22 +5180,22 @@ ACMD(follow)
if (sd->followtarget == -1)
return false;
- pc_stop_following (sd);
+ pc->stop_following (sd);
clif->message(fd, msg_txt(1159)); // Follow mode OFF.
return true;
}
- if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
+ if ( (pl_sd = iMap->nick2sd((char *)message)) == NULL )
{
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
if (sd->followtarget == pl_sd->bl.id) {
- pc_stop_following (sd);
+ pc->stop_following (sd);
clif->message(fd, msg_txt(1159)); // Follow mode OFF.
} else {
- pc_follow(sd, pl_sd->bl.id);
+ pc->follow(sd, pl_sd->bl.id);
clif->message(fd, msg_txt(1160)); // Follow mode ON.
}
@@ -5192,8 +5214,8 @@ ACMD(dropall)
for (i = 0; i < MAX_INVENTORY; i++) {
if (sd->status.inventory[i].amount) {
if(sd->status.inventory[i].equip != 0)
- pc_unequipitem(sd, i, 3);
- pc_dropitem(sd, i, sd->status.inventory[i].amount);
+ pc->unequipitem(sd, i, 3);
+ pc->dropitem(sd, i, sd->status.inventory[i].amount);
}
}
return true;
@@ -5210,7 +5232,7 @@ ACMD(storeall)
if (sd->state.storage_flag != 1)
{ //Open storage.
- if( storage_storageopen(sd) == 1 ) {
+ if( storage->open(sd) == 1 ) {
clif->message(fd, msg_txt(1161)); // You currently cannot open your storage.
return false;
}
@@ -5219,11 +5241,11 @@ ACMD(storeall)
for (i = 0; i < MAX_INVENTORY; i++) {
if (sd->status.inventory[i].amount) {
if(sd->status.inventory[i].equip != 0)
- pc_unequipitem(sd, i, 3);
- storage_storageadd(sd, i, sd->status.inventory[i].amount);
+ pc->unequipitem(sd, i, 3);
+ storage->add(sd, i, sd->status.inventory[i].amount);
}
}
- storage_storageclose(sd);
+ storage->close(sd);
clif->message(fd, msg_txt(1162)); // All items stored.
return true;
@@ -5241,9 +5263,9 @@ ACMD(clearstorage)
j = sd->status.storage.storage_amount;
for (i = 0; i < j; ++i) {
- storage_delitem(sd, i, sd->status.storage.items[i].amount);
+ storage->delitem(sd, i, sd->status.storage.items[i].amount);
}
- storage_storageclose(sd);
+ storage->close(sd);
clif->message(fd, msg_txt(1394)); // Your storage was cleaned.
return true;
@@ -5253,7 +5275,7 @@ ACMD(cleargstorage)
{
int i, j;
struct guild *g;
- struct guild_storage *gstorage;
+ struct guild_storage *guild_storage;
nullpo_retr(-1, sd);
g = sd->guild;
@@ -5273,18 +5295,18 @@ ACMD(cleargstorage)
return false;
}
- gstorage = guild2storage2(sd->status.guild_id);
- if (gstorage == NULL) {// Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
+ guild_storage = gstorage->id2storage2(sd->status.guild_id);
+ if (guild_storage == NULL) {// Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
return false;
}
- j = gstorage->storage_amount;
- gstorage->lock = 1; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
+ j = guild_storage->storage_amount;
+ guild_storage->lock = 1; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
for (i = 0; i < j; ++i) {
- guild_storage_delitem(sd, gstorage, i, gstorage->items[i].amount);
+ gstorage->delitem(sd, guild_storage, i, guild_storage->items[i].amount);
}
- storage_guild_storageclose(sd);
- gstorage->lock = 0; // Cleaning done, release lock
+ gstorage->close(sd);
+ guild_storage->lock = 0; // Cleaning done, release lock
clif->message(fd, msg_txt(1395)); // Your guild storage was cleaned.
return true;
@@ -5306,7 +5328,7 @@ ACMD(clearcart)
for( i = 0; i < MAX_CART; i++ )
if(sd->status.cart[i].nameid > 0)
- pc_cart_delitem(sd, i, sd->status.cart[i].amount, 1, LOG_TYPE_OTHER);
+ pc->cart_delitem(sd, i, sd->status.cart[i].amount, 1, LOG_TYPE_OTHER);
clif->clearcart(fd);
clif->updatestatus(sd,SP_CARTINFO);
@@ -5382,12 +5404,12 @@ ACMD(useskill)
}
if(!strcmp(target,"self")) pl_sd = sd; //quick keyword
- else if ( (pl_sd = map_nick2sd(target)) == NULL ){
+ else if ( (pl_sd = iMap->nick2sd(target)) == NULL ){
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
- if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
+ if ( pc->get_group_level(sd) < pc->get_group_level(pl_sd) )
{
clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
return false;
@@ -5426,7 +5448,7 @@ ACMD(displayskill)
return false;
}
status = status_get_status_data(&sd->bl);
- tick = gettick();
+ tick = iTimer->gettick();
clif->skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, 5);
clif->skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
clif->skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
@@ -5451,16 +5473,16 @@ ACMD(skilltree)
return false;
}
- if ( (pl_sd = map_nick2sd(target)) == NULL )
+ if ( (pl_sd = iMap->nick2sd(target)) == NULL )
{
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
- c = pc_calc_skilltree_normalize_job(pl_sd);
- c = pc_mapid2jobid(c, pl_sd->status.sex);
+ c = pc->calc_skilltree_normalize_job(pl_sd);
+ c = pc->mapid2jobid(c, pl_sd->status.sex);
- sprintf(atcmd_output, msg_txt(1168), job_name(c), pc_checkskill(pl_sd, NV_BASIC)); // Player is using %s skill tree (%d basic points).
+ sprintf(atcmd_output, msg_txt(1168), pc->job_name(c), pc->checkskill(pl_sd, NV_BASIC)); // Player is using %s skill tree (%d basic points).
clif->message(fd, atcmd_output);
ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skill_id );
@@ -5475,7 +5497,7 @@ ACMD(skilltree)
meets = 1;
for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
{
- if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
+ if( ent->need[j].id && pc->checkskill(sd,ent->need[j].id) < ent->need[j].lv)
{
sprintf(atcmd_output, msg_txt(1170), ent->need[j].lv, skill_db[ent->need[j].id].desc); // Player requires level %d of skill %s.
clif->message(fd, atcmd_output);
@@ -5503,9 +5525,9 @@ void getring (struct map_session_data* sd)
item_tmp.card[2] = sd->status.partner_id;
item_tmp.card[3] = sd->status.partner_id >> 16;
- if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
+ if((flag = pc->additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
clif->additem(sd,0,0,flag);
- map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
}
@@ -5525,12 +5547,12 @@ ACMD(marry)
return false;
}
- if ((pl_sd = map_nick2sd(player_name)) == NULL) {
+ if ((pl_sd = iMap->nick2sd(player_name)) == NULL) {
clif->message(fd, msg_txt(3));
return false;
}
- if (pc_marriage(sd, pl_sd) == 0) {
+ if (pc->marriage(sd, pl_sd) == 0) {
clif->message(fd, msg_txt(1173)); // They are married... wish them well.
clif->wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
getring(sd); // Auto-give named rings (Aru)
@@ -5550,7 +5572,7 @@ ACMD(divorce)
{
nullpo_retr(-1, sd);
- if (pc_divorce(sd) != 0) {
+ if (pc->divorce(sd) != 0) {
sprintf(atcmd_output, msg_txt(1175), sd->status.name); // '%s' is not married.
clif->message(fd, atcmd_output);
return false;
@@ -5647,7 +5669,7 @@ ACMD(changegm)
return false;
}
- if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
+ if((pl_sd=iMap->nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
clif->message(fd, msg_txt(1184)); // Target character must be online and be a guild member.
return false;
}
@@ -5670,7 +5692,7 @@ ACMD(changeleader)
return false;
}
- if (party_changeleader(sd, map_nick2sd((char *) message)))
+ if (party->changeleader(sd, iMap->nick2sd((char *) message)))
return true;
return false;
}
@@ -5686,7 +5708,7 @@ ACMD(partyoption)
char w1[16], w2[16];
nullpo_retr(-1, sd);
- if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
+ if (sd->status.party_id == 0 || (p = party->search(sd->status.party_id)) == NULL)
{
clif->message(fd, msg_txt(282));
return false;
@@ -5712,7 +5734,7 @@ ACMD(partyoption)
//Change item share type.
if (option != p->party.item)
- party_changeoption(sd, p->party.exp, option);
+ party->changeoption(sd, p->party.exp, option);
else
clif->message(fd, msg_txt(286));
@@ -5776,8 +5798,8 @@ ACMD(autolootitem)
if (action < 3) // add or remove
{
- if ((item_data = itemdb_exists(atoi(message))) == NULL)
- item_data = itemdb_searchname(message);
+ if ((item_data = itemdb->exists(atoi(message))) == NULL)
+ item_data = itemdb->search_name(message);
if (!item_data) {
// No items founds in the DB with Id or Name
clif->message(fd, msg_txt(1189)); // Item not found.
@@ -5830,7 +5852,7 @@ ACMD(autolootitem)
{
if (sd->state.autolootid[i] == 0)
continue;
- if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
+ if (!(item_data = itemdb->exists(sd->state.autolootid[i]))) {
ShowDebug("Non-existant item %d on autolootitem list (account_id: %d, char_id: %d)", sd->state.autolootid[i], sd->status.account_id, sd->status.char_id);
continue;
}
@@ -6106,14 +6128,14 @@ ACMD(mobsearch)
static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
{
nullpo_ret(bl);
- map_clearflooritem(bl);
+ iMap->clearflooritem(bl);
return 0;
}
ACMD(cleanmap)
{
- map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
+ iMap->foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
clif->message(fd, msg_txt(1221)); // All dropped items have been cleaned up.
return true;
}
@@ -6123,13 +6145,13 @@ ACMD(cleanarea)
int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
if (!message || !*message || sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) < 1) {
- map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, sd->bl.x - (AREA_SIZE * 2), sd->bl.y - (AREA_SIZE * 2), sd->bl.x + (AREA_SIZE * 2), sd->bl.y + (AREA_SIZE * 2), BL_ITEM);
+ iMap->foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, sd->bl.x - (AREA_SIZE * 2), sd->bl.y - (AREA_SIZE * 2), sd->bl.x + (AREA_SIZE * 2), sd->bl.y + (AREA_SIZE * 2), BL_ITEM);
}
else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 1) {
- map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, sd->bl.x - x0, sd->bl.y - x0, sd->bl.x + x0, sd->bl.y + x0, BL_ITEM);
+ iMap->foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, sd->bl.x - x0, sd->bl.y - x0, sd->bl.x + x0, sd->bl.y + x0, BL_ITEM);
}
else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 4) {
- map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
+ iMap->foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
}
clif->message(fd, msg_txt(1221)); // All dropped items have been cleaned up.
@@ -6148,7 +6170,7 @@ ACMD(npctalk)
unsigned long color=0;
if (sd->sc.count && //no "chatting" while muted.
- (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
+ (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_DEEP_SLEEP] || sd->sc.data[SC__BLOODYLUST] ||
(sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
return false;
@@ -6187,9 +6209,9 @@ ACMD(pettalk)
nullpo_retr(-1, sd);
if ( battle_config.min_chat_delay ) {
- if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
+ if( DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0 )
return true;
- sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
+ sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay;
}
if(!sd->status.pet_id || !(pd=sd->pd))
@@ -6199,7 +6221,7 @@ ACMD(pettalk)
}
if (sd->sc.count && //no "chatting" while muted.
- (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
+ (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_DEEP_SLEEP] || sd->sc.data[SC__BLOODYLUST] ||
(sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
return false;
@@ -6294,8 +6316,8 @@ ACMD(users)
*------------------------------------------*/
ACMD(reset)
{
- pc_resetstate(sd);
- pc_resetskill(sd,1);
+ pc->resetstate(sd);
+ pc->resetskill(sd,1);
sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
clif->message(fd, atcmd_output);
return true;
@@ -6310,7 +6332,7 @@ ACMD(summon)
int mob_id = 0;
int duration = 0;
struct mob_data *md;
- unsigned int tick=gettick();
+ unsigned int tick=iTimer->gettick();
nullpo_retr(-1, sd);
@@ -6340,7 +6362,7 @@ ACMD(summon)
md->master_id=sd->bl.id;
md->special_state.ai=1;
- md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
+ md->deletetimer=iTimer->add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
clif->specialeffect(&md->bl,344,AREA);
mob_spawn(md);
sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
@@ -6391,13 +6413,13 @@ ACMD(trade)
return false;
}
- if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
+ if ( (pl_sd = iMap->nick2sd((char *)message)) == NULL )
{
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
- trade_traderequest(sd, pl_sd);
+ trade->request(sd, pl_sd);
return true;
}
@@ -6438,7 +6460,7 @@ ACMD(unmute)
return false;
}
- if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
+ if ( (pl_sd = iMap->nick2sd((char *)message)) == NULL )
{
clif->message(fd, msg_txt(3)); // Character not found.
return false;
@@ -6465,7 +6487,7 @@ ACMD(uptime)
minute = 60, days = 0, hours = 0, minutes = 0;
nullpo_retr(-1, sd);
- seconds = get_uptime();
+ seconds = iTimer->get_uptime();
days = seconds/day;
seconds -= (seconds/day>0)?(seconds/day)*day:0;
hours = seconds/hour;
@@ -6487,10 +6509,10 @@ ACMD(changesex)
{
int i;
nullpo_retr(-1, sd);
- pc_resetskill(sd,4);
+ pc->resetskill(sd,4);
// to avoid any problem with equipment and invalid sex, equipment is unequiped.
for( i=0; i<EQI_MAX; i++ )
- if( sd->equip_index[i] >= 0 ) pc_unequipitem(sd, sd->equip_index[i], 3);
+ if( sd->equip_index[i] >= 0 ) pc->unequipitem(sd, sd->equip_index[i], 3);
chrif_changesex(sd);
return true;
}
@@ -6509,13 +6531,13 @@ ACMD(mute)
return false;
}
- if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
+ if ( (pl_sd = iMap->nick2sd(atcmd_player_name)) == NULL )
{
clif->message(fd, msg_txt(3)); // Character not found.
return false;
}
- if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
+ if ( pc->get_group_level(sd) < pc->get_group_level(pl_sd) )
{
clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
return false;
@@ -6601,7 +6623,7 @@ ACMD(misceffect) {
ACMD(mail)
{
nullpo_ret(sd);
- mail_openmail(sd);
+ mail->openmail(sd);
return true;
}
@@ -6673,7 +6695,7 @@ ACMD(mobinfo)
j = 0;
for (i = 0; i < MAX_MOB_DROP; i++) {
int droprate;
- if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
+ if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb->exists(mob->dropitem[i].nameid)) == NULL)
continue;
droprate = mob->dropitem[i].p;
@@ -6698,7 +6720,7 @@ ACMD(mobinfo)
strcpy(atcmd_output, msg_txt(1248)); // MVP Items:
j = 0;
for (i = 0; i < MAX_MVP_DROP; i++) {
- if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
+ if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb->exists(mob->mvpitem[i].nameid)) == NULL)
continue;
if (mob->mvpitem[i].p > 0) {
j++;
@@ -6867,18 +6889,24 @@ ACMD(hommutate) {
ACMD(makehomun) {
int homunid;
nullpo_retr(-1, sd);
-
- if ( sd->status.hom_id ) {
- clif->message(fd, msg_txt(450));
- return false;
- }
-
+
if (!message || !*message) {
clif->message(fd, msg_txt(1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
return false;
}
homunid = atoi(message);
+
+ if( homunid == -1 && sd->status.hom_id && !homun_alive(sd->hd) ) {
+ homun->call(sd);
+ return true;
+ }
+
+ if ( sd->status.hom_id ) {
+ clif->message(fd, msg_txt(450));
+ return false;
+ }
+
if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
{
clif->message(fd, msg_txt(1257)); // Invalid Homunculus ID.
@@ -6953,13 +6981,13 @@ ACMD(homtalk)
nullpo_retr(-1, sd);
if ( battle_config.min_chat_delay ) {
- if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
+ if( DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0 )
return true;
- sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
+ sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay;
}
if (sd->sc.count && //no "chatting" while muted.
- (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
+ (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_DEEP_SLEEP] || sd->sc.data[SC__BLOODYLUST] ||
(sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
return false;
@@ -7114,8 +7142,8 @@ ACMD(iteminfo)
clif->message(fd, msg_txt(1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
return false;
}
- if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
- count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
+ if ((item_array[0] = itemdb->exists(atoi(message))) == NULL)
+ count = itemdb->search_name_array(item_array, MAX_SEARCH, message);
if (!count) {
clif->message(fd, msg_txt(19)); // Invalid item ID or name.
@@ -7163,8 +7191,8 @@ ACMD(whodrops)
clif->message(fd, msg_txt(1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
return false;
}
- if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
- count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
+ if ((item_array[0] = itemdb->exists(atoi(message))) == NULL)
+ count = itemdb->search_name_array(item_array, MAX_SEARCH, message);
if (!count) {
clif->message(fd, msg_txt(19)); // Invalid item ID or name.
@@ -7234,7 +7262,7 @@ ACMD(whereis)
for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
{
- j = map_mapindex2mapid(mob->spawn[i].mapindex);
+ j = iMap->mapindex2mapid(mob->spawn[i].mapindex);
if (j < 0) continue;
snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
clif->message(fd, atcmd_output);
@@ -7276,7 +7304,7 @@ static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
id = va_arg(ap, int);
time = va_arg(ap, int);
- if (id != bl->id && !pc_get_group_level(pl_sd)) {
+ if (id != bl->id && !pc->get_group_level(pl_sd)) {
pl_sd->status.manner -= time;
if (pl_sd->status.manner < 0)
sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
@@ -7298,7 +7326,7 @@ ACMD(mutearea)
time = atoi(message);
- map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
+ iMap->foreachinarea(atcommand_mutearea_sub,sd->bl.m,
sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
@@ -7342,7 +7370,7 @@ ACMD(me)
memset(atcmd_output, '\0', sizeof(atcmd_output));
if (sd->sc.count && //no "chatting" while muted.
- (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
+ (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_DEEP_SLEEP] || sd->sc.data[SC__BLOODYLUST] ||
(sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
return false;
@@ -7371,7 +7399,7 @@ ACMD(size)
if(sd->state.size) {
sd->state.size = SZ_SMALL;
- pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
+ pc->setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
}
sd->state.size = size;
@@ -7398,7 +7426,7 @@ ACMD(sizeall)
if( pl_sd->state.size != size ) {
if( pl_sd->state.size ) {
pl_sd->state.size = SZ_SMALL;
- pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
+ pc->setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
}
pl_sd->state.size = size;
@@ -7440,7 +7468,7 @@ ACMD(sizeguild)
if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
if( pl_sd->state.size ) {
pl_sd->state.size = SZ_SMALL;
- pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
+ pc->setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
}
pl_sd->state.size = size;
@@ -7549,19 +7577,19 @@ return true;\
if ( strcmp( flag_name , "gvg" ) == 0 ) {
if( flag && !map[sd->bl.m].flag.gvg )
- map_zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME));
+ iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_GVG_NAME));
else if ( !flag && map[sd->bl.m].flag.gvg )
- map_zone_change2(sd->bl.m,map[sd->bl.m].prev_zone);
+ iMap->zone_change2(sd->bl.m,map[sd->bl.m].prev_zone);
} else if ( strcmp( flag_name , "pvp" ) == 0 ) {
if( flag && !map[sd->bl.m].flag.pvp )
- map_zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME));
+ iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_PVP_NAME));
else if ( !flag && map[sd->bl.m].flag.pvp )
- map_zone_change2(sd->bl.m,map[sd->bl.m].prev_zone);
+ iMap->zone_change2(sd->bl.m,map[sd->bl.m].prev_zone);
} else if ( strcmp( flag_name , "battleground" ) == 0 ) {
if( flag && !map[sd->bl.m].flag.battleground )
- map_zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_BG_NAME));
+ iMap->zone_change2(sd->bl.m,strdb_get(zone_db, MAP_ZONE_BG_NAME));
else if ( !flag && map[sd->bl.m].flag.battleground )
- map_zone_change2(sd->bl.m,map[sd->bl.m].prev_zone);
+ iMap->zone_change2(sd->bl.m,map[sd->bl.m].prev_zone);
}
setflag(autotrade); setflag(allowks); setflag(nomemo); setflag(noteleport);
@@ -7649,7 +7677,7 @@ ACMD(showdelay)
ACMD(invite)
{
unsigned int did = sd->duel_group;
- struct map_session_data *target_sd = map_nick2sd((char *)message);
+ struct map_session_data *target_sd = iMap->nick2sd((char *)message);
if(did == 0) {
// "Duel: @invite without @duel."
@@ -7722,7 +7750,7 @@ ACMD(duel)
duel_create(sd, maxpl);
} else {
struct map_session_data *target_sd;
- target_sd = map_nick2sd((char *)message);
+ target_sd = iMap->nick2sd((char *)message);
if(target_sd != NULL) {
unsigned int newduel;
if((newduel = duel_create(sd, 2)) != -1) {
@@ -7820,13 +7848,13 @@ ACMD(cash)
if( !strcmpi(command+1,"cash") )
{
if( value > 0 ) {
- if( (ret=pc_getcash(sd, value, 0)) >= 0){
+ if( (ret=pc->getcash(sd, value, 0)) >= 0){
sprintf(output, msg_txt(505), ret, sd->cashPoints);
clif->disp_onlyself(sd, output, strlen(output));
}
else clif->message(fd, msg_txt(149)); // Unable to decrease the number/value.
} else {
- if( (ret=pc_paycash(sd, -value, 0)) >= 0){
+ if( (ret=pc->paycash(sd, -value, 0)) >= 0){
sprintf(output, msg_txt(410), ret, sd->cashPoints);
clif->disp_onlyself(sd, output, strlen(output));
}
@@ -7836,13 +7864,13 @@ ACMD(cash)
else
{ // @points
if( value > 0 ) {
- if( (ret=pc_getcash(sd, 0, value)) >= 0){
+ if( (ret=pc->getcash(sd, 0, value)) >= 0){
sprintf(output, msg_txt(506), ret, sd->kafraPoints);
clif->disp_onlyself(sd, output, strlen(output));
}
else clif->message(fd, msg_txt(149)); // Unable to decrease the number/value.
} else {
- if( (ret=pc_paycash(sd, -value, -value)) >= 0){
+ if( (ret=pc->paycash(sd, -value, -value)) >= 0){
sprintf(output, msg_txt(411), ret, sd->kafraPoints);
clif->disp_onlyself(sd, output, strlen(output));
}
@@ -7864,12 +7892,12 @@ ACMD(clone)
return true;
}
- if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
+ if((pl_sd=iMap->nick2sd((char *)message)) == NULL && (pl_sd=iMap->charid2sd(atoi(message))) == NULL) {
clif->message(fd, msg_txt(3)); // Character not found.
return true;
}
- if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
+ if(pc->get_group_level(pl_sd) > pc->get_group_level(sd)) {
clif->message(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
return true;
}
@@ -7893,7 +7921,7 @@ ACMD(clone)
do {
x = sd->bl.x + (rnd() % 10 - 5);
y = sd->bl.y + (rnd() % 10 - 5);
- } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
+ } while (iMap->getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
if (i >= 10) {
x = sd->bl.x;
@@ -7948,7 +7976,7 @@ ACMD(request)
*------------------------------------------*/
ACMD(feelreset)
{
- pc_resetfeel(sd);
+ pc->resetfeel(sd);
clif->message(fd, msg_txt(1324)); // Reset 'Feeling' maps.
return true;
@@ -8020,7 +8048,7 @@ ACMD(resetstat)
{
nullpo_retr(-1, sd);
- pc_resetstate(sd);
+ pc->resetstate(sd);
sprintf(atcmd_output, msg_txt(207), sd->status.name);
clif->message(fd, atcmd_output);
return true;
@@ -8030,7 +8058,7 @@ ACMD(resetskill)
{
nullpo_retr(-1,sd);
- pc_resetskill(sd,1);
+ pc->resetskill(sd,1);
sprintf(atcmd_output, msg_txt(206), sd->status.name);
clif->message(fd, atcmd_output);
return true;
@@ -8083,7 +8111,7 @@ ACMD(itemlist)
const struct item* it = &items[i];
struct item_data* itd;
- if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
+ if( it->nameid == 0 || (itd = itemdb->exists(it->nameid)) == NULL )
continue;
counter += it->amount;
@@ -8166,7 +8194,7 @@ ACMD(itemlist)
{
struct item_data* card;
- if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
+ if( it->card[j] == 0 || (card = itemdb->exists(it->card[j])) == NULL )
continue;
counter2++;
@@ -8252,7 +8280,7 @@ ACMD(stats)
output_table[14].value = sd->change_level_2nd;
output_table[15].value = sd->change_level_3rd;
- sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
+ sprintf(job_jobname, "Job - %s %s", pc->job_name(sd->status.class_), "(level %d)");
sprintf(output, msg_txt(53), sd->status.name); // '%s' stats:
clif->message(fd, output);
@@ -8279,7 +8307,7 @@ ACMD(delitem)
return false;
}
- if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
+ if( ( id = itemdb->search_name(item_name) ) != NULL || ( id = itemdb->exists(atoi(item_name)) ) != NULL )
{
nameid = id->nameid;
}
@@ -8292,7 +8320,7 @@ ACMD(delitem)
total = amount;
// delete items
- while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
+ while( amount && ( idx = pc->search_inventory(sd, nameid) ) != -1 )
{
int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
@@ -8300,7 +8328,7 @@ ACMD(delitem)
{// delete pet
intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
}
- pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
+ pc->delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
amount-= delamount;
}
@@ -8466,7 +8494,7 @@ ACMD(accinfo) {
//remove const type
safestrncpy(query, message, NAME_LENGTH);
- intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query );
+ intif_request_accinfo( sd->fd, sd->bl.id, pc->get_group_level(sd), query );
return true;
}
@@ -8519,7 +8547,7 @@ ACMD(set) {
switch( reg[0] ) {
case '@':
- data->u.str = pc_readregstr(sd, add_str(reg));
+ data->u.str = pc->readregstr(sd, add_str(reg));
break;
case '$':
data->u.str = mapreg_readregstr(add_str(reg));
@@ -8548,7 +8576,7 @@ ACMD(set) {
data->type = C_INT;
switch( reg[0] ) {
case '@':
- data->u.num = pc_readreg(sd, add_str(reg));
+ data->u.num = pc->readreg(sd, add_str(reg));
break;
case '$':
data->u.num = mapreg_readreg(add_str(reg));
@@ -8674,7 +8702,7 @@ sd->status.skill[idx].lv = x?1:0; \
sd->status.skill[idx].flag = x?1:0;
int val = atoi(message);
- bool need_skill = pc_checkskill(sd, MC_PUSHCART) ? false : true;
+ bool need_skill = pc->checkskill(sd, MC_PUSHCART) ? false : true;
unsigned int index = skill->get_index(MC_PUSHCART);
if( !message || !*message || val < 0 || val > MAX_CARTS ) {
@@ -8692,7 +8720,7 @@ sd->status.skill[idx].flag = x?1:0;
MC_CART_MDFY(1,index);
}
- if( pc_setcart(sd, val) ) {
+ if( pc->setcart(sd, val) ) {
if( need_skill ) {
MC_CART_MDFY(0,index);
}
@@ -9017,7 +9045,7 @@ ACMD(channel) {
return false;
}
- if( sub2[0] == '\0' || ( pl_sd = map_nick2sd(sub2) ) == NULL ) {
+ if( sub2[0] == '\0' || ( pl_sd = iMap->nick2sd(sub2) ) == NULL ) {
sprintf(atcmd_output, msg_txt(1434), sub2);// Player '%s' was not found
clif->message(fd, atcmd_output);
return false;
@@ -9073,7 +9101,7 @@ ACMD(channel) {
return false;
}
- if( sub2[0] == '\0' || ( pl_sd = map_nick2sd(sub2) ) == NULL ) {
+ if( sub2[0] == '\0' || ( pl_sd = iMap->nick2sd(sub2) ) == NULL ) {
sprintf(atcmd_output, msg_txt(1434), sub2);// Player '%s' was not found
clif->message(fd, atcmd_output);
return false;
@@ -9672,6 +9700,7 @@ void atcommand_basecommands(void) {
safestrncpy(cmd->command, atcommand_base[i].command, sizeof(cmd->command));
cmd->func = atcommand_base[i].func;
cmd->help = NULL;/* start as null dear */
+ cmd->log = true;
strdb_put(atcommand->db, cmd->command, cmd);
}
return;
@@ -9807,7 +9836,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
// 1 = player invoked
if ( type == 1) {
//Commands are disabled on maps flagged as 'nocommand'
- if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
+ if ( map[sd->bl.m].nocommand && pc->get_group_level(sd) < map[sd->bl.m].nocommand ) {
clif->message(fd, msg_txt(143));
return false;
}
@@ -9842,7 +9871,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
break;
}
- if( !pc_get_group_level(sd) ) {
+ if( !pc->get_group_level(sd) ) {
if( x >= 1 || y >= 1 ) { /* we have command */
info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
if( !info || info->char_groups[sd->group_pos] == 0 ) /* if we can't use or doesn't exist: don't even display the command failed message */
@@ -9880,15 +9909,15 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
// Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
if( binding != NULL && binding->npc_event[0] &&
- ((*atcmd_msg == atcommand->at_symbol && pc_get_group_level(sd) >= binding->group_lv) ||
- (*atcmd_msg == atcommand->char_symbol && pc_get_group_level(sd) >= binding->group_lv_char)))
+ ((*atcmd_msg == atcommand->at_symbol && pc->get_group_level(sd) >= binding->group_lv) ||
+ (*atcmd_msg == atcommand->char_symbol && pc->get_group_level(sd) >= binding->group_lv_char)))
{
// Check if self or character invoking; if self == character invoked, then self invoke.
bool invokeFlag = ((*atcmd_msg == atcommand->at_symbol) ? 1 : 0);
// Check if the command initiated is a character command
if (*message == atcommand->char_symbol &&
- (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
+ (ssd = iMap->nick2sd(charname)) == NULL && (ssd = iMap->nick2sd(charname2)) == NULL ) {
sprintf(output, msg_txt(1389), command); // %s failed. Player not found.
clif->message(fd, output);
return true;
@@ -9905,7 +9934,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
//Grab the command information and check for the proper GM level required to use it or if the command exists
info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
if (info == NULL) {
- if( pc_get_group_level(sd) ) { // TODO: remove or replace with proper permission
+ if( pc->get_group_level(sd) ) { // TODO: remove or replace with proper permission
sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
clif->message(fd, output);
atcommand_get_suggestions(sd, command + 1, *message == atcommand->at_symbol);
@@ -9938,7 +9967,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
// Check if target is valid only if confirmed that player can use command.
if (*message == atcommand->char_symbol &&
- (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
+ (ssd = iMap->nick2sd(charname)) == NULL && (ssd = iMap->nick2sd(charname2)) == NULL ) {
sprintf(output, msg_txt(1389), command); // %s failed. Player not found.
clif->message(fd, output);
return true;
@@ -10088,14 +10117,15 @@ void atcommand_db_load_groups(void) {
cmd->at_groups = aMalloc( pc_group_max * sizeof(char) );
cmd->char_groups = aMalloc( pc_group_max * sizeof(char) );
for(i = 0; i < pc_group_max; i++) {
+ int idx = pc_group_id2idx(atcommand->group_ids[i]);
if( pc_group_can_use_command(atcommand->group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
- cmd->at_groups[i] = 1;
+ cmd->at_groups[idx] = 1;
else
- cmd->at_groups[i] = 0;
+ cmd->at_groups[idx] = 0;
if( pc_group_can_use_command(atcommand->group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
- cmd->char_groups[i] = 1;
+ cmd->char_groups[idx] = 1;
else
- cmd->char_groups[i] = 0;
+ cmd->char_groups[idx] = 0;
}
}
@@ -10150,6 +10180,7 @@ bool atcommand_hp_add(char *name, AtCommandFunc func) {
safestrncpy(cmd->command, name, sizeof(cmd->command));
cmd->func = func;
cmd->help = NULL;/* start as null dear */
+ cmd->log = true;
strdb_put(atcommand->db, cmd->command, cmd);
return true;
@@ -10182,7 +10213,7 @@ void atcommand_doload(void) {
atcommand->db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
atcommand->alias_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
atcommand_basecommands(); //fills initial atcommand_db with known commands
- atcommand_config_read(ATCOMMAND_CONF_FILENAME);
+ atcommand_config_read(iMap->ATCOMMAND_CONF_FILENAME);
}
void do_init_atcommand(void) {
diff --git a/src/map/battle.c b/src/map/battle.c
index 370adcd02..65c86cefd 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -90,7 +90,7 @@ struct block_list* battle_gettargeted(struct block_list *target) {
nullpo_retr(NULL, target);
memset(bl_list, 0, sizeof(bl_list));
- map_foreachinrange(battle->get_targeted_sub, target, AREA_SIZE, BL_CHAR, bl_list, &c, target->id);
+ iMap->foreachinrange(battle->get_targeted_sub, target, AREA_SIZE, BL_CHAR, bl_list, &c, target->id);
if ( c == 0 )
return NULL;
if( c > 24 )
@@ -146,7 +146,7 @@ struct block_list* battle_getenemy(struct block_list *target, int type, int rang
int c = 0;
memset(bl_list, 0, sizeof(bl_list));
- map_foreachinrange(battle->get_enemy_sub, target, range, type, bl_list, &c, target);
+ iMap->foreachinrange(battle->get_enemy_sub, target, range, type, bl_list, &c, target);
if ( c == 0 )
return NULL;
@@ -188,7 +188,7 @@ struct block_list* battle_getenemyarea(struct block_list *src, int x, int y, int
int c = 0;
memset(bl_list, 0, sizeof(bl_list));
- map_foreachinarea(battle->get_enemy_area_sub, src->m, x - range, y - range, x + range, y + range, type, bl_list, &c, src, ignore_id);
+ iMap->foreachinarea(battle->get_enemy_area_sub, src->m, x - range, y - range, x + range, y + range, type, bl_list, &c, src, ignore_id);
if( c == 0 )
return NULL;
@@ -217,33 +217,33 @@ int battle_delay_damage_sub(int tid, unsigned int tick, int id, intptr_t data) {
if ( dat ) {
struct block_list* src;
- struct block_list* target = map_id2bl(dat->target_id);
+ struct block_list* target = iMap->id2bl(dat->target_id);
if( !target || status_isdead(target) ) {/* nothing we can do */
ers_free(delay_damage_ers, dat);
return 0;
}
- src = map_id2bl(dat->src_id);
+ src = iMap->id2bl(dat->src_id);
if( src && target->m == src->m &&
(target->type != BL_PC || ((TBL_PC*)target)->invincible_timer == INVALID_TIMER) &&
check_distance_bl(src, target, dat->distance) ) //Check to see if you haven't teleported. [Skotlex]
{
- map_freeblock_lock();
+ iMap->freeblock_lock();
status_fix_damage(src, target, dat->damage, dat->delay);
if( dat->attack_type && !status_isdead(target) && dat->additional_effects )
skill->additional_effect(src,target,dat->skill_id,dat->skill_lv,dat->attack_type,dat->dmg_lv,tick);
if( dat->dmg_lv > ATK_BLOCK && dat->attack_type )
skill->counter_additional_effect(src,target,dat->skill_id,dat->skill_lv,dat->attack_type,tick);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
} else if( !src && dat->skill_id == CR_REFLECTSHIELD ) {
/**
* it was monster reflected damage, and the monster died, we pass the damage to the character as expected
**/
- map_freeblock_lock();
+ iMap->freeblock_lock();
status_fix_damage(target, target, dat->damage, dat->delay);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
}
}
ers_free(delay_damage_ers, dat);
@@ -263,13 +263,13 @@ int battle_delay_damage (unsigned int tick, int amotion, struct block_list *src,
damage = 0;
if ( !battle_config.delay_battle_damage || amotion <= 1 ) {
- map_freeblock_lock();
+ iMap->freeblock_lock();
status_fix_damage(src, target, damage, ddelay); // We have to seperate here between reflect damage and others [icescope]
if( attack_type && !status_isdead(target) && additional_effects )
- skill->additional_effect(src, target, skill_id, skill_lv, attack_type, dmg_lv, gettick());
+ skill->additional_effect(src, target, skill_id, skill_lv, attack_type, dmg_lv, iTimer->gettick());
if( dmg_lv > ATK_BLOCK && attack_type )
- skill->counter_additional_effect(src, target, skill_id, skill_lv, attack_type, gettick());
- map_freeblock_unlock();
+ skill->counter_additional_effect(src, target, skill_id, skill_lv, attack_type, iTimer->gettick());
+ iMap->freeblock_unlock();
return 0;
}
dat = ers_alloc(delay_damage_ers, struct delay_damage);
@@ -286,7 +286,7 @@ int battle_delay_damage (unsigned int tick, int amotion, struct block_list *src,
if (src->type != BL_PC && amotion > 1000)
amotion = 1000; //Aegis places a damage-delay cap of 1 sec to non player attacks. [Skotlex]
- add_timer(tick+amotion, battle->delay_damage_sub, 0, (intptr_t)dat);
+ iTimer->add_timer(tick+amotion, battle->delay_damage_sub, 0, (intptr_t)dat);
return 0;
}
@@ -340,7 +340,7 @@ int battle_attr_fix(struct block_list *src, struct block_list *target, int damag
struct block_list *src;
if( !su || !su->alive || (sg = su->group) == NULL || !sg || sg->val3 == -1 ||
- (src = map_id2bl(sg->src_id)) == NULL || status_isdead(src) )
+ (src = iMap->id2bl(sg->src_id)) == NULL || status_isdead(src) )
return 0;
if( sg->unit_id != UNT_FIREWALL ) {
@@ -349,7 +349,7 @@ int battle_attr_fix(struct block_list *src, struct block_list *target, int damag
y = sg->val3 & 0xffff;
skill->unitsetting(src,su->group->skill_id,su->group->skill_lv,x,y,1);
sg->val3 = -1;
- sg->limit = DIFF_TICK(gettick(),sg->tick)+300;
+ sg->limit = DIFF_TICK(iTimer->gettick(),sg->tick)+300;
}
}
}
@@ -363,14 +363,14 @@ int battle_attr_fix(struct block_list *src, struct block_list *target, int damag
if( tsc->data[SC_SPIDERWEB]->val2 == 0 )
status_change_end(target, SC_SPIDERWEB, INVALID_TIMER);
}
- if( tsc->data[SC_THORNSTRAP])
- status_change_end(target, SC_THORNSTRAP, INVALID_TIMER);
+ if( tsc->data[SC_THORNS_TRAP])
+ status_change_end(target, SC_THORNS_TRAP, INVALID_TIMER);
if( tsc->data[SC_FIRE_CLOAK_OPTION])
damage -= damage * tsc->data[SC_FIRE_CLOAK_OPTION]->val2 / 100;
if( tsc->data[SC_CRYSTALIZE] && target->type != BL_MOB)
status_change_end(target, SC_CRYSTALIZE, INVALID_TIMER);
if( tsc->data[SC_EARTH_INSIGNIA]) damage += damage/2;
- if( tsc->data[SC_ASH]) damage += damage/2; //150%
+ if( tsc->data[SC_VOLCANIC_ASH]) damage += damage/2; //150%
break;
case ELE_HOLY:
if( tsc->data[SC_ORATIO]) ratio += tsc->data[SC_ORATIO]->val1 * 2;
@@ -394,23 +394,458 @@ int battle_attr_fix(struct block_list *src, struct block_list *target, int damag
struct map_session_data *sd = BL_CAST(BL_PC, src);
int s;
- ARR_FIND(1, 6, s, sd->talisman[s] > 0);
+ ARR_FIND(1, 6, s, sd->charm[s] > 0);
if( s < 5 && atk_elem == s )
- ratio += sd->talisman[s] * 2; // +2% custom value
+ ratio += sd->charm[s] * 2; // +2% custom value
}
if( target && target->type == BL_PC ) {
struct map_session_data *tsd = BL_CAST(BL_PC, target);
int t;
- ARR_FIND(1, 6, t, tsd->talisman[t] > 0);
+ ARR_FIND(1, 6, t, tsd->charm[t] > 0);
if( t < 5 && atk_elem == t )
- damage -= damage * ( tsd->talisman[t] * 3 ) / 100;// -3% custom value
+ damage -= damage * ( tsd->charm[t] * 3 ) / 100;// -3% custom value
}
return damage*ratio/100;
}
+#ifdef RENEWAL
+int battle_calc_weapon_damage(struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, struct weapon_atk *watk, int nk, bool n_ele, short s_ele, short s_ele_, int size, int type, int flag, int flag2){ // [malufett]
+ int damage, eatk = 0;
+ struct status_change *sc;
+ struct map_session_data *sd;
+
+ if( !src || !bl )
+ return 0;
+ sc = status_get_sc(src);
+ sd = BL_CAST(BL_PC, src);
+
+ damage = status_get_weapon_atk(src, watk, flag);
+
+ if( sd ){
+ if( type == EQI_HAND_R )
+ damage = battle->calc_sizefix(sd, damage, EQI_HAND_R, size, flag&8);
+ else
+ damage = battle->calc_sizefix(sd, damage, EQI_HAND_L, size, flag&8);
+
+ if( sd->bonus.eatk > 0 )
+ eatk = sd->bonus.eatk;
+ if( flag&2 && sd->bonus.arrow_atk )
+ eatk += sd->bonus.arrow_atk;
+ }
+
+ if( sc && sc->count ){
+ if( sc->data[SC_ZENKAI] && watk->ele == sc->data[SC_ZENKAI]->val2 )
+ eatk += 200;
+ #ifdef RENEWAL_EDP
+ if( sc->data[SC_EDP] && skill_id != AS_GRIMTOOTH && skill_id != AS_VENOMKNIFE ){
+ eatk = eatk * sc->data[SC_EDP]->val3 / 100; // 400%
+ damage = damage * sc->data[SC_EDP]->val4 / 100; // 500%
+ damage--; // temporary until we find the correct formula [malufett]
+ }
+ #endif
+ }
+
+ /* [malufett]
+ some unknown factors that needs to be discovered. PS: it's something related with ranged attacks
+ if( eatk ){
+ eatk += unknown value;
+ eatk = eatk * (unknown value) / 100;
+ }
+ */
+
+ if( sc && sc->data[SC_WATK_ELEMENT] )
+ damage = damage + eatk;
+ else
+ damage = battle->calc_elefix(src, bl, skill_id, skill_lv, damage + eatk, nk, n_ele, s_ele, s_ele_, false, flag);
+
+ /**
+ * In RE Shield Bommerang takes weapon element only for damage calculation,
+ * - resist calculation is always against neutral
+ **/
+ if ( skill_id == CR_SHIELDBOOMERANG )
+ s_ele = s_ele_ = ELE_NEUTRAL;
+
+ if( type == EQI_HAND_R )
+ damage = battle->calc_cardfix(BF_WEAPON, src, bl, nk, s_ele, s_ele_, damage, 2, flag2);
+ else
+ damage = battle->calc_cardfix(BF_WEAPON, src, bl, nk, s_ele, s_ele_, damage, 3, flag2);
+
+ return damage;
+}
+#endif
+/*==========================================
+ * Calculates the standard damage of a normal attack assuming it hits,
+ * it calculates nothing extra fancy, is needed for magnum break's WATK_ELEMENT bonus. [Skotlex]
+ *------------------------------------------
+ * Pass damage2 as NULL to not calc it.
+ * Flag values:
+ * &1: Critical hit
+ * &2: Arrow attack
+ * &4: Skill is Magic Crasher
+ * &8: Skip target size adjustment (Extremity Fist?)
+ *&16: Arrow attack but BOW, REVOLVER, RIFLE, SHOTGUN, GATLING or GRENADE type weapon not equipped (i.e. shuriken, kunai and venom knives not affected by DEX)
+ */
+/* modifying until malufett is able to adjust the formula */
+//#ifdef RENEWAL
+#if 0
+int battle_calc_base_damage(struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int nk, bool n_ele, short s_ele, short s_ele_, int type, int flag, int flag2)
+{
+ int damage, batk;
+ struct status_change *sc = status_get_sc(src);
+ struct status_data *status = status_get_status_data(src);
+
+ if( sc && sc->data[SC_TK_SEVENWIND] && !sc->data[SC_WATK_ELEMENT] )
+ batk = battle->calc_elefix(src, bl, skill_id, skill_lv, status->batk, nk, n_ele, s_ele, s_ele_, false, flag);
+ else
+ batk = status->batk;
+
+ if( type == EQI_HAND_L )
+ damage = batk + 3 * battle->calc_weapon_damage(src, bl, skill_id, skill_lv, &status->lhw, nk, n_ele, s_ele, s_ele_, status_get_size(bl), type, flag, flag2) / 4;
+ else
+ damage = (batk << 1) + battle->calc_weapon_damage(src, bl, skill_id, skill_lv, &status->rhw, nk, n_ele, s_ele, s_ele_, status_get_size(bl), type, flag, flag2);
+#else
+static int battle_calc_base_damage(struct status_data *status, struct weapon_atk *wa, struct status_change *sc, unsigned short t_size, struct map_session_data *sd, int flag)
+{
+ unsigned int atkmin=0, atkmax=0;
+ short type = 0;
+ int damage = 0;
+
+ if (!sd) { //Mobs/Pets
+ if(flag&4) {
+ atkmin = status->matk_min;
+ atkmax = status->matk_max;
+ } else {
+ atkmin = wa->atk;
+ atkmax = wa->atk2;
+ }
+ if (atkmin > atkmax)
+ atkmin = atkmax;
+ } else { //PCs
+ atkmax = wa->atk;
+ type = (wa == &status->lhw)?EQI_HAND_L:EQI_HAND_R;
+
+ if (!(flag&1) || (flag&2)) { //Normal attacks
+ atkmin = status->dex;
+
+ if (sd->equip_index[type] >= 0 && sd->inventory_data[sd->equip_index[type]])
+ atkmin = atkmin*(80 + sd->inventory_data[sd->equip_index[type]]->wlv*20)/100;
+
+ if (atkmin > atkmax)
+ atkmin = atkmax;
+
+ if(flag&2 && !(flag&16)) { //Bows
+ atkmin = atkmin*atkmax/100;
+ if (atkmin > atkmax)
+ atkmax = atkmin;
+ }
+ }
+ }
+
+ if (sc && sc->data[SC_MAXIMIZEPOWER])
+ atkmin = atkmax;
+
+ //Weapon Damage calculation
+ if (!(flag&1))
+ damage = (atkmax>atkmin? rnd()%(atkmax-atkmin):0)+atkmin;
+ else
+ damage = atkmax;
+
+ if (sd) {
+ //rodatazone says the range is 0~arrow_atk-1 for non crit
+ if (flag&2 && sd->bonus.arrow_atk)
+ damage += ( (flag&1) ? sd->bonus.arrow_atk : rnd()%sd->bonus.arrow_atk );
+
+ //SizeFix only for players
+ if (!(sd->special_state.no_sizefix || (flag&8)))
+ damage = damage * ( type == EQI_HAND_L ? sd->left_weapon.atkmods[t_size] : sd->right_weapon.atkmods[t_size] ) / 100;
+ }
+
+ //Finally, add baseatk
+ if(flag&4)
+ damage += status->matk_min;
+ else
+ damage += status->batk;
+
+ //rodatazone says that Overrefine bonuses are part of baseatk
+ //Here we also apply the weapon_atk_rate bonus so it is correctly applied on left/right hands.
+ if(sd) {
+ if (type == EQI_HAND_L) {
+ if(sd->left_weapon.overrefine)
+ damage += rnd()%sd->left_weapon.overrefine+1;
+ if (sd->weapon_atk_rate[sd->weapontype2])
+ damage += damage * sd->weapon_atk_rate[sd->weapontype2] / 100;
+ } else { //Right hand
+ if(sd->right_weapon.overrefine)
+ damage += rnd()%sd->right_weapon.overrefine+1;
+ if (sd->weapon_atk_rate[sd->weapontype1])
+ damage += damage * sd->weapon_atk_rate[sd->weapontype1] / 100;
+ }
+ }
+#endif
+ return damage;
+}
+
+int battle_calc_sizefix(struct map_session_data *sd, int damage, int type, int size, bool ignore){
+ //SizeFix only for players
+ if (!(sd->special_state.no_sizefix || (ignore)))
+ damage = damage * ( type == EQI_HAND_L ? sd->left_weapon.atkmods[size] : sd->right_weapon.atkmods[size] ) / 100;
+ return damage;
+}
+
+/*==========================================
+ * Passive skill damages increases
+ *------------------------------------------*/
+int battle_addmastery(struct map_session_data *sd,struct block_list *target,int dmg,int type)
+{
+ int damage,skill;
+ struct status_data *status = status_get_status_data(target);
+ int weapon;
+ damage = dmg;
+
+ nullpo_ret(sd);
+
+ if((skill = pc->checkskill(sd,AL_DEMONBANE)) > 0 &&
+ target->type == BL_MOB && //This bonus doesnt work against players.
+ (battle->check_undead(status->race,status->def_ele) || status->race==RC_DEMON) )
+ damage += (int)(skill*(3+sd->status.base_level/20.0));
+ //damage += (skill * 3);
+ if( (skill = pc->checkskill(sd, RA_RANGERMAIN)) > 0 && (status->race == RC_BRUTE || status->race == RC_PLANT || status->race == RC_FISH) )
+ damage += (skill * 5);
+ if( (skill = pc->checkskill(sd,NC_RESEARCHFE)) > 0 && (status->def_ele == ELE_FIRE || status->def_ele == ELE_EARTH) )
+ damage += (skill * 10);
+ if( pc_ismadogear(sd) )
+ damage += 20 + 20 * pc->checkskill(sd, NC_MADOLICENCE);
+#ifdef RENEWAL
+ if( (skill = pc->checkskill(sd,BS_WEAPONRESEARCH)) > 0 )
+ damage += (skill * 2);
+#endif
+ if((skill = pc->checkskill(sd,HT_BEASTBANE)) > 0 && (status->race==RC_BRUTE || status->race==RC_INSECT) ) {
+ damage += (skill * 4);
+ if (sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_HUNTER)
+ damage += sd->status.str;
+ }
+
+ if(type == 0)
+ weapon = sd->weapontype1;
+ else
+ weapon = sd->weapontype2;
+ switch(weapon)
+ {
+ case W_1HSWORD:
+ #ifdef RENEWAL
+ if((skill = pc->checkskill(sd,AM_AXEMASTERY)) > 0)
+ damage += (skill * 3);
+ #endif
+ case W_DAGGER:
+ if((skill = pc->checkskill(sd,SM_SWORD)) > 0)
+ damage += (skill * 4);
+ if((skill = pc->checkskill(sd,GN_TRAINING_SWORD)) > 0)
+ damage += skill * 10;
+ break;
+ case W_2HSWORD:
+ #ifdef RENEWAL
+ if((skill = pc->checkskill(sd,AM_AXEMASTERY)) > 0)
+ damage += (skill * 3);
+ #endif
+ if((skill = pc->checkskill(sd,SM_TWOHAND)) > 0)
+ damage += (skill * 4);
+ break;
+ case W_1HSPEAR:
+ case W_2HSPEAR:
+ if((skill = pc->checkskill(sd,KN_SPEARMASTERY)) > 0) {
+
+ if(!pc_isriding(sd))
+ damage += (skill * 4);
+ else if(pc_isridingdragon(sd))
+ damage += (skill * 10);
+ else
+ damage += (skill * 5);
+ }
+ break;
+ case W_1HAXE:
+ case W_2HAXE:
+ if((skill = pc->checkskill(sd,AM_AXEMASTERY)) > 0)
+ damage += (skill * 3);
+ if((skill = pc->checkskill(sd,NC_TRAININGAXE)) > 0)
+ damage += (skill * 5);
+ break;
+ case W_MACE:
+ case W_2HMACE:
+ if((skill = pc->checkskill(sd,PR_MACEMASTERY)) > 0)
+ damage += (skill * 3);
+ if((skill = pc->checkskill(sd,NC_TRAININGAXE)) > 0)
+ damage += (skill * 5);
+ break;
+ case W_FIST:
+ if((skill = pc->checkskill(sd,TK_RUN)) > 0)
+ damage += (skill * 10);
+ // No break, fallthrough to Knuckles
+ case W_KNUCKLE:
+ if((skill = pc->checkskill(sd,MO_IRONHAND)) > 0)
+ damage += (skill * 3);
+ break;
+ case W_MUSICAL:
+ if((skill = pc->checkskill(sd,BA_MUSICALLESSON)) > 0)
+ damage += (skill * 3);
+ break;
+ case W_WHIP:
+ if((skill = pc->checkskill(sd,DC_DANCINGLESSON)) > 0)
+ damage += (skill * 3);
+ break;
+ case W_BOOK:
+ if((skill = pc->checkskill(sd,SA_ADVANCEDBOOK)) > 0)
+ damage += (skill * 3);
+ break;
+ case W_KATAR:
+ if((skill = pc->checkskill(sd,AS_KATAR)) > 0)
+ damage += (skill * 3);
+ break;
+ }
+
+ return damage;
+}
+
+/*==========================================
+ * Calculates ATK masteries.
+ *------------------------------------------*/
+int battle_calc_masteryfix(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int damage, int div, bool left, bool weapon){
+ int skill, i;
+ struct map_session_data *sd;
+ struct status_change *sc;
+
+ nullpo_ret(src);
+ nullpo_ret(target);
+
+ sd = BL_CAST(BL_PC, src);
+ sc = status_get_sc(src);
+
+ if ( !sd )
+ return damage;
+
+ switch( skill_id ){ // specific skill masteries
+ case MO_INVESTIGATE:
+ case MO_EXTREMITYFIST:
+ case CR_GRANDCROSS:
+ case NJ_ISSEN:
+ case CR_ACIDDEMONSTRATION:
+ return damage;
+ case NJ_SYURIKEN:
+ if( (skill = pc->checkskill(sd,NJ_TOBIDOUGU)) > 0 && weapon )
+ damage += 3 * skill;
+ break;
+ case NJ_KUNAI:
+ if( weapon )
+ damage += 60;
+ break;
+ case RA_WUGDASH:
+ case RA_WUGSTRIKE:
+ case RA_WUGBITE:
+ damage += 30*pc->checkskill(sd, RA_TOOTHOFWUG);
+ break;
+ }
+
+ if ( sc && sc->data[SC_MIRACLE] ) i = 2; //Star anger
+ else
+ ARR_FIND(0, MAX_PC_FEELHATE, i, status_get_class(target) == sd->hate_mob[i]);
+ if ( i < MAX_PC_FEELHATE && (skill=pc->checkskill(sd,sg_info[i].anger_id)) && weapon ){
+ int ratio = sd->status.base_level + status_get_dex(src) + status_get_luk(src);
+ if ( i == 2 ) ratio += status_get_str(src); //Star Anger
+ if (skill < 4 )
+ ratio /= (12 - 3 * skill);
+ damage += damage * ratio / 100;
+ }
+
+ if( sc ){
+ if(sc->data[SC_GN_CARTBOOST])
+ damage += 10 * sc->data[SC_GN_CARTBOOST]->val1;
+ if(sc->data[SC_CAMOUFLAGE])
+ damage += 30 * ( 10 - sc->data[SC_CAMOUFLAGE]->val4 );
+ }
+
+ // general skill masteries
+#ifdef RENEWAL
+ if( skill_id == MO_FINGEROFFENSIVE )//The finger offensive spheres on moment of attack do count. [Skotlex]
+ damage += div * sd->spiritball_old * 3;
+ else
+ damage += div * sd->spiritball * 3;
+ if( skill_id != CR_SHIELDBOOMERANG ) // Only Shield boomerang doesn't takes the Star Crumbs bonus.
+ damage += div * (left ? sd->left_weapon.star : sd->right_weapon.star);
+#else
+ if( skill_id != ASC_BREAKER && weapon ) // Adv Katar Mastery is does not applies to ASC_BREAKER, but other masteries DO apply >_>
+ if( sd->status.weapon == W_KATAR && (skill=pc->checkskill(sd,ASC_KATAR)) > 0 )
+ damage += damage * (10 + 2 * skill) / 100;
+#endif
+
+
+ damage = battle->add_mastery(sd, target, damage, left);
+
+ if((skill = pc->checkskill(sd,AB_EUCHARISTICA)) > 0 &&
+ (status_get_status_data(target)->race == RC_DEMON || status_get_status_data(target)->def_ele == ELE_DARK) )
+ damage += damage * skill / 100;
+
+ return damage;
+}
+/*==========================================
+ * Elemental attribute fix.
+ *------------------------------------------*/
+int battle_calc_elefix(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int damage, int nk, int n_ele, int s_ele, int s_ele_, bool left, int flag){
+ struct status_data *sstatus, *tstatus;
+ struct status_change *sc;
+
+ nullpo_ret(src);
+ nullpo_ret(target);
+
+ sstatus = status_get_status_data(src);
+ tstatus = status_get_status_data(target);
+ sc = status_get_sc(src);
+
+ if( (nk&NK_NO_ELEFIX) && n_ele )
+ return damage;
+
+ if( damage > 0 )
+ {
+ if( left )
+ damage = battle->attr_fix(src, target, damage, s_ele_, tstatus->def_ele, tstatus->ele_lv);
+ else{
+ damage=battle->attr_fix(src, target, damage, s_ele, tstatus->def_ele, tstatus->ele_lv);
+ if( skill_id == MC_CARTREVOLUTION ) //Cart Revolution applies the element fix once more with neutral element
+ damage = battle->attr_fix(src,target,damage,ELE_NEUTRAL,tstatus->def_ele, tstatus->ele_lv);
+ if( skill_id == GS_GROUNDDRIFT ) //Additional 50*lv Neutral damage.
+ damage += battle_attr_fix(src,target,50*skill_lv,ELE_NEUTRAL,tstatus->def_ele, tstatus->ele_lv);
+ }
+ }
+ if( sc && sc->data[SC_WATK_ELEMENT] )
+ { // Descriptions indicate this means adding a percent of a normal attack in another element. [Skotlex]
+ damage =
+/* modifying until malufett can adjust the formula */
+//#ifndef RENEWAL
+#if 1
+ battle->calc_base_damage(sstatus, &sstatus->rhw, sc, tstatus->size, BL_CAST(BL_PC, src), (flag?2:0))
+#else
+ battle->calc_base_damage(src, target, skill_id, skill_lv, nk, n_ele, s_ele, s_ele_, EQI_HAND_R, (flag?2:0)|(sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0), 0)
+#endif
+ * sc->data[SC_WATK_ELEMENT]->val2 / 100;
+
+ damage += battle->attr_fix(src, target, damage, sc->data[SC_WATK_ELEMENT]->val1, tstatus->def_ele, tstatus->ele_lv);
+ if( left ){
+ damage =
+/* modifying until malufett can adjust the formula */
+//#ifndef RENEWAL
+#if 1
+ battle->calc_base_damage(sstatus, &sstatus->lhw, sc, tstatus->size, BL_CAST(BL_PC, src), (flag?2:0))
+#else
+ battle->calc_base_damage(src, target, skill_id, skill_lv, nk, n_ele, s_ele, s_ele_, EQI_HAND_L, (flag?2:0)|(sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0), 0)
+#endif
+ * sc->data[SC_WATK_ELEMENT]->val2 / 100;
+ damage += battle->attr_fix(src, target, damage, sc->data[SC_WATK_ELEMENT]->val1, tstatus->def_ele, tstatus->ele_lv);
+ }
+ }
+
+ return damage;
+}
/*==========================================
* Calculates card bonuses damage adjustments.
*------------------------------------------*/
@@ -422,6 +857,9 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li
if( !damage )
return 0;
+
+ nullpo_ret(src);
+ nullpo_ret(target);
sd = BL_CAST(BL_PC, src);
tsd = BL_CAST(BL_PC, target);
@@ -430,7 +868,7 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li
sstatus = status_get_status_data(src);
tstatus = status_get_status_data(target);
s_race2 = status_get_race2(src);
-
+
switch(attack_type){
case BF_MAGIC:
if ( sd && !(nk&NK_NO_CARDFIX_ATK) ) {
@@ -487,8 +925,8 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li
cardfix = cardfix * ( 100 - tsd->bonus.magic_def_rate ) / 100;
- if( tsd->sc.data[SC_MDEF_RATE] )
- cardfix = cardfix * ( 100 - tsd->sc.data[SC_MDEF_RATE]->val1 ) / 100;
+ if( tsd->sc.data[SC_PROTECT_MDEF] )
+ cardfix = cardfix * ( 100 - tsd->sc.data[SC_PROTECT_MDEF]->val1 ) / 100;
if (cardfix != 1000)
damage = damage * cardfix / 1000;
@@ -618,18 +1056,12 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li
if( flag&BF_LONG )
cardfix = cardfix * ( 100 + sd->bonus.long_attack_atk_rate ) / 100;
-#ifdef RENEWAL_EDP
- if( sd->sc.data[SC_EDP] ){
- cardfix = cardfix * (100 + sd->sc.data[SC_EDP]->val1 * 60 ) / 100;
- cardfix_ = cardfix_ * (100 + sd->sc.data[SC_EDP]->val1 * 60 ) / 100;
- }
-#endif
if( (left&1) && cardfix_ != 1000 )
damage = damage * cardfix_ / 1000;
else if( cardfix != 1000 )
damage = damage * cardfix / 1000;
- }else if( tsd && !(nk&NK_NO_CARDFIX_DEF) ){
+ } else if( tsd && !(nk&NK_NO_CARDFIX_DEF) && !(left&2) ){
if( !(nk&NK_NO_ELEFIX) )
{
int ele_fix = tsd->subele[s_ele];
@@ -677,8 +1109,8 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li
else // BF_LONG (there's no other choice)
cardfix = cardfix * ( 100 - tsd->bonus.long_attack_def_rate ) / 100;
- if( tsd->sc.data[SC_DEF_RATE] )
- cardfix = cardfix * ( 100 - tsd->sc.data[SC_DEF_RATE]->val1 ) / 100;
+ if( tsd->sc.data[SC_PROTECT_DEF] )
+ cardfix = cardfix * ( 100 - tsd->sc.data[SC_PROTECT_DEF]->val1 ) / 100;
if( cardfix != 1000 )
damage = damage * cardfix / 1000;
@@ -714,7 +1146,7 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li
else // BF_LONG (there's no other choice)
cardfix = cardfix * ( 100 - tsd->bonus.long_attack_def_rate ) / 100;
- if (cardfix != 10000)
+ if (cardfix != 1000)
damage = damage * cardfix / 1000;
}
break;
@@ -724,6 +1156,1323 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li
}
/*==========================================
+ * Calculates defense reduction. [malufett]
+ * flag:
+ * &1 - idef/imdef(Ignore defense)
+ * &2 - pdef(Pierce defense)
+ * &4 - tdef(Total defense reduction)
+ *------------------------------------------*/
+int battle_calc_defense(int attack_type, struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int damage, int flag, int pdef){
+ struct status_data *sstatus, *tstatus;
+ struct map_session_data *sd, *tsd;
+ struct status_change *sc, *tsc;
+ int i;
+
+ if( !damage )
+ return 0;
+
+ nullpo_ret(src);
+ nullpo_ret(target);
+
+ sd = BL_CAST(BL_PC, src);
+ tsd = BL_CAST(BL_PC, target);
+ sstatus = status_get_status_data(src);
+ tstatus = status_get_status_data(target);
+ sc = status_get_sc(src);
+ tsc = status_get_sc(target);
+
+ switch(attack_type){
+ case BF_WEAPON:
+ {
+ /** Take note in RE
+ * def1 = equip def
+ * def2 = status def
+ **/
+ defType def1 = status_get_def(target); //Don't use tstatus->def1 due to skill timer reductions.
+ short def2 = tstatus->def2, vit_def;
+#ifdef RENEWAL
+ def1 = status_calc_def2(target, tsc, def1, false); // equip def(RE)
+ def2 = status_calc_def(target, tsc, def2, false); // status def(RE)
+#else
+ def1 = status_calc_def(target, tsc, def1, false); // equip def(RE)
+ def2 = status_calc_def2(target, tsc, def2, false); // status def(RE)
+#endif
+
+ if( sd ){
+ i = sd->ignore_def[is_boss(target)?RC_BOSS:RC_NONBOSS];
+ i += sd->ignore_def[tstatus->race];
+ if( i ){
+ if( i > 100 ) i = 100;
+ def1 -= def1 * i / 100;
+ def2 -= def2 * i / 100;
+ }
+ }
+
+ if( sc && sc->data[SC_EXPIATIO] ){
+ i = 5 * sc->data[SC_EXPIATIO]->val1; // 5% per level
+ def1 -= def1 * i / 100;
+ def2 -= def2 * i / 100;
+ }
+
+ if( battle_config.vit_penalty_type && battle_config.vit_penalty_target&target->type ) {
+ unsigned char target_count; //256 max targets should be a sane max
+ target_count = unit_counttargeted(target);
+ if(target_count >= battle_config.vit_penalty_count) {
+ if(battle_config.vit_penalty_type == 1) {
+ if( !tsc || !tsc->data[SC_STEELBODY] )
+ def1 = (def1 * (100 - (target_count - (battle_config.vit_penalty_count - 1))*battle_config.vit_penalty_num))/100;
+ def2 = (def2 * (100 - (target_count - (battle_config.vit_penalty_count - 1))*battle_config.vit_penalty_num))/100;
+ } else { //Assume type 2
+ if( !tsc || !tsc->data[SC_STEELBODY] )
+ def1 -= (target_count - (battle_config.vit_penalty_count - 1))*battle_config.vit_penalty_num;
+ def2 -= (target_count - (battle_config.vit_penalty_count - 1))*battle_config.vit_penalty_num;
+ }
+ }
+ if(skill_id == AM_ACIDTERROR) def1 = 0; //Acid Terror ignores only armor defense. [Skotlex]
+ if(def2 < 1) def2 = 1;
+ }
+ //Vitality reduction from rodatazone: http://rodatazone.simgaming.net/mechanics/substats.php#def
+ if (tsd) //Sd vit-eq
+ {
+#ifndef RENEWAL
+ //[VIT*0.5] + rnd([VIT*0.3], max([VIT*0.3],[VIT^2/150]-1))
+ vit_def = def2*(def2-15)/150;
+ vit_def = def2/2 + (vit_def>0?rnd()%vit_def:0);
+#else
+ vit_def = def2;
+#endif
+ if((battle->check_undead(sstatus->race,sstatus->def_ele) || sstatus->race==RC_DEMON) && //This bonus already doesnt work vs players
+ src->type == BL_MOB && (i=pc->checkskill(tsd,AL_DP)) > 0)
+ vit_def += i*(int)(3 +(tsd->status.base_level+1)*0.04); // submitted by orn
+ if( src->type == BL_MOB && (i=pc->checkskill(tsd,RA_RANGERMAIN))>0 &&
+ (sstatus->race == RC_BRUTE || sstatus->race == RC_FISH || sstatus->race == RC_PLANT) )
+ vit_def += i*5;
+ }
+ else { //Mob-Pet vit-eq
+#ifndef RENEWAL
+ //VIT + rnd(0,[VIT/20]^2-1)
+ vit_def = (def2/20)*(def2/20);
+ vit_def = def2 + (vit_def>0?rnd()%vit_def:0);
+#else
+ vit_def = def2;
+#endif
+ }
+
+ if (battle_config.weapon_defense_type) {
+ vit_def += def1*battle_config.weapon_defense_type;
+ def1 = 0;
+ }
+ #ifdef RENEWAL
+ /**
+ * RE DEF Reduction
+ * Damage = Attack * (4000+eDEF)/(4000+eDEF*10) - sDEF
+ * Pierce defence gains 1 atk per def/2
+ **/
+
+ if( def1 == -400 ) /* being hit by a gazillion units, you hit the jackpot and got -400 which creates a division by 0 and subsequently crashes */
+ def1 = -399;
+
+ if( flag&2 )
+ damage += def1 >> 1;
+
+ if( !(flag&1) && !(flag&2) ) {
+ if( flag&4 )
+ damage -= (def1 + vit_def);
+ else
+ damage = damage * (4000+def1) / (4000+10*def1) - vit_def;
+ }
+
+ #else
+ if( def1 > 100 ) def1 = 100;
+ if( !(flag&1) ){
+ if( flag&2 )
+ damage = damage * pdef * (def1+vit_def) / 100;
+ else
+ damage = damage * (100-def1) / 100;
+ }
+ if( !(flag&1 || flag&2) )
+ damage -= vit_def;
+ #endif
+ }
+ break;
+
+ case BF_MAGIC:
+ {
+ defType mdef = tstatus->mdef;
+ short mdef2= tstatus->mdef2;
+#ifdef RENEWAL
+ mdef2 = status_calc_mdef(target, tsc, mdef2, false); // status mdef(RE)
+ mdef = status_calc_mdef2(target, tsc, mdef, false); // equip mde(RE)
+#else
+ mdef2 = status_calc_mdef2(target, tsc, mdef2, false); // status mdef(RE)
+ mdef = status_calc_mdef(target, tsc, mdef, false); // equip mde(RE)
+#endif
+ if( flag&1 )
+ mdef = 0;
+
+ if(sd) {
+ i = sd->ignore_mdef[is_boss(target)?RC_BOSS:RC_NONBOSS];
+ i += sd->ignore_mdef[tstatus->race];
+ if (i)
+ {
+ if (i > 100) i = 100;
+ mdef -= mdef * i/100;
+ //mdef2-= mdef2* i/100;
+ }
+ }
+ #ifdef RENEWAL
+ /**
+ * RE MDEF Reduction
+ * Damage = Magic Attack * (1000+eMDEF)/(1000+eMDEF) - sMDEF
+ **/
+ damage = damage * (1000 + mdef) / (1000 + mdef * 10) - mdef2;
+ #else
+ if(battle_config.magic_defense_type)
+ damage = damage - mdef*battle_config.magic_defense_type - mdef2;
+ else
+ damage = damage * (100-mdef)/100 - mdef2;
+ #endif
+ }
+ break;
+ }
+ return damage;
+}
+
+int battle_calc_skillratio(int attack_type, struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int skillratio, int flag){
+ int i, addedratio;
+ struct status_change *sc, *tsc;
+ struct map_session_data *sd, *tsd;
+ struct status_data *status, *tstatus;
+
+ nullpo_ret(src);
+ nullpo_ret(target);
+
+ sd = BL_CAST(BL_PC, src);
+ tsd = BL_CAST(BL_PC, target);
+ sc = status_get_sc(src);
+ tsc = status_get_sc(target);
+ status = status_get_status_data(src);
+ tstatus = status_get_status_data(target);
+
+ addedratio = skillratio - 100;
+
+ switch(attack_type){
+ case BF_MAGIC:
+ switch(skill_id){
+ case MG_NAPALMBEAT:
+ skillratio += skill_lv * 10 - 30;
+ break;
+ case MG_FIREBALL:
+ #ifdef RENEWAL
+ skillratio += 20 * skill_lv;
+ #else
+ skillratio += skill_lv * 10 - 30;
+ #endif
+ break;
+ case MG_SOULSTRIKE:
+ if (battle->check_undead(tstatus->race,tstatus->def_ele))
+ skillratio += 5*skill_lv;
+ break;
+ case MG_FIREWALL:
+ skillratio -= 50;
+ break;
+ case MG_THUNDERSTORM:
+ /**
+ * in Renewal Thunder Storm boost is 100% (in pre-re, 80%)
+ **/
+ #ifndef RENEWAL
+ skillratio -= 20;
+ #endif
+ break;
+ case MG_FROSTDIVER:
+ skillratio += 10 * skill_lv;
+ break;
+ case AL_HOLYLIGHT:
+ skillratio += 25;
+ if (sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_PRIEST)
+ skillratio *= 5; //Does 5x damage include bonuses from other skills?
+ break;
+ case AL_RUWACH:
+ skillratio += 45;
+ break;
+ case WZ_FROSTNOVA:
+ skillratio += (100+skill_lv*10) * 2 / 3 - 100;
+ break;
+ case WZ_FIREPILLAR:
+ if (skill_lv > 10)
+ skillratio += 100;
+ else
+ skillratio -= 80;
+ break;
+ case WZ_SIGHTRASHER:
+ skillratio += 20 * skill_lv;
+ break;
+ case WZ_WATERBALL:
+ skillratio += 30 * skill_lv;
+ break;
+ case WZ_STORMGUST:
+ skillratio += 40 * skill_lv;
+ break;
+ case HW_NAPALMVULCAN:
+ skillratio += 10 * skill_lv - 30;
+ break;
+ case SL_STIN:
+ skillratio += (tstatus->size!=SZ_SMALL?-99:10*skill_lv); //target size must be small (0) for full damage.
+ break;
+ case SL_STUN:
+ skillratio += (tstatus->size!=SZ_BIG?5*skill_lv:-99); //Full damage is dealt on small/medium targets
+ break;
+ case SL_SMA:
+ skillratio += -60 + status_get_lv(src); //Base damage is 40% + lv%
+ break;
+ case NJ_KOUENKA:
+ skillratio -= 10;
+ break;
+ case NJ_KAENSIN:
+ skillratio -= 50;
+ break;
+ case NJ_BAKUENRYU:
+ skillratio += 50 * (skill_lv-1);
+ break;
+ case NJ_HYOUSYOURAKU:
+ skillratio += 50 * skill_lv;
+ break;
+ case NJ_RAIGEKISAI:
+ skillratio += 60 + 40 * skill_lv;
+ break;
+ case NJ_KAMAITACHI:
+ case NPC_ENERGYDRAIN:
+ skillratio += 100 * skill_lv;
+ break;
+ case NPC_EARTHQUAKE:
+ skillratio += 100 + 100 * skill_lv + 100 * (skill_lv/2);
+ break;
+ #ifdef RENEWAL
+ case WZ_HEAVENDRIVE:
+ case WZ_METEOR:
+ skillratio += 25;
+ break;
+ case WZ_VERMILION:
+ {
+ int interval = 0, per = interval, ratio = per;
+ while( (per++) < skill_lv ){
+ ratio += interval;
+ if(per%3==0) interval += 20;
+ }
+ if( skill_lv > 9 )
+ ratio -= 10;
+ skillratio += ratio;
+ }
+ break;
+ case NJ_HUUJIN:
+ skillratio += 50;
+ break;
+ #else
+ case WZ_VERMILION:
+ skillratio += 20*skill_lv-20;
+ break;
+ #endif
+ /**
+ * Arch Bishop
+ **/
+ case AB_JUDEX:
+ skillratio += 180 + 20 * skill_lv;
+ if (skill_lv > 4) skillratio += 20;
+ RE_LVL_DMOD(100);
+ break;
+ case AB_ADORAMUS:
+ skillratio += 400 + 100 * skill_lv;
+ RE_LVL_DMOD(100);
+ break;
+ case AB_DUPLELIGHT_MAGIC:
+ skillratio += 100 + 20 * skill_lv;
+ break;
+ /**
+ * Warlock
+ **/
+ case WL_SOULEXPANSION: // MATK [{( Skill Level + 4 ) x 100 ) + ( Caster?s INT )} x ( Caster?s Base Level / 100 )] %
+ skillratio += 300 + 100 * skill_lv + status_get_int(src);
+ RE_LVL_DMOD(100);
+ break;
+ case WL_FROSTMISTY: // MATK [{( Skill Level x 100 ) + 200 } x ( Caster’s Base Level / 100 )] %
+ skillratio += 100 + 100 * skill_lv;
+ RE_LVL_DMOD(100);
+ break;
+ case WL_JACKFROST:
+ if( tsc && tsc->data[SC_FROSTMISTY] ){
+ skillratio += 900 + 300 * skill_lv;
+ RE_LVL_DMOD(100);
+ }else{
+ skillratio += 400 + 100 * skill_lv;
+ RE_LVL_DMOD(150);
+ }
+ break;
+ case WL_DRAINLIFE:
+ skillratio = 200 * skill_lv + status_get_int(src);
+ RE_LVL_DMOD(100);
+ break;
+ case WL_CRIMSONROCK:
+ skillratio = 300 * skill_lv;
+ RE_LVL_DMOD(100);
+ skillratio += 1300;
+ break;
+ case WL_HELLINFERNO:
+ skillratio = 300 * skill_lv;
+ RE_LVL_DMOD(100);
+ // Shadow: MATK [{( Skill Level x 300 ) x ( Caster Base Level / 100 ) x 4/5 }] %
+ // Fire : MATK [{( Skill Level x 300 ) x ( Caster Base Level / 100 ) /5 }] %
+ if( flag&ELE_DARK )
+ skillratio *= 4;
+ skillratio /= 5;
+ break;
+ case WL_COMET:
+ i = ( sc ? distance_xy(target->x, target->y, sc->comet_x, sc->comet_y) : 8 );
+ if( i <= 3 ) skillratio += 2400 + 500 * skill_lv; // 7 x 7 cell
+ else
+ if( i <= 5 ) skillratio += 1900 + 500 * skill_lv; // 11 x 11 cell
+ else
+ if( i <= 7 ) skillratio += 1400 + 500 * skill_lv; // 15 x 15 cell
+ else
+ skillratio += 900 + 500 * skill_lv; // 19 x 19 cell
+
+ if( sd && sd->status.party_id ){
+ struct map_session_data* psd;
+ int static p_sd[5] = {0, 0, 0, 0, 0}, c; // just limit it to 5
+
+ c = 0;
+ memset (p_sd, 0, sizeof(p_sd));
+ party_foreachsamemap(skill->check_condition_char_sub, sd, 3, &sd->bl, &c, &p_sd, skill_id);
+ c = ( c > 1 ? rand()%c : 0 );
+
+ if( (psd = iMap->id2sd(p_sd[c])) && pc->checkskill(psd,WL_COMET) > 0 ){
+ skillratio = skill_lv * 400; //MATK [{( Skill Level x 400 ) x ( Caster's Base Level / 120 )} + 2500 ] %
+ RE_LVL_DMOD(120);
+ skillratio += 2500;
+ status_zap(&psd->bl, 0, skill->get_sp(skill_id, skill_lv) / 2);
+ }
+ }
+ break;
+ case WL_CHAINLIGHTNING_ATK:
+ skillratio += 400 + 100 * skill_lv;
+ RE_LVL_DMOD(100);
+ if(flag > 0)
+ skillratio += 100 * flag;
+ break;
+ case WL_EARTHSTRAIN:
+ skillratio += 1900 + 100 * skill_lv;
+ RE_LVL_DMOD(100);
+ break;
+ case WL_TETRAVORTEX_FIRE:
+ case WL_TETRAVORTEX_WATER:
+ case WL_TETRAVORTEX_WIND:
+ case WL_TETRAVORTEX_GROUND:
+ skillratio += 400 + 500 * skill_lv;
+ break;
+ case WL_SUMMON_ATK_FIRE:
+ case WL_SUMMON_ATK_WATER:
+ case WL_SUMMON_ATK_WIND:
+ case WL_SUMMON_ATK_GROUND:
+ skillratio = skill_lv * (status_get_lv(src) + ( sd ? sd->status.job_level : 50 ));// This is close to official, but lacking a little info to finalize. [Rytech]
+ RE_LVL_DMOD(100);
+ break;
+ case LG_RAYOFGENESIS:
+ {
+ int16 lv = skill_lv;
+ int bandingBonus = 0;
+ if( sc && sc->data[SC_BANDING] )
+ bandingBonus = 200 * (sd ? skill->check_pc_partner(sd,skill_id,&lv,skill->get_splash(skill_id,skill_lv),0) : 1);
+ skillratio = ((300 * skill_lv) + bandingBonus) * (sd ? sd->status.job_level : 1) / 25;
+ }
+ break;
+ case LG_SHIELDSPELL:// [(Casters Base Level x 4) + (Shield MDEF x 100) + (Casters INT x 2)] %
+ if( sd ) {
+ skillratio = status_get_lv(src) * 4 + sd->bonus.shieldmdef * 100 + status_get_int(src) * 2;
+ } else
+ skillratio += 1900; //2000%
+ break;
+ case WM_METALICSOUND:
+ skillratio += 120 * skill_lv + 60 * ( sd? pc->checkskill(sd, WM_LESSON) : 10 ) - 100;
+ break;
+ /*case WM_SEVERE_RAINSTORM:
+ skillratio += 50 * skill_lv;
+ break;
+
+ WM_SEVERE_RAINSTORM just set a unit place,
+ refer to WM_SEVERE_RAINSTORM_MELEE to set the formula.
+ */
+ case WM_REVERBERATION_MAGIC:
+ // MATK [{(Skill Level x 100) + 100} x Casters Base Level / 100] %
+ skillratio += 100 * (sd ? pc->checkskill(sd, WM_REVERBERATION) : 1);
+ RE_LVL_DMOD(100);
+ break;
+ case SO_FIREWALK:
+ skillratio = 300;
+ RE_LVL_DMOD(100);
+ if( sc && sc->data[SC_HEATER_OPTION] )
+ skillratio += sc->data[SC_HEATER_OPTION]->val3;
+ break;
+ case SO_ELECTRICWALK:
+ skillratio = 300;
+ RE_LVL_DMOD(100);
+ if( sc && sc->data[SC_BLAST_OPTION] )
+ skillratio += sd ? sd->status.job_level / 2 : 0;
+ break;
+ case SO_EARTHGRAVE:
+ skillratio = ( 200 * ( sd ? pc->checkskill(sd, SA_SEISMICWEAPON) : 10 ) + status_get_int(src) * skill_lv );
+ RE_LVL_DMOD(100);
+ if( sc && sc->data[SC_CURSED_SOIL_OPTION] )
+ skillratio += sc->data[SC_CURSED_SOIL_OPTION]->val2;
+ break;
+ case SO_DIAMONDDUST:
+ skillratio = ( 200 * ( sd ? pc->checkskill(sd, SA_FROSTWEAPON) : 10 ) + status_get_int(src) * skill_lv );
+ RE_LVL_DMOD(100);
+ if( sc && sc->data[SC_COOLER_OPTION] )
+ skillratio += sc->data[SC_COOLER_OPTION]->val3;
+ break;
+ case SO_POISON_BUSTER:
+ skillratio += 1100 + 300 * skill_lv;
+ if( sc && sc->data[SC_CURSED_SOIL_OPTION] )
+ skillratio += sc->data[SC_CURSED_SOIL_OPTION]->val2;
+ break;
+ case SO_PSYCHIC_WAVE:
+ skillratio += -100 + skill_lv * 70 + (status_get_int(src) * 3);
+ RE_LVL_DMOD(100);
+ if( sc ){
+ if( sc->data[SC_HEATER_OPTION] )
+ skillratio += sc->data[SC_HEATER_OPTION]->val3;
+ else if(sc->data[SC_COOLER_OPTION] )
+ skillratio += sc->data[SC_COOLER_OPTION]->val3;
+ else if(sc->data[SC_BLAST_OPTION] )
+ skillratio += sc->data[SC_BLAST_OPTION]->val2;
+ else if(sc->data[SC_CURSED_SOIL_OPTION] )
+ skillratio += sc->data[SC_CURSED_SOIL_OPTION]->val3;
+ }
+ break;
+ case SO_VARETYR_SPEAR: //MATK [{( Endow Tornado skill level x 50 ) + ( Caster INT x Varetyr Spear Skill level )} x Caster Base Level / 100 ] %
+ skillratio = status_get_int(src) * skill_lv + ( sd ? pc->checkskill(sd, SA_LIGHTNINGLOADER) * 50 : 0 );
+ RE_LVL_DMOD(100);
+ if( sc && sc->data[SC_BLAST_OPTION] )
+ skillratio += sd ? sd->status.job_level * 5 : 0;
+ break;
+ case SO_CLOUD_KILL:
+ skillratio += -100 + skill_lv * 40;
+ RE_LVL_DMOD(100);
+ if( sc && sc->data[SC_CURSED_SOIL_OPTION] )
+ skillratio += sc->data[SC_CURSED_SOIL_OPTION]->val2;
+ break;
+ case GN_DEMONIC_FIRE:
+ if( skill_lv > 20)
+ { // Fire expansion Lv.2
+ skillratio += 110 + 20 * (skill_lv - 20) + status_get_int(src) * 3; // Need official INT bonus. [LimitLine]
+ }
+ else if( skill_lv > 10 )
+ { // Fire expansion Lv.1
+ skillratio += 110 + 20 * (skill_lv - 10) / 2;
+ }
+ else
+ skillratio += 110 + 20 * skill_lv;
+ break;
+ // Magical Elemental Spirits Attack Skills
+ case EL_FIRE_MANTLE:
+ case EL_WATER_SCREW:
+ skillratio += 900;
+ break;
+ case EL_FIRE_ARROW:
+ case EL_ROCK_CRUSHER_ATK:
+ skillratio += 200;
+ break;
+ case EL_FIRE_BOMB:
+ case EL_ICE_NEEDLE:
+ case EL_HURRICANE_ATK:
+ skillratio += 400;
+ break;
+ case EL_FIRE_WAVE:
+ case EL_TYPOON_MIS_ATK:
+ skillratio += 1100;
+ break;
+ case MH_ERASER_CUTTER:
+ if(skill_lv%2) skillratio += 400; //600:800:1000
+ else skillratio += 700; //1000:1200
+ skillratio += 100 * skill_lv;
+ break;
+ case MH_XENO_SLASHER:
+ if(skill_lv%2) skillratio += 350 + 50 * skill_lv; //500:600:700
+ else skillratio += 400 + 100 * skill_lv; //700:900
+ break;
+ case MH_HEILIGE_STANGE:
+ skillratio += 400 + 250 * skill_lv;
+ break;
+ case MH_POISON_MIST:
+ skillratio += 100 * skill_lv;
+ break;
+ case KO_KAIHOU:
+ if( sd ){
+ ARR_FIND(1, 6, i, sd->charm[i] > 0);
+ if( i < 5 ){
+ skillratio += -100 + 200 * sd->charm[i];
+ RE_LVL_DMOD(100);
+ pc->del_charm(sd, sd->charm[i], i);
+ }
+ }
+ break;
+ }
+ break;
+ case BF_WEAPON:
+ switch( skill_id )
+ {
+ case SM_BASH:
+ case MS_BASH:
+ skillratio += 30 * skill_lv;
+ break;
+ case SM_MAGNUM:
+ case MS_MAGNUM:
+ skillratio += 20 * skill_lv;
+ break;
+ case MC_MAMMONITE:
+ skillratio += 50 * skill_lv;
+ break;
+ case HT_POWER:
+ skillratio += -50 + 8 * status_get_str(src);
+ break;
+ case AC_DOUBLE:
+ case MA_DOUBLE:
+ skillratio += 10 * (skill_lv-1);
+ break;
+ case AC_SHOWER:
+ case MA_SHOWER:
+ #ifdef RENEWAL
+ skillratio += 50 + 10 * skill_lv;
+ #else
+ skillratio += -25 + 5 * skill_lv;
+ #endif
+ break;
+ case AC_CHARGEARROW:
+ case MA_CHARGEARROW:
+ skillratio += 50;
+ break;
+ #ifndef RENEWAL
+ case HT_FREEZINGTRAP:
+ case MA_FREEZINGTRAP:
+ skillratio += -50 + 10 * skill_lv;
+ break;
+ #endif
+ case KN_PIERCE:
+ case ML_PIERCE:
+ skillratio += 10 * skill_lv;
+ break;
+ case MER_CRASH:
+ skillratio += 10 * skill_lv;
+ break;
+ case KN_SPEARSTAB:
+ skillratio += 15 * skill_lv;
+ break;
+ case KN_SPEARBOOMERANG:
+ skillratio += 50*skill_lv;
+ break;
+ case KN_BRANDISHSPEAR:
+ case ML_BRANDISH:
+ {
+ int ratio = 100 + 20 * skill_lv;
+ skillratio += ratio - 100;
+ if(skill_lv>3 && flag==1) skillratio += ratio / 2;
+ if(skill_lv>6 && flag==1) skillratio += ratio / 4;
+ if(skill_lv>9 && flag==1) skillratio += ratio / 8;
+ if(skill_lv>6 && flag==2) skillratio += ratio / 2;
+ if(skill_lv>9 && flag==2) skillratio += ratio / 4;
+ if(skill_lv>9 && flag==3) skillratio += ratio / 2;
+ break;
+ }
+ case KN_BOWLINGBASH:
+ case MS_BOWLINGBASH:
+ skillratio+= 40 * skill_lv;
+ break;
+ case AS_GRIMTOOTH:
+ skillratio += 20 * skill_lv;
+ break;
+ case AS_POISONREACT:
+ skillratio += 30 * skill_lv;
+ break;
+ case AS_SONICBLOW:
+ skillratio += -50 + 5 * skill_lv;
+ break;
+ case TF_SPRINKLESAND:
+ skillratio += 30;
+ break;
+ case MC_CARTREVOLUTION:
+ skillratio += 50;
+ if( sd && sd->cart_weight )
+ skillratio += 100 * sd->cart_weight / sd->cart_weight_max; // +1% every 1% weight
+ else if (!sd)
+ skillratio += 100; //Max damage for non players.
+ break;
+ case NPC_RANDOMATTACK:
+ skillratio += 100 * skill_lv;
+ break;
+ case NPC_WATERATTACK:
+ case NPC_GROUNDATTACK:
+ case NPC_FIREATTACK:
+ case NPC_WINDATTACK:
+ case NPC_POISONATTACK:
+ case NPC_HOLYATTACK:
+ case NPC_DARKNESSATTACK:
+ case NPC_UNDEADATTACK:
+ case NPC_TELEKINESISATTACK:
+ case NPC_BLOODDRAIN:
+ case NPC_ACIDBREATH:
+ case NPC_DARKNESSBREATH:
+ case NPC_FIREBREATH:
+ case NPC_ICEBREATH:
+ case NPC_THUNDERBREATH:
+ case NPC_HELLJUDGEMENT:
+ case NPC_PULSESTRIKE:
+ skillratio += 100 * (skill_lv-1);
+ break;
+ case RG_BACKSTAP:
+ if( sd && sd->status.weapon == W_BOW && battle_config.backstab_bow_penalty )
+ skillratio += (200 + 40 * skill_lv) / 2;
+ else
+ skillratio += 200 + 40 * skill_lv;
+ break;
+ case RG_RAID:
+ skillratio += 40 * skill_lv;
+ break;
+ case RG_INTIMIDATE:
+ skillratio += 30 * skill_lv;
+ break;
+ case CR_SHIELDCHARGE:
+ skillratio += 20 * skill_lv;
+ break;
+ case CR_SHIELDBOOMERANG:
+ skillratio += 30 * skill_lv;
+ break;
+ case NPC_DARKCROSS:
+ case CR_HOLYCROSS:
+ {
+ int ratio = 35 * skill_lv;
+ #ifdef RENEWAL
+ if(sd && sd->status.weapon == W_2HSPEAR)
+ ratio *= 2;
+ #endif
+ skillratio += ratio;
+ break;
+ }
+ case AM_DEMONSTRATION:
+ skillratio += 20 * skill_lv;
+ break;
+ case AM_ACIDTERROR:
+ skillratio += 40 * skill_lv;
+ break;
+ case MO_FINGEROFFENSIVE:
+ skillratio+= 50 * skill_lv;
+ break;
+ case MO_INVESTIGATE:
+ skillratio += 75 * skill_lv;
+ break;
+ #ifndef RENEWAL
+ case MO_EXTREMITYFIST:
+ { //Overflow check. [Skotlex]
+ unsigned int ratio = skillratio + 100*(8 + status->sp/10);
+ //You'd need something like 6K SP to reach this max, so should be fine for most purposes.
+ if (ratio > 60000) ratio = 60000; //We leave some room here in case skillratio gets further increased.
+ skillratio = (unsigned short)ratio;
+ }
+ break;
+ #endif
+ case MO_TRIPLEATTACK:
+ skillratio += 20 * skill_lv;
+ break;
+ case MO_CHAINCOMBO:
+ skillratio += 50 + 50 * skill_lv;
+ break;
+ case MO_COMBOFINISH:
+ skillratio += 140 + 60 * skill_lv;
+ break;
+ case BA_MUSICALSTRIKE:
+ case DC_THROWARROW:
+ skillratio += 25 + 25 * skill_lv;
+ break;
+ case CH_TIGERFIST:
+ skillratio += 100 * skill_lv - 60;
+ break;
+ case CH_CHAINCRUSH:
+ skillratio += 300 + 100 * skill_lv;
+ break;
+ case CH_PALMSTRIKE:
+ skillratio += 100 + 100 * skill_lv;
+ break;
+ case LK_HEADCRUSH:
+ skillratio += 40 * skill_lv;
+ break;
+ case LK_JOINTBEAT:
+ i = 10 * skill_lv - 50;
+ // Although not clear, it's being assumed that the 2x damage is only for the break neck ailment.
+ if (flag&BREAK_NECK) i*=2;
+ skillratio += i;
+ break;
+ case ASC_METEORASSAULT:
+ skillratio += 40 * skill_lv - 60;
+ break;
+ case SN_SHARPSHOOTING:
+ case MA_SHARPSHOOTING:
+ skillratio += 100 + 50 * skill_lv;
+ break;
+ case CG_ARROWVULCAN:
+ skillratio += 100 + 100 * skill_lv;
+ break;
+ case AS_SPLASHER:
+ skillratio += 400 + 50 * skill_lv;
+ if(sd)
+ skillratio += 20 * pc->checkskill(sd,AS_POISONREACT);
+ break;
+ #ifndef RENEWAL
+ case ASC_BREAKER:
+ skillratio += 100*skill_lv-100;
+ break;
+ #endif
+ case PA_SACRIFICE:
+ skillratio += 10 * skill_lv - 10;
+ break;
+ case PA_SHIELDCHAIN:
+ skillratio += 30 * skill_lv;
+ break;
+ case WS_CARTTERMINATION:
+ i = 10 * (16 - skill_lv);
+ if (i < 1) i = 1;
+ //Preserve damage ratio when max cart weight is changed.
+ if(sd && sd->cart_weight)
+ skillratio += sd->cart_weight/i * 80000/battle_config.max_cart_weight - 100;
+ else if (!sd)
+ skillratio += 80000 / i - 100;
+ break;
+ case TK_DOWNKICK:
+ skillratio += 60 + 20 * skill_lv;
+ break;
+ case TK_STORMKICK:
+ skillratio += 60 + 20 * skill_lv;
+ break;
+ case TK_TURNKICK:
+ skillratio += 90 + 30 * skill_lv;
+ break;
+ case TK_COUNTER:
+ skillratio += 90 + 30 * skill_lv;
+ break;
+ case TK_JUMPKICK:
+ skillratio += -70 + 10*skill_lv;
+ if (sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == skill_id)
+ skillratio += 10 * status_get_lv(src) / 3; //Tumble bonus
+ if (flag)
+ {
+ skillratio += 10 * status_get_lv(src) / 3; //Running bonus (TODO: What is the real bonus?)
+ if( sc && sc->data[SC_STRUP] ) // Spurt bonus
+ skillratio *= 2;
+ }
+ break;
+ case GS_TRIPLEACTION:
+ skillratio += 50 * skill_lv;
+ break;
+ case GS_BULLSEYE:
+ //Only works well against brute/demihumans non bosses.
+ if((tstatus->race == RC_BRUTE || tstatus->race == RC_DEMIHUMAN)
+ && !(tstatus->mode&MD_BOSS))
+ skillratio += 400;
+ break;
+ case GS_TRACKING:
+ skillratio += 100 * (skill_lv+1);
+ break;
+ case GS_PIERCINGSHOT:
+ skillratio += 20 * skill_lv;
+ break;
+ case GS_RAPIDSHOWER:
+ skillratio += 10 * skill_lv;
+ break;
+ case GS_DESPERADO:
+ skillratio += 50 * (skill_lv-1);
+ break;
+ case GS_DUST:
+ skillratio += 50 * skill_lv;
+ break;
+ case GS_FULLBUSTER:
+ skillratio += 100 * (skill_lv+2);
+ break;
+ case GS_SPREADATTACK:
+ #ifdef RENEWAL
+ skillratio += 20 * (skill_lv);
+ #else
+ skillratio += 20 * (skill_lv-1);
+ #endif
+ break;
+ case NJ_HUUMA:
+ skillratio += 50 + 150 * skill_lv;
+ break;
+ case NJ_TATAMIGAESHI:
+ skillratio += 10 * skill_lv;
+ break;
+ case NJ_KASUMIKIRI:
+ skillratio += 10 * skill_lv;
+ break;
+ case NJ_KIRIKAGE:
+ skillratio += 100 * (skill_lv-1);
+ break;
+ case KN_CHARGEATK:
+ {
+ int k = (flag-1)/3; //+100% every 3 cells of distance
+ if( k > 2 ) k = 2; // ...but hard-limited to 300%.
+ skillratio += 100 * k;
+ }
+ break;
+ case HT_PHANTASMIC:
+ skillratio += 50;
+ break;
+ case MO_BALKYOUNG:
+ skillratio += 200;
+ break;
+ case HFLI_MOON: //[orn]
+ skillratio += 10 + 110 * skill_lv;
+ break;
+ case HFLI_SBR44: //[orn]
+ skillratio += 100 * (skill_lv-1);
+ break;
+ case NPC_VAMPIRE_GIFT:
+ skillratio += ((skill_lv-1)%5+1) * 100;
+ break;
+ case RK_SONICWAVE:
+ skillratio += -100 + 100 * (skill_lv + 5);
+ skillratio = skillratio * (100 + (status_get_lv(src)-100) / 2) / 100;
+ break;
+ case RK_HUNDREDSPEAR:
+ skillratio += 500 + (80 * skill_lv);
+ if( sd ){
+ short index = sd->equip_index[EQI_HAND_R];
+ if( index >= 0 && sd->inventory_data[index]
+ && sd->inventory_data[index]->type == IT_WEAPON )
+ skillratio += (10000 - min(10000, sd->inventory_data[index]->weight)) / 10;
+ skillratio = skillratio * (100 + (status_get_lv(src)-100) / 2) / 100 + 50 * pc->checkskill(sd,LK_SPIRALPIERCE);
+ }
+ break;
+ case RK_WINDCUTTER:
+ skillratio += -100 + 50 * (skill_lv + 2);
+ RE_LVL_DMOD(100);
+ break;
+ case RK_IGNITIONBREAK:
+ i = distance_bl(src,target);
+ if( i < 2 )
+ skillratio += 300 * skill_lv;
+ else if( i < 4 )
+ skillratio += 250 * skill_lv;
+ else
+ skillratio += 200 * skill_lv;
+ skillratio = (skillratio - 100) * (100 + (status_get_lv(src)-100)) / 100;
+ if( status->rhw.ele == ELE_FIRE )
+ skillratio += 100 * skill_lv;
+ break;
+ case RK_CRUSHSTRIKE:
+ if( sd )
+ {//ATK [{Weapon Level * (Weapon Upgrade Level + 6) * 100} + (Weapon ATK) + (Weapon Weight)]%
+ short index = sd->equip_index[EQI_HAND_R];
+ if( index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->type == IT_WEAPON )
+ skillratio += -100 + sd->inventory_data[index]->weight/10 + status->rhw.atk +
+ 100 * sd->inventory_data[index]->wlv * (sd->status.inventory[index].refine + 6);
+ }
+ break;
+ case RK_STORMBLAST:
+ skillratio += -100 + 100 * (sd ? pc->checkskill(sd,RK_RUNEMASTERY) : 1) + 100 * (status_get_int(src) / 4);
+ break;
+ case RK_PHANTOMTHRUST:
+ skillratio += -100 + 50 * skill_lv + 10 * ( sd ? pc->checkskill(sd,KN_SPEARMASTERY) : 10);
+ RE_LVL_DMOD(150);
+ break;
+ /**
+ * GC Guilotine Cross
+ **/
+ case GC_CROSSIMPACT:
+ skillratio += 900 + 100 * skill_lv;
+ RE_LVL_DMOD(120);
+ break;
+ case GC_PHANTOMMENACE:
+ skillratio += 200;
+ break;
+ case GC_COUNTERSLASH:
+ //ATK [{(Skill Level x 100) + 300} x Caster's Base Level / 120]% + ATK [(AGI x 2) + (Caster's Job Level x 4)]%
+ skillratio += 200 + (100 * skill_lv);
+ RE_LVL_DMOD(120);
+ skillratio += status_get_agi(src) * 2 + (sd?sd->status.job_level:0) * 4;
+ break;
+ case GC_ROLLINGCUTTER:
+ skillratio += -50 + 50 * skill_lv;
+ RE_LVL_DMOD(100);
+ break;
+ case GC_CROSSRIPPERSLASHER:
+ skillratio += 300 + 80 * skill_lv;
+ RE_LVL_DMOD(100);
+ if( sc && sc->data[SC_ROLLINGCUTTER] )
+ skillratio += sc->data[SC_ROLLINGCUTTER]->val1 * status_get_agi(src);
+ break;
+ case GC_DARKCROW:
+ skillratio += 100 * (skill_lv - 1);
+ break;
+ /**
+ * Arch Bishop
+ **/
+ case AB_DUPLELIGHT_MELEE:
+ skillratio += 10 * skill_lv;
+ break;
+ /**
+ * Ranger
+ **/
+ case RA_ARROWSTORM:
+ skillratio += 900 + 80 * skill_lv;
+ RE_LVL_DMOD(100);
+ break;
+ case RA_AIMEDBOLT:
+ skillratio += 400 + 50 * skill_lv;
+ RE_LVL_DMOD(100);
+ break;
+ case RA_CLUSTERBOMB:
+ skillratio += 100 + 100 * skill_lv;
+ break;
+ case RA_WUGDASH:// ATK 300%
+ skillratio += 200;
+ break;
+ case RA_WUGSTRIKE:
+ skillratio += -100 + 200 * skill_lv;
+ break;
+ case RA_WUGBITE:
+ skillratio += 300 + 200 * skill_lv;
+ if ( skill_lv == 5 ) skillratio += 100;
+ break;
+ case RA_SENSITIVEKEEN:
+ skillratio += 50 * skill_lv;
+ break;
+ /**
+ * Mechanic
+ **/
+ case NC_BOOSTKNUCKLE:
+ skillratio += 100 + 100 * skill_lv + status_get_dex(src);
+ RE_LVL_DMOD(100);
+ break;
+ case NC_PILEBUNKER:
+ skillratio += 200 + 100 * skill_lv + status_get_str(src);
+ RE_LVL_DMOD(100);
+ break;
+ case NC_VULCANARM:
+ skillratio += -100 + 70 * skill_lv + status_get_dex(src);
+ RE_LVL_DMOD(100);
+ break;
+ case NC_FLAMELAUNCHER:
+ case NC_COLDSLOWER:
+ skillratio += 200 + 300 * skill_lv;
+ RE_LVL_DMOD(100);
+ break;
+ case NC_ARMSCANNON:
+ switch( tstatus->size ) {
+ case SZ_SMALL: skillratio += 100 + 500 * skill_lv; break;// Small
+ case SZ_MEDIUM: skillratio += 100 + 400 * skill_lv; break;// Medium
+ case SZ_BIG: skillratio += 100 + 300 * skill_lv; break;// Large
+ }
+ RE_LVL_DMOD(100);
+ //NOTE: Their's some other factors that affects damage, but not sure how exactly. Will recheck one day. [Rytech]
+ break;
+ case NC_AXEBOOMERANG:
+ skillratio += 60 + 40 * skill_lv;
+ if( sd ) {
+ short index = sd->equip_index[EQI_HAND_R];
+ if( index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->type == IT_WEAPON )
+ skillratio += sd->inventory_data[index]->weight / 10;// Weight is divided by 10 since 10 weight in coding make 1 whole actural weight. [Rytech]
+ }
+ RE_LVL_DMOD(100);
+ break;
+ case NC_POWERSWING:
+ skillratio += 80 + 20 * skill_lv + status_get_str(src) + status_get_dex(src);
+ RE_LVL_DMOD(100);
+ break;
+ case NC_AXETORNADO:
+ skillratio += 100 + 100 * skill_lv + status_get_vit(src);
+ RE_LVL_DMOD(100);
+ break;
+ case SC_FATALMENACE:
+ skillratio += 100 * skill_lv;
+ break;
+ case SC_TRIANGLESHOT:
+ skillratio += 270 + 30 * skill_lv;
+ break;
+ case SC_FEINTBOMB:
+ skillratio += 100 + 100 * skill_lv;
+ break;
+ case LG_CANNONSPEAR:// Stimated formula. Still need confirm it.
+ skillratio += -100 + (50 + status_get_str(src)) * skill_lv;
+ RE_LVL_DMOD(100);
+ break;
+ case LG_BANISHINGPOINT:
+ skillratio += -100 + ((50 * skill_lv) + (30 * ((sd)?pc->checkskill(sd,SM_BASH):1)));
+ RE_LVL_DMOD(100);
+ break;
+ case LG_SHIELDPRESS:
+ skillratio += 60 + 43 * skill_lv;
+ RE_LVL_DMOD(100);
+ break;
+ case LG_PINPOINTATTACK:
+ skillratio += -100 + ((100 * skill_lv) + (10 * status_get_agi(src)) );
+ RE_LVL_DMOD(100);
+ break;
+ case LG_RAGEBURST:
+ if( sd && sd->spiritball_old )
+ skillratio += -100 + (sd->spiritball_old * 200);
+ else
+ skillratio += -100 + 15 * 200;
+ RE_LVL_DMOD(100);
+ break;
+ case LG_SHIELDSPELL:// [(Casters Base Level x 4) + (Shield DEF x 10) + (Casters VIT x 2)] %
+ if( sd ) {
+ struct item_data *shield_data = sd->inventory_data[sd->equip_index[EQI_HAND_L]];
+ skillratio += -100 + status_get_lv(src) * 4 + status_get_vit(src) * 2;
+ if( shield_data )
+ skillratio += shield_data->def * 10;
+ } else
+ skillratio += 2400; //2500%
+ break;
+ case LG_MOONSLASHER:
+ skillratio += -100 + (120 * skill_lv + ((sd) ? pc->checkskill(sd,LG_OVERBRAND) : 5) * 80);
+ RE_LVL_DMOD(100);
+ break;
+ case LG_OVERBRAND:
+ skillratio += -100 + 400 * skill_lv + (pc->checkskill(sd,CR_SPEARQUICKEN) * 30);
+ RE_LVL_DMOD(100);
+ break;
+ case LG_OVERBRAND_BRANDISH:
+ skillratio += -100 + 300 * skill_lv + (2 * (status_get_str(src) + status_get_dex(src)) / 3);
+ RE_LVL_DMOD(100);
+ break;
+ case LG_OVERBRAND_PLUSATK:
+ skillratio += -100 + 150 * skill_lv;
+ RE_LVL_DMOD(100);
+ break;
+ case LG_RAYOFGENESIS:
+ skillratio += 200 + 300 * skill_lv;
+ RE_LVL_DMOD(100);
+ break;
+ case LG_EARTHDRIVE:
+ skillratio = (skillratio + 100) * skill_lv;
+ RE_LVL_DMOD(100);
+ break;
+ case LG_HESPERUSLIT:
+ skillratio += 120 * skill_lv - 100;
+ break;
+ case SR_DRAGONCOMBO:
+ skillratio += 40 * skill_lv;
+ RE_LVL_DMOD(100);
+ break;
+ case SR_SKYNETBLOW:
+ if( sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == SR_DRAGONCOMBO )//ATK [{(Skill Level x 100) + (Caster AGI) + 150} x Caster Base Level / 100] %
+ skillratio += 100 * skill_lv + status_get_agi(src) + 50;
+ else //ATK [{(Skill Level x 80) + (Caster AGI)} x Caster Base Level / 100] %
+ skillratio += -100 + 80 * skill_lv + status_get_agi(src);
+ RE_LVL_DMOD(100);
+ break;
+ case SR_EARTHSHAKER:
+ if( tsc && (tsc->data[SC_HIDING] || tsc->data[SC_CLOAKING] || // [(Skill Level x 150) x (Caster Base Level / 100) + (Caster INT x 3)] %
+ tsc->data[SC_CHASEWALK] || tsc->data[SC_CLOAKINGEXCEED] || tsc->data[SC__INVISIBILITY]) ){
+ skillratio += -100 + 150 * skill_lv;
+ RE_LVL_DMOD(100);
+ skillratio += status_get_int(src) * 3;
+ }else{ //[(Skill Level x 50) x (Caster Base Level / 100) + (Caster INT x 2)] %
+ skillratio += 50 * (skill_lv-2);
+ RE_LVL_DMOD(100);
+ skillratio += status_get_int(src) * 2;
+ }
+ break;
+ case SR_FALLENEMPIRE:// ATK [(Skill Level x 150 + 100) x Caster Base Level / 150] %
+ skillratio += 150 *skill_lv;
+ RE_LVL_DMOD(150);
+ break;
+ case SR_TIGERCANNON:// ATK [((Caster consumed HP + SP) / 4) x Caster Base Level / 100] %
+ {
+ int hp = status_get_max_hp(src) * (10 + 2 * skill_lv) / 100,
+ sp = status_get_max_sp(src) * (6 + skill_lv) / 100;
+ if( sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == SR_FALLENEMPIRE ) // ATK [((Caster consumed HP + SP) / 2) x Caster Base Level / 100] %
+ skillratio += -100 + hp+sp / 2;
+ else
+ skillratio += -100 + (hp+sp) / 4;
+ RE_LVL_DMOD(100);
+ }
+ break;
+ case SR_RAMPAGEBLASTER:
+ skillratio += 20 * skill_lv * (sd?sd->spiritball_old:5) - 100;
+ if( sc && sc->data[SC_EXPLOSIONSPIRITS] ){
+ skillratio += sc->data[SC_EXPLOSIONSPIRITS]->val1 * 20;
+ RE_LVL_DMOD(120);
+ }else
+ RE_LVL_DMOD(150);
+ break;
+ case SR_KNUCKLEARROW:
+ if( flag&4 ){ // ATK [(Skill Level x 150) + (1000 x Target current weight / Maximum weight) + (Target Base Level x 5) x (Caster Base Level / 150)] %
+ skillratio += -100 + 150 * skill_lv + status_get_lv(target) * 5 * (status_get_lv(src) / 100) ;
+ if( tsd && tsd->weight )
+ skillratio += 100 * (tsd->weight / tsd->max_weight);
+ }else // ATK [(Skill Level x 100 + 500) x Caster Base Level / 100] %
+ skillratio += 400 + (100 * skill_lv);
+ RE_LVL_DMOD(100);
+ break;
+ case SR_WINDMILL: // ATK [(Caster Base Level + Caster DEX) x Caster Base Level / 100] %
+ skillratio += -100 + status_get_lv(src) + status_get_dex(src);
+ RE_LVL_DMOD(100);
+ break;
+ case SR_GATEOFHELL:
+ if( sc && sc->data[SC_COMBOATTACK]
+ && sc->data[SC_COMBOATTACK]->val1 == SR_FALLENEMPIRE )
+ skillratio += 800 * skill_lv -100;
+ else
+ skillratio += 500 * skill_lv -100;
+ RE_LVL_DMOD(100);
+ break;
+ case SR_GENTLETOUCH_QUIET:
+ skillratio += 100 * skill_lv - 100 + status_get_dex(src);
+ RE_LVL_DMOD(100);
+ break;
+ case SR_HOWLINGOFLION:
+ skillratio += 300 * skill_lv - 100;
+ RE_LVL_DMOD(150);
+ break;
+ case SR_RIDEINLIGHTNING: // ATK [{(Skill Level x 200) + Additional Damage} x Caster Base Level / 100] %
+ if( (status->rhw.ele) == ELE_WIND || (status->lhw.ele) == ELE_WIND )
+ skillratio += skill_lv * 50;
+ skillratio += -100 + 200 * skill_lv;
+ RE_LVL_DMOD(100);
+ break;
+ case WM_REVERBERATION_MELEE:
+ // ATK [{(Skill Level x 100) + 300} x Caster Base Level / 100]
+ skillratio += 200 + 100 * pc->checkskill(sd, WM_REVERBERATION);
+ RE_LVL_DMOD(100);
+ break;
+ case WM_SEVERE_RAINSTORM_MELEE:
+ //ATK [{(Caster DEX + AGI) x (Skill Level / 5)} x Caster Base Level / 100] %
+ skillratio += -100 + (status_get_dex(src) + status_get_agi(src)) * (skill_lv * 2);
+ RE_LVL_DMOD(100);
+ skillratio /= 10;
+ break;
+ case WM_GREAT_ECHO:
+ skillratio += 800 + 100 * skill_lv;
+ if( sd ) { // Still need official value [pakpil]
+ short lv = (short)skill_lv;
+ skillratio += 100 * skill->check_pc_partner(sd,skill_id,&lv,skill->get_splash(skill_id,skill_lv),0);
+ }
+ break;
+ case WM_SOUND_OF_DESTRUCTION:
+ skillratio += 400;
+ break;
+ case GN_CART_TORNADO:
+ // ATK [( Skill Level x 50 ) + ( Cart Weight / ( 150 - Caster Base STR ))] + ( Cart Remodeling Skill Level x 50 )] %
+ skillratio += -100 + 50 * skill_lv;
+ if( sd && sd->cart_weight)
+ skillratio += sd->cart_weight/10 / max(150-status_get_str(src),1) + pc->checkskill(sd, GN_REMODELING_CART) * 50;
+ break;
+ case GN_CARTCANNON:
+ // ATK [{( Cart Remodeling Skill Level x 50 ) x ( INT / 40 )} + ( Cart Cannon Skill Level x 60 )] %
+ skillratio += -100 + 60 * skill_lv;
+ if( sd ) skillratio += pc->checkskill(sd, GN_REMODELING_CART) * 50 * (status_get_int(src) / 40);
+ break;
+ case GN_SPORE_EXPLOSION:
+ skillratio += 200 + 100 * skill_lv;
+ break;
+ case GN_CRAZYWEED_ATK:
+ skillratio += 400 + 100 * skill_lv;
+ break;
+ case GN_SLINGITEM_RANGEMELEEATK:
+ if( sd ) {
+ switch( sd->itemid ) {
+ case 13260: // Apple Bomob
+ case 13261: // Coconut Bomb
+ case 13262: // Melon Bomb
+ case 13263: // Pinapple Bomb
+ skillratio += 400; // Unconfirded
+ break;
+ case 13264: // Banana Bomb 2000%
+ skillratio += 1900;
+ break;
+ case 13265: skillratio -= 75; break; // Black Lump 25%
+ case 13266: skillratio -= 25; break; // Hard Black Lump 75%
+ case 13267: skillratio += 100; break; // Extremely Hard Black Lump 200%
+ }
+ } else
+ skillratio += 300; // Bombs
+ break;
+ case SO_VARETYR_SPEAR://ATK [{( Striking Level x 50 ) + ( Varetyr Spear Skill Level x 50 )} x Caster Base Level / 100 ] %
+ skillratio += -100 + 50 * skill_lv + ( sd ? pc->checkskill(sd, SO_STRIKING) * 50 : 0 );
+ if( sc && sc->data[SC_BLAST_OPTION] )
+ skillratio += sd ? sd->status.job_level * 5 : 0;
+ break;
+ // Physical Elemantal Spirits Attack Skills
+ case EL_CIRCLE_OF_FIRE:
+ case EL_FIRE_BOMB_ATK:
+ case EL_STONE_RAIN:
+ skillratio += 200;
+ break;
+ case EL_FIRE_WAVE_ATK:
+ skillratio += 500;
+ break;
+ case EL_TIDAL_WEAPON:
+ skillratio += 1400;
+ break;
+ case EL_WIND_SLASH:
+ skillratio += 100;
+ break;
+ case EL_HURRICANE:
+ skillratio += 600;
+ break;
+ case EL_TYPOON_MIS:
+ case EL_WATER_SCREW_ATK:
+ skillratio += 900;
+ break;
+ case EL_STONE_HAMMER:
+ skillratio += 400;
+ break;
+ case EL_ROCK_CRUSHER:
+ skillratio += 700;
+ break;
+ case KO_JYUMONJIKIRI:
+ skillratio += -100 + 150 * skill_lv;
+ RE_LVL_DMOD(120);
+ if( tsc && tsc->data[SC_KO_JYUMONJIKIRI] )
+ skillratio += status_get_lv(src) * skill_lv;
+ case KO_HUUMARANKA:
+ skillratio += -100 + 150 * skill_lv + status_get_agi(src) + status_get_dex(src) + 100 * (sd ? pc->checkskill(sd, NJ_HUUMA) : 0);
+ break;
+ case KO_SETSUDAN:
+ skillratio += -100 + 100 * skill_lv;
+ RE_LVL_DMOD(100);
+ break;
+ case KO_BAKURETSU:
+ skillratio += -100 + (50 + status_get_dex(src) / 4) * skill_lv * (sd?pc->checkskill(sd,NJ_TOBIDOUGU):10) * 4 / 100;
+ RE_LVL_DMOD(120);
+ skillratio += 10 * (sd ? sd->status.job_level : 0);
+ break;
+ case MH_NEEDLE_OF_PARALYZE:
+ skillratio += 600 + 100 * skill_lv;
+ break;
+ case MH_STAHL_HORN:
+ skillratio += 400 + 100 * skill_lv;
+ break;
+ case MH_LAVA_SLIDE:
+ skillratio += -100 + 70 * skill_lv;
+ break;
+ case MH_TINDER_BREAKER:
+ case MH_MAGMA_FLOW:
+ skillratio += -100 + 100 * skill_lv;
+ break;
+ }
+ if( sc && sc->data[SC_EDP] ){
+ skillratio -= addedratio;
+ if( skill_id == AS_SONICBLOW ||
+ skill_id == GC_COUNTERSLASH ||
+ skill_id == GC_CROSSIMPACT )
+ skillratio >>= 1;
+ skillratio += addedratio;
+ }
+ }
+ if( skillratio < 1 )
+ return 0;
+ return skillratio;
+}
+/*==========================================
* Check dammage trough status.
* ATK may be MISS, BLOCKED FAIL, reduc, increase, end status...
* After this we apply bg/gvg reduction
@@ -834,7 +2583,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
{
clif->skill_nodamage(bl,src,GC_WEAPONBLOCKING,1,1);
d->dmg_lv = ATK_BLOCK;
- sc_start2(bl,SC_COMBO,100,GC_WEAPONBLOCKING,src->id,2000);
+ sc_start2(bl,SC_COMBOATTACK,100,GC_WEAPONBLOCKING,src->id,2000);
return 0;
}
if( (sce=sc->data[SC_AUTOGUARD]) && flag&BF_WEAPON && !(skill->get_nk(skill_id)&NK_NO_CARDFIX_ATK) && rnd()%100 < sce->val2 )
@@ -848,9 +2597,9 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
delay = 200;
else
delay = 100;
- unit_set_walkdelay(bl, gettick(), delay, 1);
+ unit_set_walkdelay(bl, iTimer->gettick(), delay, 1);
- if(sc->data[SC_SHRINK] && rnd()%100<5*sce->val1)
+ if(sc->data[SC_CR_SHRINK] && rnd()%100<5*sce->val1)
skill->blown(bl,src,skill->get_blewcount(CR_SHRINK,1),-1,0);
return 0;
}
@@ -879,20 +2628,20 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
return 0;
}
- if(sc->data[SC_DODGE] && ( !sc->opt1 || sc->opt1 == OPT1_BURNING ) &&
- (flag&BF_LONG || sc->data[SC_SPURT])
+ if(sc->data[SC_DODGE_READY] && ( !sc->opt1 || sc->opt1 == OPT1_BURNING ) &&
+ (flag&BF_LONG || sc->data[SC_STRUP])
&& rnd()%100 < 20) {
- if (sd && pc_issit(sd)) pc_setstand(sd); //Stand it to dodge.
+ if (sd && pc_issit(sd)) pc->setstand(sd); //Stand it to dodge.
clif->skill_nodamage(bl,bl,TK_DODGE,1,1);
- if (!sc->data[SC_COMBO])
- sc_start4(bl, SC_COMBO, 100, TK_JUMPKICK, src->id, 1, 0, 2000);
+ if (!sc->data[SC_COMBOATTACK])
+ sc_start4(bl, SC_COMBOATTACK, 100, TK_JUMPKICK, src->id, 1, 0, 2000);
return 0;
}
if(sc->data[SC_HERMODE] && flag&BF_MAGIC)
return 0;
- if(sc->data[SC_TATAMIGAESHI] && (flag&(BF_MAGIC|BF_LONG)) == BF_LONG)
+ if(sc->data[SC_NJ_TATAMIGAESHI] && (flag&(BF_MAGIC|BF_LONG)) == BF_LONG)
return 0;
if( sc->data[SC_NEUTRALBARRIER] && (flag&(BF_MAGIC|BF_LONG)) == (BF_MAGIC|BF_LONG) ) {
@@ -915,33 +2664,33 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
return 0;
}
- if (((sce=sc->data[SC_UTSUSEMI]) || sc->data[SC_BUNSINJYUTSU])
+ if (((sce=sc->data[SC_NJ_UTSUSEMI]) || sc->data[SC_NJ_BUNSINJYUTSU])
&& flag&BF_WEAPON && !(skill->get_nk(skill_id)&NK_NO_CARDFIX_ATK)) {
- skill->additional_effect (src, bl, skill_id, skill_lv, flag, ATK_BLOCK, gettick() );
+ skill->additional_effect (src, bl, skill_id, skill_lv, flag, ATK_BLOCK, iTimer->gettick() );
if( !status_isdead(src) )
- skill->counter_additional_effect( src, bl, skill_id, skill_lv, flag, gettick() );
+ skill->counter_additional_effect( src, bl, skill_id, skill_lv, flag, iTimer->gettick() );
if (sce) {
clif->specialeffect(bl, 462, AREA);
skill->blown(src,bl,sce->val3,-1,0);
}
//Both need to be consumed if they are active.
if (sce && --(sce->val2) <= 0)
- status_change_end(bl, SC_UTSUSEMI, INVALID_TIMER);
- if ((sce=sc->data[SC_BUNSINJYUTSU]) && --(sce->val2) <= 0)
- status_change_end(bl, SC_BUNSINJYUTSU, INVALID_TIMER);
+ status_change_end(bl, SC_NJ_UTSUSEMI, INVALID_TIMER);
+ if ((sce=sc->data[SC_NJ_BUNSINJYUTSU]) && --(sce->val2) <= 0)
+ status_change_end(bl, SC_NJ_BUNSINJYUTSU, INVALID_TIMER);
return 0;
}
//Now damage increasing effects
- if( sc->data[SC_AETERNA] && skill_id != PF_SOULBURN )
+ if( sc->data[SC_LEXAETERNA] && skill_id != PF_SOULBURN )
{
if( src->type != BL_MER || skill_id == 0 )
damage <<= 1; // Lex Aeterna only doubles damage of regular attacks from mercenaries
if( skill_id != ASC_BREAKER || !(flag&BF_WEAPON) )
- status_change_end(bl, SC_AETERNA, INVALID_TIMER); //Shouldn't end until Breaker's non-weapon part connects.
+ status_change_end(bl, SC_LEXAETERNA, INVALID_TIMER); //Shouldn't end until Breaker's non-weapon part connects.
}
#ifdef RENEWAL
@@ -955,9 +2704,9 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
if( damage ) {
struct map_session_data *tsd = BL_CAST(BL_PC, src);
- if( sc->data[SC_DEEPSLEEP] ) {
+ if( sc->data[SC_DEEP_SLEEP] ) {
damage += damage / 2; // 1.5 times more damage while in Deep Sleep.
- status_change_end(bl,SC_DEEPSLEEP,INVALID_TIMER);
+ status_change_end(bl,SC_DEEP_SLEEP,INVALID_TIMER);
}
if( tsd && sd && sc->data[SC_CRYSTALIZE] && flag&BF_WEAPON ){
switch(tsd->status.weapon){
@@ -984,8 +2733,8 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
break;
}
}
- if( sc->data[SC_VOICEOFSIREN] )
- status_change_end(bl,SC_VOICEOFSIREN,INVALID_TIMER);
+ if( sc->data[SC_SIREN] )
+ status_change_end(bl,SC_SIREN,INVALID_TIMER);
}
//Finally damage reductions....
@@ -1003,11 +2752,11 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
(flag&(BF_LONG|BF_WEAPON)) == (BF_LONG|BF_WEAPON))
damage = damage * ( 100 - sc->data[SC_DEFENDER]->val2 ) / 100;
- if(sc->data[SC_ADJUSTMENT] &&
+ if(sc->data[SC_GS_ADJUSTMENT] &&
(flag&(BF_LONG|BF_WEAPON)) == (BF_LONG|BF_WEAPON))
damage -= damage * 20 / 100;
- if(sc->data[SC_FOGWALL] && skill_id != RK_DRAGONBREATH) {
+ if(sc->data[SC_FOGWALL] && skill_id != RK_DRAGONBREATH && skill_id != RK_DRAGONBREATH_WATER) {
if(flag&BF_SKILL) //25% reduction
damage -= damage * 25 / 100;
else if ((flag&(BF_LONG|BF_WEAPON)) == (BF_LONG|BF_WEAPON))
@@ -1057,10 +2806,10 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
damage -= damage * sc->data[SC_PAIN_KILLER]->val3 / 100;
}
if((sce=sc->data[SC_MAGMA_FLOW]) && (rnd()%100 <= sce->val2) ){
- skill->castend_damage_id(bl,src,MH_MAGMA_FLOW,sce->val1,gettick(),0);
+ skill->castend_damage_id(bl,src,MH_MAGMA_FLOW,sce->val1,iTimer->gettick(),0);
}
- if( (sce = sc->data[SC_STONEHARDSKIN]) && flag&BF_WEAPON && damage > 0 ) {
+ if( (sce = sc->data[SC_STONEHARDSKIN]) && flag&(BF_SHORT|BF_WEAPON) && damage > 0 ) {
sce->val2 -= damage;
if( src->type == BL_PC ) {
TBL_PC *ssd = BL_CAST(BL_PC, src);
@@ -1070,7 +2819,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
skill->break_equip(src, EQP_WEAPON, 3000, BCT_SELF);
// 30% chance to reduce monster's ATK by 25% for 10 seconds.
if( src->type == BL_MOB )
- sc_start(src, SC_STRIPWEAPON, 30, 0, skill->get_time2(RK_STONEHARDSKIN, sce->val1));
+ sc_start(src, SC_NOEQUIPWEAPON, 30, 0, skill->get_time2(RK_STONEHARDSKIN, sce->val1));
if( sce->val2 <= 0 )
status_change_end(bl, SC_STONEHARDSKIN, INVALID_TIMER);
}
@@ -1085,10 +2834,10 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
#endif
//Finally added to remove the status of immobile when aimedbolt is used. [Jobbie]
- if( skill_id == RA_AIMEDBOLT && (sc->data[SC_BITE] || sc->data[SC_ANKLE] || sc->data[SC_ELECTRICSHOCKER]) )
+ if( skill_id == RA_AIMEDBOLT && (sc->data[SC_WUGBITE] || sc->data[SC_ANKLESNARE] || sc->data[SC_ELECTRICSHOCKER]) )
{
- status_change_end(bl, SC_BITE, INVALID_TIMER);
- status_change_end(bl, SC_ANKLE, INVALID_TIMER);
+ status_change_end(bl, SC_WUGBITE, INVALID_TIMER);
+ status_change_end(bl, SC_ANKLESNARE, INVALID_TIMER);
status_change_end(bl, SC_ELECTRICSHOCKER, INVALID_TIMER);
}
@@ -1114,7 +2863,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
if( (sce = sc->data[SC_LIGHTNINGWALK]) && flag&BF_LONG && rnd()%100 < sce->val1 ) {
int dx[8]={0,-1,-1,-1,0,1,1,1};
int dy[8]={1,1,0,-1,-1,-1,0,1};
- uint8 dir = map_calc_dir(bl, src->x, src->y);
+ uint8 dir = iMap->calc_dir(bl, src->x, src->y);
if( unit_movepos(bl, src->x-dx[dir], src->y-dy[dir], 1, 1) ) {
clif->slide(bl,src->x-dx[dir],src->y-dy[dir]);
unit_setdir(bl, dir);
@@ -1126,12 +2875,12 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
//Probably not the most correct place, but it'll do here
//(since battle_drain is strictly for players currently)
- if ((sce=sc->data[SC_BLOODLUST]) && flag&BF_WEAPON && damage > 0 &&
+ if ((sce=sc->data[SC_HAMI_BLOODLUST]) && flag&BF_WEAPON && damage > 0 &&
rnd()%100 < sce->val3)
status_heal(src, damage*sce->val4/100, 0, 3);
if( sd && (sce = sc->data[SC_FORCEOFVANGUARD]) && flag&BF_WEAPON && rnd()%100 < sce->val2 )
- pc_addspiritball(sd,skill->get_time(LG_FORCEOFVANGUARD,sce->val1),sce->val3);
+ pc->addspiritball(sd,skill->get_time(LG_FORCEOFVANGUARD,sce->val1),sce->val3);
if (sc->data[SC_STYLE_CHANGE] && rnd()%2) {
TBL_HOM *hd = BL_CAST(BL_HOM,bl);
if (hd) homun->addspiritball(hd, 10); //add a sphere
@@ -1141,7 +2890,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
status_change_spread(bl, src); // Deadly infect attacked side
if( sc && sc->data[SC__SHADOWFORM] ) {
- struct block_list *s_bl = map_id2bl(sc->data[SC__SHADOWFORM]->val2);
+ struct block_list *s_bl = iMap->id2bl(sc->data[SC__SHADOWFORM]->val2);
if( !s_bl || s_bl->m != bl->m ) { // If the shadow form target is not present remove the sc.
status_change_end(bl, SC__SHADOWFORM, INVALID_TIMER);
} else if( status_isdead(s_bl) || !battle->check_target(src,s_bl,BCT_ENEMY)) { // If the shadow form target is dead or not your enemy remove the sc in both.
@@ -1154,7 +2903,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
if( s_bl->type == BL_PC )
((TBL_PC*)s_bl)->shadowform_id = 0;
} else {
- status_damage(bl, s_bl, damage, 0, clif->damage(s_bl, s_bl, gettick(), 500, 500, damage, -1, 0, 0), 0);
+ status_damage(bl, s_bl, damage, 0, clif->damage(s_bl, s_bl, iTimer->gettick(), 500, 500, damage, -1, 0, 0), 0);
return ATK_NONE;
}
}
@@ -1236,9 +2985,9 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
if( bl->type == BL_MOB && !status_isdead(bl) && src != bl) {
if (damage > 0 )
- mobskill_event((TBL_MOB*)bl,src,gettick(),flag);
+ mobskill_event((TBL_MOB*)bl,src,iTimer->gettick(),flag);
if (skill_id)
- mobskill_event((TBL_MOB*)bl,src,gettick(),MSC_SKILLUSED|(skill_id<<16));
+ mobskill_event((TBL_MOB*)bl,src,iTimer->gettick(),MSC_SKILLUSED|(skill_id<<16));
}
if( sd ) {
if( pc_ismadogear(sd) && rnd()%100 < 50 ) {
@@ -1256,7 +3005,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damag
else if( element == -3 ) //Use random element
element = rnd()%ELE_MAX;
if( element == ELE_FIRE || element == ELE_WATER )
- pc_overheat(sd,element == ELE_FIRE ? 1 : -1);
+ pc->overheat(sd,element == ELE_FIRE ? 1 : -1);
}
}
@@ -1353,207 +3102,6 @@ int battle_calc_drain(int damage, int rate, int per) {
}
/*==========================================
- * Passif skill dammages increases
- *------------------------------------------*/
-int battle_addmastery(struct map_session_data *sd,struct block_list *target,int dmg,int type) {
- int damage,skill;
- struct status_data *status = status_get_status_data(target);
- int weapon;
- damage = dmg;
-
- nullpo_ret(sd);
-
- if((skill = pc_checkskill(sd,AL_DEMONBANE)) > 0 &&
- target->type == BL_MOB && //This bonus doesnt work against players.
- (battle->check_undead(status->race,status->def_ele) || status->race==RC_DEMON) )
- damage += (skill*(int)(3+(sd->status.base_level+1)*0.05)); // submitted by orn
- //damage += (skill * 3);
- if( (skill = pc_checkskill(sd, RA_RANGERMAIN)) > 0 && (status->race == RC_BRUTE || status->race == RC_PLANT || status->race == RC_FISH) )
- damage += (skill * 5);
- if( (skill = pc_checkskill(sd,NC_RESEARCHFE)) > 0 && (status->def_ele == ELE_FIRE || status->def_ele == ELE_EARTH) )
- damage += (skill * 10);
- if( pc_ismadogear(sd) )
- damage += 20 + 20 * pc_checkskill(sd, NC_MADOLICENCE);
-
- if((skill = pc_checkskill(sd,HT_BEASTBANE)) > 0 && (status->race==RC_BRUTE || status->race==RC_INSECT) ) {
- damage += (skill * 4);
- if (sd->sc.data[SC_SPIRIT] && sd->sc.data[SC_SPIRIT]->val2 == SL_HUNTER)
- damage += sd->status.str;
- }
-
- if(type == 0)
- weapon = sd->weapontype1;
- else
- weapon = sd->weapontype2;
- switch(weapon)
- {
- case W_1HSWORD:
- #ifdef RENEWAL
- if((skill = pc_checkskill(sd,AM_AXEMASTERY)) > 0)
- damage += (skill * 3);
- #endif
- case W_DAGGER:
- if((skill = pc_checkskill(sd,SM_SWORD)) > 0)
- damage += (skill * 4);
- if((skill = pc_checkskill(sd,GN_TRAINING_SWORD)) > 0)
- damage += skill * 10;
- break;
- case W_2HSWORD:
- #ifdef RENEWAL
- if((skill = pc_checkskill(sd,AM_AXEMASTERY)) > 0)
- damage += (skill * 3);
- #endif
- if((skill = pc_checkskill(sd,SM_TWOHAND)) > 0)
- damage += (skill * 4);
- break;
- case W_1HSPEAR:
- case W_2HSPEAR:
- if((skill = pc_checkskill(sd,KN_SPEARMASTERY)) > 0) {
- if(!pc_isriding(sd))
- damage += (skill * 4);
- else
- damage += (skill * 5);
- }
- break;
- case W_1HAXE:
- case W_2HAXE:
- if((skill = pc_checkskill(sd,AM_AXEMASTERY)) > 0)
- damage += (skill * 3);
- if((skill = pc_checkskill(sd,NC_TRAININGAXE)) > 0)
- damage += (skill * 5);
- break;
- case W_MACE:
- case W_2HMACE:
- if((skill = pc_checkskill(sd,PR_MACEMASTERY)) > 0)
- damage += (skill * 3);
- if((skill = pc_checkskill(sd,NC_TRAININGAXE)) > 0)
- damage += (skill * 5);
- break;
- case W_FIST:
- if((skill = pc_checkskill(sd,TK_RUN)) > 0)
- damage += (skill * 10);
- // No break, fallthrough to Knuckles
- case W_KNUCKLE:
- if((skill = pc_checkskill(sd,MO_IRONHAND)) > 0)
- damage += (skill * 3);
- break;
- case W_MUSICAL:
- if((skill = pc_checkskill(sd,BA_MUSICALLESSON)) > 0)
- damage += (skill * 3);
- break;
- case W_WHIP:
- if((skill = pc_checkskill(sd,DC_DANCINGLESSON)) > 0)
- damage += (skill * 3);
- break;
- case W_BOOK:
- if((skill = pc_checkskill(sd,SA_ADVANCEDBOOK)) > 0)
- damage += (skill * 3);
- break;
- case W_KATAR:
- if((skill = pc_checkskill(sd,AS_KATAR)) > 0)
- damage += (skill * 3);
- break;
- }
-
- return damage;
-}
-/*==========================================
- * Calculates the standard damage of a normal attack assuming it hits,
- * it calculates nothing extra fancy, is needed for magnum break's WATK_ELEMENT bonus. [Skotlex]
- *------------------------------------------
- * Pass damage2 as NULL to not calc it.
- * Flag values:
- * &1: Critical hit
- * &2: Arrow attack
- * &4: Skill is Magic Crasher
- * &8: Skip target size adjustment (Extremity Fist?)
- *&16: Arrow attack but BOW, REVOLVER, RIFLE, SHOTGUN, GATLING or GRENADE type weapon not equipped (i.e. shuriken, kunai and venom knives not affected by DEX)
- */
-int battle_calc_base_damage(struct status_data *status, struct weapon_atk *wa, struct status_change *sc, unsigned short t_size, struct map_session_data *sd, int flag) {
- unsigned int atkmin=0, atkmax=0;
- short type = 0;
- int damage = 0;
-
- if (!sd)
- { //Mobs/Pets
- if(flag&4)
- {
- atkmin = status->matk_min;
- atkmax = status->matk_max;
- } else {
- atkmin = wa->atk;
- atkmax = wa->atk2;
- }
- if (atkmin > atkmax)
- atkmin = atkmax;
- } else { //PCs
- atkmax = wa->atk;
- type = (wa == &status->lhw)?EQI_HAND_L:EQI_HAND_R;
-
- if (!(flag&1) || (flag&2))
- { //Normal attacks
- atkmin = status->dex;
-
- if (sd->equip_index[type] >= 0 && sd->inventory_data[sd->equip_index[type]])
- atkmin = atkmin*(80 + sd->inventory_data[sd->equip_index[type]]->wlv*20)/100;
-
- if (atkmin > atkmax)
- atkmin = atkmax;
-
- if(flag&2 && !(flag&16))
- { //Bows
- atkmin = atkmin*atkmax/100;
- if (atkmin > atkmax)
- atkmax = atkmin;
- }
- }
- }
-
- if (sc && sc->data[SC_MAXIMIZEPOWER])
- atkmin = atkmax;
-
- //Weapon Damage calculation
- if (!(flag&1))
- damage = (atkmax>atkmin? rnd()%(atkmax-atkmin):0)+atkmin;
- else
- damage = atkmax;
-
- if (sd)
- {
- //rodatazone says the range is 0~arrow_atk-1 for non crit
- if (flag&2 && sd->bonus.arrow_atk)
- damage += ( (flag&1) ? sd->bonus.arrow_atk : rnd()%sd->bonus.arrow_atk );
-
- //SizeFix only for players
- if (!(sd->special_state.no_sizefix || (flag&8)))
- damage = damage * ( type == EQI_HAND_L ? sd->left_weapon.atkmods[t_size] : sd->right_weapon.atkmods[t_size] ) / 100;
- }
-
- //Finally, add baseatk
- if(flag&4)
- damage += status->matk_min;
- else
- damage += status->batk;
-
- //rodatazone says that Overrefine bonuses are part of baseatk
- //Here we also apply the weapon_atk_rate bonus so it is correctly applied on left/right hands.
- if(sd) {
- if (type == EQI_HAND_L) {
- if(sd->left_weapon.overrefine)
- damage += rnd()%sd->left_weapon.overrefine+1;
- if (sd->weapon_atk_rate[sd->weapontype2])
- damage += damage * sd->weapon_atk_rate[sd->weapontype2] / 100;
- } else { //Right hand
- if(sd->right_weapon.overrefine)
- damage += rnd()%sd->right_weapon.overrefine+1;
- if (sd->weapon_atk_rate[sd->weapontype1])
- damage += damage * sd->weapon_atk_rate[sd->weapontype1] / 100;
- }
- }
- return damage;
-}
-
-/*==========================================
* Consumes ammo for the given skill.
*------------------------------------------*/
void battle_consume_ammo(TBL_PC*sd, int skill_id, int lv) {
@@ -1567,7 +3115,7 @@ void battle_consume_ammo(TBL_PC*sd, int skill_id, int lv) {
}
if(sd->equip_index[EQI_AMMO]>=0) //Qty check should have been done in skill_check_condition
- pc_delitem(sd,sd->equip_index[EQI_AMMO],qty,0,1,LOG_TYPE_CONSUME);
+ pc->delitem(sd,sd->equip_index[EQI_AMMO],qty,0,1,LOG_TYPE_CONSUME);
sd->state.arrow_atk = 0;
}
@@ -1610,10 +3158,736 @@ int battle_blewcount_bonus(struct map_session_data *sd, uint16 skill_id) {
}
return 0;
}
-
//For quick div adjustment.
#define damage_div_fix(dmg, div) { if (div > 1) (dmg)*=div; else if (div < 0) (div)*=-1; }
/*==========================================
+ * battle_calc_magic_attack [DracoRPG]
+ *------------------------------------------*/
+struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int mflag) {
+ int i, nk;
+ short s_ele = 0;
+ unsigned int skillratio = 100; //Skill dmg modifiers.
+
+ TBL_PC *sd;
+// TBL_PC *tsd;
+ struct status_change *sc, *tsc;
+ struct Damage ad;
+ struct status_data *sstatus = status_get_status_data(src);
+ struct status_data *tstatus = status_get_status_data(target);
+ struct {
+ unsigned imdef : 1;
+ unsigned infdef : 1;
+ } flag;
+
+ memset(&ad,0,sizeof(ad));
+ memset(&flag,0,sizeof(flag));
+
+ if(src==NULL || target==NULL)
+ {
+ nullpo_info(NLP_MARK);
+ return ad;
+ }
+ //Initial Values
+ ad.damage = 1;
+ ad.div_=skill->get_num(skill_id,skill_lv);
+ ad.amotion=skill->get_inf(skill_id)&INF_GROUND_SKILL?0:sstatus->amotion; //Amotion should be 0 for ground skills.
+ ad.dmotion=tstatus->dmotion;
+ ad.blewcount = skill->get_blewcount(skill_id,skill_lv);
+ ad.flag=BF_MAGIC|BF_SKILL;
+ ad.dmg_lv=ATK_DEF;
+ nk = skill->get_nk(skill_id);
+ flag.imdef = nk&NK_IGNORE_DEF?1:0;
+
+ sd = BL_CAST(BL_PC, src);
+// tsd = BL_CAST(BL_PC, target);
+ sc = status_get_sc(src);
+ tsc = status_get_sc(target);
+
+ //Initialize variables that will be used afterwards
+ s_ele = skill->get_ele(skill_id, skill_lv);
+
+ if (s_ele == -1){ // pl=-1 : the skill takes the weapon's element
+ s_ele = sstatus->rhw.ele;
+ if( sd ){ //Summoning 10 charm will endow your weapon
+ ARR_FIND(1, 6, i, sd->charm[i] >= 10);
+ if( i < 5 ) s_ele = i;
+ }
+ }else if (s_ele == -2) //Use status element
+ s_ele = status_get_attack_sc_element(src,status_get_sc(src));
+ else if( s_ele == -3 ) //Use random element
+ s_ele = rnd()%ELE_MAX;
+
+ if( skill_id == SO_PSYCHIC_WAVE ) {
+ if( sc && sc->count ) {
+ if( sc->data[SC_HEATER_OPTION] ) s_ele = sc->data[SC_HEATER_OPTION]->val4;
+ else if( sc->data[SC_COOLER_OPTION] ) s_ele = sc->data[SC_COOLER_OPTION]->val4;
+ else if( sc->data[SC_BLAST_OPTION] ) s_ele = sc->data[SC_BLAST_OPTION]->val3;
+ else if( sc->data[SC_CURSED_SOIL_OPTION] ) s_ele = sc->data[SC_CURSED_SOIL_OPTION]->val4;
+ }
+ }
+
+ //Set miscellaneous data that needs be filled
+ if(sd) {
+ sd->state.arrow_atk = 0;
+ ad.blewcount += battle->blewcount_bonus(sd, skill_id);
+ }
+
+ //Skill Range Criteria
+ ad.flag |= battle->range_type(src, target, skill_id, skill_lv);
+ flag.infdef=(tstatus->mode&MD_PLANT?1:0);
+ if( target->type == BL_SKILL){
+ TBL_SKILL *su = (TBL_SKILL*)target;
+ if( su->group && (su->group->skill_id == WM_REVERBERATION || su->group->skill_id == WM_POEMOFNETHERWORLD) )
+ flag.infdef = 1;
+ }
+
+ switch(skill_id) {
+ case MG_FIREWALL:
+ case NJ_KAENSIN:
+ ad.dmotion = 0; //No flinch animation.
+ if ( tstatus->def_ele == ELE_FIRE || battle->check_undead(tstatus->race, tstatus->def_ele) )
+ ad.blewcount = 0; //No knockback
+ break;
+ case PR_SANCTUARY:
+ ad.dmotion = 0; //No flinch animation.
+ break;
+ case WL_HELLINFERNO:
+ if( mflag&ELE_DARK )
+ s_ele = ELE_DARK;
+ break;
+ case KO_KAIHOU:
+ if( sd ){
+ ARR_FIND(1, 6, i, sd->charm[i] > 0);
+ if( i < 5 )
+ s_ele = i;
+ }
+ break;
+#ifdef RENEWAL
+ case CR_ACIDDEMONSTRATION:
+ case ASC_BREAKER:
+ case HW_MAGICCRASHER:
+ flag.imdef = 1;
+ break;
+#endif
+ }
+
+ if (!flag.infdef) //No need to do the math for plants
+ {
+#ifdef RENEWAL
+ ad.damage = 0; //reinitialize..
+#endif
+//MATK_RATE scales the damage. 100 = no change. 50 is halved, 200 is doubled, etc
+#define MATK_RATE( a ) { ad.damage= ad.damage*(a)/100; }
+//Adds dmg%. 100 = +100% (double) damage. 10 = +10% damage
+#define MATK_ADDRATE( a ) { ad.damage+= ad.damage*(a)/100; }
+//Adds an absolute value to damage. 100 = +100 damage
+#define MATK_ADD( a ) { ad.damage+= a; }
+
+ switch (skill_id)
+ { //Calc base damage according to skill
+ case AL_HEAL:
+ case PR_BENEDICTIO:
+ case PR_SANCTUARY:
+ /**
+ * Arch Bishop
+ **/
+ case AB_HIGHNESSHEAL:
+ ad.damage = skill->calc_heal(src, target, skill_id, skill_lv, false);
+ break;
+ case PR_ASPERSIO:
+ ad.damage = 40;
+ break;
+ case ALL_RESURRECTION:
+ case PR_TURNUNDEAD:
+ //Undead check is on skill_castend_damageid code.
+ i = 20*skill_lv + sstatus->luk + sstatus->int_ + status_get_lv(src)
+ + 200 - 200*tstatus->hp/tstatus->max_hp; // there is no changed in success chance in renewal. [malufett]
+ if(i > 700) i = 700;
+ if(rnd()%1000 < i && !(tstatus->mode&MD_BOSS))
+ ad.damage = tstatus->hp;
+ else {
+ #ifdef RENEWAL
+ MATK_ADD(status_get_matk(src, 2));
+ #else
+ ad.damage = status_get_lv(src) + sstatus->int_ + skill_lv * 10;
+ #endif
+ }
+ break;
+ case PF_SOULBURN:
+ ad.damage = tstatus->sp * 2;
+ break;
+ /**
+ * Arch Bishop
+ **/
+ case AB_RENOVATIO:
+ //Damage calculation from iRO wiki. [Jobbie]
+ ad.damage = (int)((15 * status_get_lv(src)) + (1.5 * sstatus->int_));
+ break;
+ default: {
+ MATK_ADD( status_get_matk(src, 2) );
+
+ if (nk&NK_SPLASHSPLIT) { // Divide MATK in case of multiple targets skill
+ if(mflag>0)
+ ad.damage/= mflag;
+ else
+ ShowError("0 enemies targeted by %d:%s, divide per 0 avoided!\n", skill_id, skill->get_name(skill_id));
+ }
+
+ if (sc){
+ if( sc->data[SC_TELEKINESIS_INTENSE] && s_ele == ELE_GHOST )
+ skillratio += sc->data[SC_TELEKINESIS_INTENSE]->val3;
+ }
+ switch(skill_id){
+ case MG_FIREBOLT:
+ case MG_COLDBOLT:
+ case MG_LIGHTNINGBOLT:
+ if ( sc && sc->data[SC_SPELLFIST] && mflag&BF_SHORT ) {
+ skillratio += (sc->data[SC_SPELLFIST]->val4 * 100) + (sc->data[SC_SPELLFIST]->val2 * 100) - 100;// val4 = used bolt level, val2 = used spellfist level. [Rytech]
+ ad.div_ = 1;// ad mods, to make it work similar to regular hits [Xazax]
+ ad.flag = BF_WEAPON|BF_SHORT;
+ ad.type = 0;
+ }
+ break;
+ default:
+ MATK_RATE(battle->calc_skillratio(BF_MAGIC, src, target, skill_id, skill_lv, skillratio, mflag));
+ }
+ //Constant/misc additions from skills
+ if (skill_id == WZ_FIREPILLAR)
+ MATK_ADD(50);
+ if( sd && (i=pc->checkskill(sd,AB_EUCHARISTICA)) > 0 &&
+ (tstatus->race == RC_DEMON || tstatus->def_ele == ELE_DARK) )
+ MATK_ADDRATE(i);
+ }
+ }
+#ifndef HMAP_ZONE_DAMAGE_CAP_TYPE
+ if( target && skill_id ) {
+ for(i = 0; i < map[target->m].zone->capped_skills_count; i++) {
+ if( skill_id == map[target->m].zone->capped_skills[i]->nameid && (map[target->m].zone->capped_skills[i]->type & target->type) ) {
+ if( target->type == BL_MOB && map[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) {
+ if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) )
+ continue;
+ if( ((TBL_MOB*)target)->special_state.clone && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) )
+ continue;
+ }
+ if( ad.damage > map[target->m].zone->capped_skills[i]->cap )
+ ad.damage = map[target->m].zone->capped_skills[i]->cap;
+ if( ad.damage2 > map[target->m].zone->capped_skills[i]->cap )
+ ad.damage2 = map[target->m].zone->capped_skills[i]->cap;
+ break;
+ }
+ }
+ }
+#endif
+/* temporarily disabling until malufett can adjust */
+//#ifdef RENEWAL
+// ad.damage = battle->calc_cardfix(BF_MAGIC, src, target, nk, s_ele, 0, ad.damage, 0, ad.flag);
+//#endif
+ if(sd) {
+ //Damage bonuses
+ if ((i = pc->skillatk_bonus(sd, skill_id)))
+ ad.damage += ad.damage*i/100;
+
+ if( (i = battle->adjust_skill_damage(src->m,skill_id)) )
+ MATK_RATE(i);
+
+ //Ignore Defense?
+ if (!flag.imdef && (
+ sd->bonus.ignore_mdef_ele & ( 1 << tstatus->def_ele ) ||
+ sd->bonus.ignore_mdef_race & ( 1 << tstatus->race ) ||
+ sd->bonus.ignore_mdef_race & ( is_boss(target) ? 1 << RC_BOSS : 1 << RC_NONBOSS )
+ ))
+ flag.imdef = 1;
+ }
+
+ ad.damage = battle->calc_defense(BF_MAGIC, src, target, skill_id, skill_lv, ad.damage, (flag.imdef?1:0), 0);
+
+ if (skill_id == NPC_EARTHQUAKE)
+ { //Adds atk2 to the damage, should be influenced by number of hits and skill-ratio, but not mdef reductions. [Skotlex]
+ //Also divide the extra bonuses from atk2 based on the number in range [Kevin]
+ if(mflag>0)
+ ad.damage+= (sstatus->rhw.atk2*skillratio/100)/mflag;
+ else
+ ShowError("Zero range by %d:%s, divide per 0 avoided!\n", skill_id, skill->get_name(skill_id));
+ }
+
+ if(ad.damage<1)
+ ad.damage=1;
+ else if(sc){//only applies when hit
+ // TODO: there is another factor that contribute with the damage and need to be formulated. [malufett]
+ switch(skill_id){
+ case MG_LIGHTNINGBOLT:
+ case MG_THUNDERSTORM:
+ case MG_FIREBOLT:
+ case MG_FIREWALL:
+ case MG_COLDBOLT:
+ case MG_FROSTDIVER:
+ case WZ_EARTHSPIKE:
+ case WZ_HEAVENDRIVE:
+ if(sc->data[SC_GUST_OPTION] || sc->data[SC_PETROLOGY_OPTION]
+ || sc->data[SC_PYROTECHNIC_OPTION] || sc->data[SC_AQUAPLAY_OPTION])
+ ad.damage += (6 + sstatus->int_/4) + max(sstatus->dex-10,0)/30;
+ break;
+ }
+ }
+
+ if (!(nk&NK_NO_ELEFIX))
+ ad.damage=battle->attr_fix(src, target, ad.damage, s_ele, tstatus->def_ele, tstatus->ele_lv);
+
+ if( skill_id == CR_GRANDCROSS || skill_id == NPC_GRANDDARKNESS )
+ { //Apply the physical part of the skill's damage. [Skotlex]
+ struct Damage wd = battle->calc_weapon_attack(src,target,skill_id,skill_lv,mflag);
+ ad.damage = battle->attr_fix(src, target, wd.damage + ad.damage, s_ele, tstatus->def_ele, tstatus->ele_lv) * (100 + 40*skill_lv)/100;
+ if( src == target )
+ {
+ if( src->type == BL_PC )
+ ad.damage = ad.damage/2;
+ else
+ ad.damage = 0;
+ }
+ }
+/* temporarily making global until malufett can adjust */
+//#ifndef RENEWAL
+ ad.damage = battle->calc_cardfix(BF_MAGIC, src, target, nk, s_ele, 0, ad.damage, 0, ad.flag);
+//#endif
+ }
+
+ damage_div_fix(ad.damage, ad.div_);
+
+ if (flag.infdef && ad.damage)
+ ad.damage = ad.damage>0?1:-1;
+
+ ad.damage=battle->calc_damage(src,target,&ad,ad.damage,skill_id,skill_lv);
+ if( map_flag_gvg2(target->m) )
+ ad.damage=battle->calc_gvg_damage(src,target,ad.damage,ad.div_,skill_id,skill_lv,ad.flag);
+ else if( map[target->m].flag.battleground )
+ ad.damage=battle->calc_bg_damage(src,target,ad.damage,ad.div_,skill_id,skill_lv,ad.flag);
+
+ switch( skill_id ) { /* post-calc modifiers */
+ case SO_VARETYR_SPEAR: { // Physical damage.
+ struct Damage wd = battle->calc_weapon_attack(src,target,skill_id,skill_lv,mflag);
+ if(!flag.infdef && ad.damage > 1)
+ ad.damage += wd.damage;
+ break;
+ }
+ //case HM_ERASER_CUTTER:
+ }
+
+ return ad;
+}
+
+/*==========================================
+ * Calculate Misc dammage for skill_id
+ *------------------------------------------*/
+struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int mflag) {
+ int temp;
+ short i, nk;
+ short s_ele;
+
+ struct map_session_data *sd, *tsd;
+ struct Damage md; //DO NOT CONFUSE with md of mob_data!
+ struct status_data *sstatus = status_get_status_data(src);
+ struct status_data *tstatus = status_get_status_data(target);
+ struct status_change *tsc = status_get_sc(target);
+#ifdef RENEWAL
+ struct status_change *sc = status_get_sc(src);
+#endif
+
+ memset(&md,0,sizeof(md));
+
+ if( src == NULL || target == NULL ){
+ nullpo_info(NLP_MARK);
+ return md;
+ }
+
+ //Some initial values
+ md.amotion=skill->get_inf(skill_id)&INF_GROUND_SKILL?0:sstatus->amotion;
+ md.dmotion=tstatus->dmotion;
+ md.div_=skill->get_num( skill_id,skill_lv );
+ md.blewcount=skill->get_blewcount(skill_id,skill_lv);
+ md.dmg_lv=ATK_DEF;
+ md.flag=BF_MISC|BF_SKILL;
+
+ nk = skill->get_nk(skill_id);
+
+ sd = BL_CAST(BL_PC, src);
+ tsd = BL_CAST(BL_PC, target);
+
+ if(sd) {
+ sd->state.arrow_atk = 0;
+ md.blewcount += battle->blewcount_bonus(sd, skill_id);
+ }
+
+ s_ele = skill->get_ele(skill_id, skill_lv);
+ if (s_ele < 0 && s_ele != -3) //Attack that takes weapon's element for misc attacks? Make it neutral [Skotlex]
+ s_ele = ELE_NEUTRAL;
+ else if (s_ele == -3) //Use random element
+ s_ele = rnd()%ELE_MAX;
+
+ //Skill Range Criteria
+ md.flag |= battle->range_type(src, target, skill_id, skill_lv);
+
+ switch( skill_id )
+ {
+#ifdef RENEWAL
+ case HT_LANDMINE:
+ case MA_LANDMINE:
+ case HT_BLASTMINE:
+ case HT_CLAYMORETRAP:
+ md.damage = skill_lv * sstatus->dex * (3+status_get_lv(src)/100) * (1+sstatus->int_/35);
+ md.damage += md.damage * (rnd()%20-10) / 100;
+ md.damage += 40 * (sd?pc->checkskill(sd,RA_RESEARCHTRAP):0);
+ break;
+#else
+ case HT_LANDMINE:
+ case MA_LANDMINE:
+ md.damage=skill_lv*(sstatus->dex+75)*(100+sstatus->int_)/100;
+ break;
+ case HT_BLASTMINE:
+ md.damage=skill_lv*(sstatus->dex/2+50)*(100+sstatus->int_)/100;
+ break;
+ case HT_CLAYMORETRAP:
+ md.damage=skill_lv*(sstatus->dex/2+75)*(100+sstatus->int_)/100;
+ break;
+#endif
+ case HT_BLITZBEAT:
+ case SN_FALCONASSAULT:
+ //Blitz-beat Damage.
+ if(!sd || (temp = pc->checkskill(sd,HT_STEELCROW)) <= 0)
+ temp=0;
+ md.damage=(sstatus->dex/10+sstatus->int_/2+temp*3+40)*2;
+ if(mflag > 1) //Autocasted Blitz.
+ nk|=NK_SPLASHSPLIT;
+
+ if (skill_id == SN_FALCONASSAULT) {
+ //Div fix of Blitzbeat
+ temp = skill->get_num(HT_BLITZBEAT, 5);
+ damage_div_fix(md.damage, temp);
+
+ //Falcon Assault Modifier
+ md.damage=md.damage*(150+70*skill_lv)/100;
+ }
+ break;
+ case TF_THROWSTONE:
+ md.damage=50;
+ break;
+ case BA_DISSONANCE:
+ md.damage=30+skill_lv*10;
+ if (sd)
+ md.damage+= 3*pc->checkskill(sd,BA_MUSICALLESSON);
+ break;
+ case NPC_SELFDESTRUCTION:
+ md.damage = sstatus->hp;
+ break;
+ case NPC_SMOKING:
+ md.damage=3;
+ break;
+ case NPC_DARKBREATH:
+ md.damage = 500 + (skill_lv-1)*1000 + rnd()%1000;
+ if(md.damage > 9999) md.damage = 9999;
+ break;
+ case PA_PRESSURE:
+ md.damage=500+300*skill_lv;
+ break;
+ case PA_GOSPEL:
+ md.damage = 1+rnd()%9999;
+ break;
+ case CR_ACIDDEMONSTRATION:
+/* modifying until malufett can adjust the formula */
+//#ifdef RENEWAL
+#if 0
+ {// [malufett]
+ int matk=0, atk;
+ short tdef = status_get_total_def(target);
+ short tmdef = status_get_total_mdef(target);
+ int targetVit = min(120, status_get_vit(target));
+ short totaldef = (tmdef + tdef - ((uint64)(tmdef + tdef) >> 32)) >> 1;
+
+ matk = battle->calc_magic_attack(src, target, skill_id, skill_lv, mflag).damage;
+ atk = battle->calc_base_damage(src, target, skill_id, skill_lv, nk, false, s_ele, ELE_NEUTRAL, EQI_HAND_R, (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0), md.flag);
+ md.damage = matk + atk;
+ if( src->type == BL_MOB ){
+ totaldef = (tdef + tmdef) >> 1;
+ md.damage = 7 * targetVit * skill_lv * (atk + matk) / 100;
+ /*
+ // Pending [malufett]
+ if( unknown condition )
+ md.damage >>= 1;
+ if( unknown condition ){
+ md.damage = 7 * md.damage % 20;
+ md.damage = 7 * md.damage / 20;
+ }*/
+ }else{
+ float vitfactor = 0.0f, temp;
+
+ if( (vitfactor=(status_get_vit(target)-120.0f)) > 0)
+ vitfactor = (vitfactor * (matk + atk) / 10) / status_get_vit(target);
+ temp = max(0, vitfactor) + (targetVit * (matk + atk)) / 10;
+ md.damage = (int)(temp * 70 * skill_lv / 100);
+ }
+ md.damage -= totaldef;
+ }
+#else
+ // updated the formula based on a Japanese formula found to be exact [Reddozen]
+ if(tstatus->vit+sstatus->int_) //crash fix
+ md.damage = (int)(7*tstatus->vit*sstatus->int_*sstatus->int_ / (10*(tstatus->vit+sstatus->int_)));
+ else
+ md.damage = 0;
+ if (tsd) md.damage>>=1;
+#endif
+ if (md.damage < 0 || md.damage > INT_MAX>>1)
+ //Overflow prevention, will anyone whine if I cap it to a few billion?
+ //Not capped to INT_MAX to give some room for further damage increase.
+ md.damage = INT_MAX>>1;
+ break;
+
+ case KO_MUCHANAGE:
+ md.damage = skill->get_zeny(skill_id ,skill_lv);
+ md.damage = md.damage * (50 + rand()%50) / 100;
+ if ( is_boss(target) || (sd && !pc->checkskill(sd,NJ_TOBIDOUGU)) )
+ md.damage >>= 1;
+ break;
+ case NJ_ZENYNAGE:
+ md.damage = skill->get_zeny(skill_id ,skill_lv);
+ if (!md.damage) md.damage = 2;
+ md.damage = rand()%md.damage + md.damage;
+ if (is_boss(target))
+ md.damage=md.damage / 3;
+ else if (tsd)
+ md.damage=md.damage / 2;
+ break;
+ case GS_FLING:
+ md.damage = sd?sd->status.job_level:status_get_lv(src);
+ break;
+ case HVAN_EXPLOSION: //[orn]
+ md.damage = sstatus->max_hp * (50 + 50 * skill_lv) / 100;
+ break ;
+ case ASC_BREAKER:
+ {
+/* modifying until malufett can adjust the formula */
+//#ifndef RENEWAL
+#if 1
+ md.damage = 500+rnd()%500 + 5*skill_lv * sstatus->int_;
+ nk|=NK_IGNORE_FLEE|NK_NO_ELEFIX; //These two are not properties of the weapon based part.
+#else
+ int ratio = 300 + 50 * skill_lv;
+ int matk = battle->calc_magic_attack(src, target, skill_id, skill_lv, mflag).damage;
+ short totaldef = status_get_total_def(target) + status_get_total_mdef(target);
+ int atk = battle->calc_base_damage(src, target, skill_id, skill_lv, nk, false, s_ele, ELE_NEUTRAL, EQI_HAND_R, (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0), md.flag);
+
+ if( sc && sc->data[SC_EDP] )
+ ratio >>= 1;
+ md.damage = (matk + atk) * ratio / 100;
+ md.damage -= totaldef;
+#endif
+ }
+ break;
+ case HW_GRAVITATION:
+ md.damage = 200+200*skill_lv;
+ md.dmotion = 0; //No flinch animation.
+ break;
+ case NPC_EVILLAND:
+ md.damage = skill->calc_heal(src,target,skill_id,skill_lv,false);
+ break;
+ case RK_DRAGONBREATH:
+ case RK_DRAGONBREATH_WATER:
+ md.damage = ((status_get_hp(src) / 50) + (status_get_max_sp(src) / 4)) * skill_lv;
+ RE_LVL_MDMOD(150);
+ if (sd) md.damage = md.damage * (100 + 5 * (pc->checkskill(sd,RK_DRAGONTRAINING) - 1)) / 100;
+ md.flag |= BF_LONG|BF_WEAPON;
+ break;
+ /**
+ * Ranger
+ **/
+ case RA_CLUSTERBOMB:
+ case RA_FIRINGTRAP:
+ case RA_ICEBOUNDTRAP:
+ md.damage = skill_lv * sstatus->dex + sstatus->int_ * 5 ;
+ RE_LVL_TMDMOD();
+ if(sd)
+ {
+ int researchskill_lv = pc->checkskill(sd,RA_RESEARCHTRAP);
+ if(researchskill_lv)
+ md.damage = md.damage * 20 * researchskill_lv / (skill_id == RA_CLUSTERBOMB?50:100);
+ else
+ md.damage = 0;
+ }else
+ md.damage = md.damage * 200 / (skill_id == RA_CLUSTERBOMB?50:100);
+
+ break;
+ /**
+ * Mechanic
+ **/
+ case NC_SELFDESTRUCTION:
+ {
+#ifdef RENEWAL
+ short totaldef = status_get_total_def(target);
+#else
+ short totaldef = tstatus->def2 + (short)status_get_def(target);
+#endif
+ md.damage = ( (sd?pc->checkskill(sd,NC_MAINFRAME):10) + 8 ) * ( skill_lv + 1 ) * ( status_get_sp(src) + sstatus->vit );
+ RE_LVL_MDMOD(100);
+ md.damage += status_get_hp(src) - totaldef;
+ }
+ break;
+ case NC_MAGMA_ERUPTION:
+ md.damage = 1200 + 400 * skill_lv;
+ break;
+ case GN_THORNS_TRAP:
+ md.damage = 100 + 200 * skill_lv + sstatus->int_;
+ break;
+ case GN_HELLS_PLANT_ATK:
+ //[{( Hell Plant Skill Level x Casters Base Level ) x 10 } + {( Casters INT x 7 ) / 2 } x { 18 + ( Casters Job Level / 4 )] x ( 5 / ( 10 - Summon Flora Skill Level ))
+ md.damage = ( skill_lv * status_get_lv(src) * 10 ) + ( sstatus->int_ * 7 / 2 ) * ( 18 + (sd?sd->status.job_level:0) / 4 ) * ( 5 / (10 - (sd?pc->checkskill(sd,AM_CANNIBALIZE):0)) );
+ break;
+ case KO_HAPPOKUNAI:
+ {
+ struct Damage wd = battle->calc_weapon_attack(src,target,skill_id,skill_lv,mflag);
+#ifdef RENEWAL
+ short totaldef = status_get_total_def(target);
+#else
+ short totaldef = tstatus->def2 + (short)status_get_def(target);
+#endif
+ md.damage = 3 * wd.damage * (5 + skill_lv) / 5;
+ md.damage -= totaldef;
+ }
+ break;
+ }
+
+ if (nk&NK_SPLASHSPLIT){ // Divide ATK among targets
+ if(mflag>0)
+ md.damage/= mflag;
+ else
+ ShowError("0 enemies targeted by %d:%s, divide per 0 avoided!\n", skill_id, skill->get_name(skill_id));
+ }
+
+ damage_div_fix(md.damage, md.div_);
+
+ if (!(nk&NK_IGNORE_FLEE))
+ {
+ i = 0; //Temp for "hit or no hit"
+ if(tsc && tsc->opt1 && tsc->opt1 != OPT1_STONEWAIT && tsc->opt1 != OPT1_BURNING)
+ i = 1;
+ else {
+ short
+ flee = tstatus->flee,
+#ifdef RENEWAL
+ hitrate = 0; //Default hitrate
+#else
+ hitrate = 80; //Default hitrate
+#endif
+
+ if(battle_config.agi_penalty_type && battle_config.agi_penalty_target&target->type) {
+ unsigned char attacker_count; //256 max targets should be a sane max
+ attacker_count = unit_counttargeted(target);
+ if(attacker_count >= battle_config.agi_penalty_count)
+ {
+ if (battle_config.agi_penalty_type == 1)
+ flee = (flee * (100 - (attacker_count - (battle_config.agi_penalty_count - 1))*battle_config.agi_penalty_num))/100;
+ else //asume type 2: absolute reduction
+ flee -= (attacker_count - (battle_config.agi_penalty_count - 1))*battle_config.agi_penalty_num;
+ if(flee < 1) flee = 1;
+ }
+ }
+
+ hitrate+= sstatus->hit - flee;
+#ifdef RENEWAL
+ if( sd ) //in Renewal hit bonus from Vultures Eye is not anymore shown in status window
+ hitrate += pc->checkskill(sd,AC_VULTURE);
+#endif
+ if( skill_id == KO_MUCHANAGE )
+ hitrate = (int)((10 - ((float)1 / (status_get_dex(src) + status_get_luk(src))) * 500) * ((float)skill_lv / 2 + 5));
+
+ hitrate = cap_value(hitrate, battle_config.min_hitrate, battle_config.max_hitrate);
+
+ if(rnd()%100 < hitrate)
+ i = 1;
+ }
+ if (!i) {
+ md.damage = 0;
+ md.dmg_lv=ATK_FLEE;
+ }
+ }
+#ifndef HMAP_ZONE_DAMAGE_CAP_TYPE
+ if( target && skill_id ) {
+ for(i = 0; i < map[target->m].zone->capped_skills_count; i++) {
+ if( skill_id == map[target->m].zone->capped_skills[i]->nameid && (map[target->m].zone->capped_skills[i]->type & target->type) ) {
+ if( target->type == BL_MOB && map[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) {
+ if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) )
+ continue;
+ if( ((TBL_MOB*)target)->special_state.clone && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) )
+ continue;
+ }
+ if( md.damage > map[target->m].zone->capped_skills[i]->cap )
+ md.damage = map[target->m].zone->capped_skills[i]->cap;
+ if( md.damage2 > map[target->m].zone->capped_skills[i]->cap )
+ md.damage2 = map[target->m].zone->capped_skills[i]->cap;
+ break;
+ }
+ }
+ }
+#endif
+ md.damage = battle->calc_cardfix(BF_MISC, src, target, nk, s_ele, 0, md.damage, 0, md.flag);
+
+ if (sd && (i = pc->skillatk_bonus(sd, skill_id)))
+ md.damage += md.damage*i/100;
+
+ if( (i = battle->adjust_skill_damage(src->m,skill_id)) )
+ md.damage = md.damage * i / 100;
+
+ if(md.damage < 0)
+ md.damage = 0;
+ else if(md.damage && tstatus->mode&MD_PLANT){
+ switch(skill_id){
+ case HT_LANDMINE:
+ case MA_LANDMINE:
+ case HT_BLASTMINE:
+ case HT_CLAYMORETRAP:
+ case RA_CLUSTERBOMB:
+#ifdef RENEWAL
+ break;
+#endif
+ default:
+ md.damage = 1;
+ }
+ }else if( target->type == BL_SKILL ){
+ TBL_SKILL *su = (TBL_SKILL*)target;
+ if( su->group && (su->group->skill_id == WM_REVERBERATION || su->group->skill_id == WM_POEMOFNETHERWORLD) )
+ md.damage = 1;
+ }
+
+ if(!(nk&NK_NO_ELEFIX))
+ md.damage=battle->attr_fix(src, target, md.damage, s_ele, tstatus->def_ele, tstatus->ele_lv);
+
+ md.damage=battle->calc_damage(src,target,&md,md.damage,skill_id,skill_lv);
+ if( map_flag_gvg2(target->m) )
+ md.damage=battle->calc_gvg_damage(src,target,md.damage,md.div_,skill_id,skill_lv,md.flag);
+ else if( map[target->m].flag.battleground )
+ md.damage=battle->calc_bg_damage(src,target,md.damage,md.div_,skill_id,skill_lv,md.flag);
+
+ switch( skill_id ) {
+ case RA_FIRINGTRAP:
+ case RA_ICEBOUNDTRAP:
+ if( md.damage == 1 ) break;
+ case RA_CLUSTERBOMB:
+ {
+ struct Damage wd;
+ wd = battle->calc_weapon_attack(src,target,skill_id,skill_lv,mflag);
+ md.damage += wd.damage;
+ }
+ break;
+ case NJ_ZENYNAGE:
+ if( sd ) {
+ if ( md.damage > sd->status.zeny )
+ md.damage = sd->status.zeny;
+ pc->payzeny(sd, md.damage,LOG_TYPE_STEAL,NULL);
+ }
+ break;
+ }
+
+ return md;
+}
+
+/*==========================================
* battle_calc_weapon_attack (by Skotlex)
*------------------------------------------*/
struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int wflag)
@@ -1642,6 +3916,9 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
unsigned rh : 1; //Attack considers right hand (wd.damage)
unsigned lh : 1; //Attack considers left hand (wd.damage2)
unsigned weapon : 1; //It's a weapon attack (consider VVS, and all that)
+#ifdef RENEWAL
+ unsigned tdef : 1; //Total defence reduction
+#endif
} flag;
memset(&wd,0,sizeof(wd));
@@ -1682,7 +3959,9 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
nk |= NK_NO_CARDFIX_ATK|NK_IGNORE_FLEE;
flag.hit = nk&NK_IGNORE_FLEE?1:0;
flag.idef = flag.idef2 = nk&NK_IGNORE_DEF?1:0;
-
+#ifdef RENEWAL
+ flag.tdef = 0;
+#endif
if (sc && !sc->count)
sc = NULL; //Skip checking as there are no status changes active.
if (tsc && !tsc->count)
@@ -1756,10 +4035,23 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
case LK_SPIRALPIERCE:
if (!sd) wd.flag=(wd.flag&~(BF_RANGEMASK|BF_WEAPONMASK))|BF_LONG|BF_MISC;
break;
+
+ case MO_INVESTIGATE:
+ flag.pdef = flag.pdef2 = 2;
+ break;
+
+ case RA_AIMEDBOLT:
+ if( tsc && (tsc->data[SC_WUGBITE] || tsc->data[SC_ANKLESNARE] || tsc->data[SC_ELECTRICSHOCKER]) )
+ wd.div_ = tstatus->size + 2 + ( (rnd()%100 < 50-tstatus->size*10) ? 1 : 0 );
+ break;
+#ifdef RENEWAL
+ case HW_MAGICCRASHER:
+ flag.tdef = 1;
+ break;
+#endif
}
} else //Range for normal attacks.
wd.flag |= flag.arrow?BF_LONG:BF_SHORT;
-
if ( (!skill_id || skill_id == PA_SACRIFICE) && tstatus->flee2 && rnd()%1000 < tstatus->flee2 )
{ //Check for Lucky Dodge
wd.type=0x0b;
@@ -1774,8 +4066,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
{ //Take weapon's element
s_ele = sstatus->rhw.ele;
s_ele_ = sstatus->lhw.ele;
- if( sd ){ //Summoning 10 talisman will endow your weapon.
- ARR_FIND(1, 6, i, sd->talisman[i] >= 10);
+ if( sd ){ //Summoning 10 charm will endow your weapon.
+ ARR_FIND(1, 6, i, sd->charm[i] >= 10);
if( i < 5 ) s_ele = s_ele_ = i;
}
if( flag.arrow && sd && sd->bonus.arrow_ele )
@@ -1817,7 +4109,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
}
if( sd && !skill_id ) { //Check for double attack.
- if( ( ( skill_lv = pc_checkskill(sd,TF_DOUBLE) ) > 0 && sd->weapontype1 == W_DAGGER )
+ if( ( ( skill_lv = pc->checkskill(sd,TF_DOUBLE) ) > 0 && sd->weapontype1 == W_DAGGER )
|| ( sd->bonus.double_rate > 0 && sd->weapontype1 != W_FIST ) //Will fail bare-handed
|| ( sc && sc->data[SC_KAGEMUSYA] && sd->weapontype1 != W_FIST )) // Need confirmation
{ //Success chance is not added, the higher one is used [Skotlex]
@@ -1827,7 +4119,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
wd.type = 0x08;
}
}
- else if( sd->weapontype1 == W_REVOLVER && (skill_lv = pc_checkskill(sd,GS_CHAINACTION)) > 0 && rnd()%100 < 5*skill_lv )
+ else if( sd->weapontype1 == W_REVOLVER && (skill_lv = pc->checkskill(sd,GS_CHAINACTION)) > 0 && rnd()%100 < 5*skill_lv )
{
wd.div_ = skill->get_num(GS_CHAINACTION,skill_lv);
wd.type = 0x08;
@@ -1880,9 +4172,13 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
}
if( sc && sc->data[SC_CAMOUFLAGE] )
cri += 10 * (10-sc->data[SC_CAMOUFLAGE]->val4);
+#ifndef RENEWAL
//The official equation is *2, but that only applies when sd's do critical.
//Therefore, we use the old value 3 on cases when an sd gets attacked by a mob
cri -= tstatus->luk*(!sd&&tsd?3:2);
+#else
+ cri -= status_get_lv(target) / 15 + 2 * status_get_luk(target);
+#endif
if( tsc && tsc->data[SC_SLEEP] ) {
cri <<= 1;
@@ -1910,11 +4206,10 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
}
if (flag.cri) {
wd.type = 0x0a;
-#ifdef RENEWAL
- flag.hit = 1;
-#else
- flag.idef = flag.idef2 = flag.hit = 1;
+#ifndef RENEWAL
+ flag.idef = flag.idef2 =
#endif
+ flag.hit = 1;
} else { //Check for Perfect Hit
if(sd && sd->bonus.perfect_hit > 0 && rnd()%100 < sd->bonus.perfect_hit)
flag.hit = 1;
@@ -1930,7 +4225,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
flag.hit = 1;
break;
case CR_SHIELDBOOMERANG:
- if( sc && sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_CRUSADER )
+ if( sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_CRUSADER )
flag.hit = 1;
break;
}
@@ -1970,7 +4265,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
hitrate += sd->bonus.arrow_hit;
#ifdef RENEWAL
if( sd ) //in Renewal hit bonus from Vultures Eye is not anymore shown in status window
- hitrate += pc_checkskill(sd,AC_VULTURE);
+ hitrate += pc->checkskill(sd,AC_VULTURE);
#endif
if(skill_id)
switch(skill_id)
@@ -2003,14 +4298,14 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
hitrate += hitrate * 5 * skill_lv / 100;
break;
case AS_SONICBLOW:
- if(sd && pc_checkskill(sd,AS_SONICACCEL)>0)
+ if(sd && pc->checkskill(sd,AS_SONICACCEL)>0)
hitrate += hitrate * 50 / 100;
break;
case MC_CARTREVOLUTION:
case GN_CART_TORNADO:
case GN_CARTCANNON:
- if( sd && pc_checkskill(sd, GN_REMODELING_CART) )
- hitrate += pc_checkskill(sd, GN_REMODELING_CART) * 4;
+ if( sd && pc->checkskill(sd, GN_REMODELING_CART) )
+ hitrate += pc->checkskill(sd, GN_REMODELING_CART) * 4;
break;
case GC_VENOMPRESSURE:
hitrate += 10 + 4 * skill_lv;
@@ -2019,16 +4314,19 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if( sd ) {
// Weaponry Research hidden bonus
- if ((temp = pc_checkskill(sd,BS_WEAPONRESEARCH)) > 0)
+ if ((temp = pc->checkskill(sd,BS_WEAPONRESEARCH)) > 0)
hitrate += hitrate * ( 2 * temp ) / 100;
if( (sd->status.weapon == W_1HSWORD || sd->status.weapon == W_DAGGER) &&
- (temp = pc_checkskill(sd, GN_TRAINING_SWORD))>0 )
+ (temp = pc->checkskill(sd, GN_TRAINING_SWORD))>0 )
hitrate += 3 * temp;
}
hitrate = cap_value(hitrate, battle_config.min_hitrate, battle_config.max_hitrate);
-
+#ifdef RENEWAL
+ if( !sd )
+ hitrate = cap_value(hitrate, 5, 95);
+#endif
if(rnd()%100 >= hitrate)
wd.dmg_lv = ATK_FLEE;
else
@@ -2057,11 +4355,35 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
wd.damage = sstatus->max_hp* 9/100;
wd.damage2 = 0;
break;
-#ifndef RENEWAL
- case NJ_ISSEN:
+ case NJ_ISSEN: // [malufett]
+/* modifying until malufett can adjust the formula */
+//#ifndef RENEWAL
+#if 1
wd.damage = 40*sstatus->str +skill_lv*(sstatus->hp/10 + 35);
wd.damage2 = 0;
+#else
+ {
+ short totaldef = status_get_total_def(target);
+ i = 0;
+ wd.damage = battle->calc_base_damage(src, target, skill_id, skill_lv, nk, n_ele, s_ele, s_ele_, EQI_HAND_R, (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0), wd.flag);
+ if( sc && sc->data[SC_NJ_BUNSINJYUTSU] && (i=sc->data[SC_NJ_BUNSINJYUTSU]->val2) > 0 )
+ wd.div_ = ~( i++ + 2 ) + 1;
+ wd.damage *= sstatus->hp * skill_lv;
+ wd.damage = wd.damage / sstatus->max_hp + sstatus->hp + i * (wd.damage / sstatus->max_hp + sstatus->hp) / 5;
+ ATK_ADD(-totaldef);
+ if( is_boss(target) )
+ ATK_RATE(50);
+ flag.idef = 1;
+ }
+ break;
+ case MO_EXTREMITYFIST: // [malufett]
+ wd.damage = battle->calc_base_damage(src, target, skill_id, skill_lv, nk, n_ele, s_ele, s_ele_, EQI_HAND_R, (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|8, wd.flag);
+ // first value is still not confirm.
+ wd.damage = status_get_sp(src) + 10 * status_get_sp(src) * wd.damage / 100 + 8 * wd.damage;
+ flag.tdef = 1;
+#endif
break;
+#ifndef RENEWAL
case LK_SPIRALPIERCE:
case ML_SPIRALPIERCE:
if (sd) {
@@ -2111,12 +4433,18 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
}
default:
{
- i = (flag.cri?1:0)|
+ i = (flag.cri
+#ifdef RENEWAL
+ || (sc && sc->data[SC_MAXIMIZEPOWER])
+#endif
+ ?1:0)|
(flag.arrow?2:0)|
+#ifndef RENEWAL
(skill_id == HW_MAGICCRASHER?4:0)|
- (!skill_id && sc && sc->data[SC_CHANGE]?4:0)|
(skill_id == MO_EXTREMITYFIST?8:0)|
- (sc && sc->data[SC_WEAPONPERFECTION]?8:0);
+#endif
+ (!skill_id && sc && sc->data[SC_HLIF_CHANGE]?4:0)|
+ (sc && sc->data[SC_WEAPONPERFECT]?8:0);
if (flag.arrow && sd)
switch(sd->status.weapon) {
case W_BOW:
@@ -2128,10 +4456,20 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
default:
i |= 16; // for ex. shuriken must not be influenced by DEX
}
+/* modifying until malufett can adjust the formula */
+//#ifdef RENEWAL
+#if 0
+ wd.damage = battle->calc_base_damage(src, target, skill_id, skill_lv, nk, n_ele, s_ele, s_ele_, EQI_HAND_R, i, wd.flag);
+ wd.damage = battle->calc_masteryfix(src, target, skill_id, skill_lv, wd.damage, wd.div_, 0, flag.weapon);
+ if (flag.lh){
+ wd.damage2 = battle->calc_base_damage(src, target, skill_id, skill_lv, nk, n_ele, s_ele, s_ele_, EQI_HAND_L, i, wd.flag);
+ wd.damage2 = battle->calc_masteryfix(src, target, skill_id, skill_lv, wd.damage2, wd.div_, 1, flag.weapon);
+ }
+#else
wd.damage = battle->calc_base_damage(sstatus, &sstatus->rhw, sc, tstatus->size, sd, i);
if (flag.lh)
wd.damage2 = battle->calc_base_damage(sstatus, &sstatus->lhw, sc, tstatus->size, sd, i);
-
+#endif
if (nk&NK_SPLASHSPLIT){ // Divide ATK among targets
if(wflag>0)
wd.damage/= wflag;
@@ -2147,8 +4485,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if(flag.cri && sd->bonus.crit_atk_rate)
ATK_ADDRATE(sd->bonus.crit_atk_rate);
- if(sd->status.party_id && (temp=pc_checkskill(sd,TK_POWER)) > 0){
- if( (i = party_foreachsamemap(party_sub_count, sd, 0)) > 1 ) // exclude the player himself [Inkfish]
+ if(sd->status.party_id && (temp=pc->checkskill(sd,TK_POWER)) > 0){
+ if( (i = party_foreachsamemap(party->sub_count, sd, 0)) > 1 ) // exclude the player himself [Inkfish]
ATK_ADDRATE(2*temp*i);
}
}
@@ -2157,214 +4495,38 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
} //End switch(skill_id)
//Skill damage modifiers that stack linearly
+ if( sd && sd->status.weapon == W_KATAR && (i=pc->checkskill(sd,ASC_KATAR)) > 0 )
+ skillratio += skillratio * (13 + 2 * i) / 100;
if(sc && skill_id != PA_SACRIFICE)
{
if(sc->data[SC_OVERTHRUST])
skillratio += sc->data[SC_OVERTHRUST]->val3;
- if(sc->data[SC_MAXOVERTHRUST])
- skillratio += sc->data[SC_MAXOVERTHRUST]->val2;
- if (sc->data[SC_BERSERK] || sc->data[SC_SATURDAYNIGHTFEVER] || sc->data[SC__BLOODYLUST])
+ if(sc->data[SC_OVERTHRUSTMAX])
+ skillratio += sc->data[SC_OVERTHRUSTMAX]->val2;
+ if (sc->data[SC_BERSERK] || sc->data[SC_SATURDAY_NIGHT_FEVER] || sc->data[SC__BLOODYLUST])
skillratio += 100;
- if(sc->data[SC_ZENKAI] && sstatus->rhw.ele == sc->data[SC_ZENKAI]->val2 )
- skillratio += sc->data[SC_ZENKAI]->val1 * 2;
+#ifdef RENEWAL
+ if( sc->data[SC_TRUESIGHT] )
+ skillratio += 2*sc->data[SC_TRUESIGHT]->val1;
+ if( sc->data[SC_LKCONCENTRATION] )
+ skillratio += sc->data[SC_LKCONCENTRATION]->val2;
+#endif
+ if( sc->data[SC_UNLIMIT] && wd.flag&BF_LONG )
+ ATK_ADD( 50 * sc->data[SC_UNLIMIT]->val1 );
}
+ if( tsc && skill_id != PA_SACRIFICE ){
+ if( tsc->data[SC_DARKCROW] && wd.flag&BF_SHORT )
+ ATK_ADD( 30 * tsc->data[SC_DARKCROW]->val1 );
+ }
+
if( !skill_id )
{
ATK_RATE(skillratio);
}
else
{
- switch( skill_id )
- {
- case SM_BASH:
- case MS_BASH:
- skillratio += 30*skill_lv;
- break;
- case SM_MAGNUM:
- case MS_MAGNUM:
- skillratio += 20*skill_lv;
- break;
- case MC_MAMMONITE:
- skillratio += 50*skill_lv;
- break;
- case HT_POWER:
- skillratio += -50+8*sstatus->str;
- break;
- case AC_DOUBLE:
- case MA_DOUBLE:
- skillratio += 10*(skill_lv-1);
- break;
- case AC_SHOWER:
- case MA_SHOWER:
- #ifdef RENEWAL
- skillratio += 50+10*skill_lv;
- #else
- skillratio += -25+5*skill_lv;
- #endif
- break;
- case AC_CHARGEARROW:
- case MA_CHARGEARROW:
- skillratio += 50;
- break;
-#ifndef RENEWAL
- case HT_FREEZINGTRAP:
- case MA_FREEZINGTRAP:
- skillratio += -50+10*skill_lv;
- break;
-#endif
- case KN_PIERCE:
- case ML_PIERCE:
- skillratio += 10*skill_lv;
- break;
- case MER_CRASH:
- skillratio += 10*skill_lv;
- break;
- case KN_SPEARSTAB:
- skillratio += 15*skill_lv;
- break;
- case KN_SPEARBOOMERANG:
- skillratio += 50*skill_lv;
- break;
- case KN_BRANDISHSPEAR:
- case ML_BRANDISH:
- {
- int ratio = 100+20*skill_lv;
- skillratio += ratio-100;
- if(skill_lv>3 && wflag==1) skillratio += ratio/2;
- if(skill_lv>6 && wflag==1) skillratio += ratio/4;
- if(skill_lv>9 && wflag==1) skillratio += ratio/8;
- if(skill_lv>6 && wflag==2) skillratio += ratio/2;
- if(skill_lv>9 && wflag==2) skillratio += ratio/4;
- if(skill_lv>9 && wflag==3) skillratio += ratio/2;
- break;
- }
- case KN_BOWLINGBASH:
- case MS_BOWLINGBASH:
- skillratio+= 40*skill_lv;
- break;
- case AS_GRIMTOOTH:
- skillratio += 20*skill_lv;
- break;
- case AS_POISONREACT:
- skillratio += 30*skill_lv;
- break;
- case AS_SONICBLOW:
- skillratio += -50+5*skill_lv;
- break;
- case TF_SPRINKLESAND:
- skillratio += 30;
- break;
- case MC_CARTREVOLUTION:
- skillratio += 50;
- if(sd && sd->cart_weight)
- skillratio += 100*sd->cart_weight/sd->cart_weight_max; // +1% every 1% weight
- else if (!sd)
- skillratio += 100; //Max damage for non players.
- break;
- case NPC_RANDOMATTACK:
- skillratio += 100*skill_lv;
- break;
- case NPC_WATERATTACK:
- case NPC_GROUNDATTACK:
- case NPC_FIREATTACK:
- case NPC_WINDATTACK:
- case NPC_POISONATTACK:
- case NPC_HOLYATTACK:
- case NPC_DARKNESSATTACK:
- case NPC_UNDEADATTACK:
- case NPC_TELEKINESISATTACK:
- case NPC_BLOODDRAIN:
- case NPC_ACIDBREATH:
- case NPC_DARKNESSBREATH:
- case NPC_FIREBREATH:
- case NPC_ICEBREATH:
- case NPC_THUNDERBREATH:
- case NPC_HELLJUDGEMENT:
- case NPC_PULSESTRIKE:
- skillratio += 100*(skill_lv-1);
- break;
- case RG_BACKSTAP:
- if(sd && sd->status.weapon == W_BOW && battle_config.backstab_bow_penalty)
- skillratio += (200+40*skill_lv)/2;
- else
- skillratio += 200+40*skill_lv;
- break;
- case RG_RAID:
- skillratio += 40*skill_lv;
- break;
- case RG_INTIMIDATE:
- skillratio += 30*skill_lv;
- break;
- case CR_SHIELDCHARGE:
- skillratio += 20*skill_lv;
- break;
- case CR_SHIELDBOOMERANG:
- skillratio += 30*skill_lv;
- break;
- case NPC_DARKCROSS:
- case CR_HOLYCROSS:
- {
- int ratio = 35*skill_lv;
- #ifdef RENEWAL
- if(sd && sd->status.weapon == W_2HSPEAR)
- ratio *= 2;
- #endif
- skillratio += ratio;
- break;
- }
- case AM_DEMONSTRATION:
- skillratio += 20*skill_lv;
- break;
- case AM_ACIDTERROR:
- skillratio += 40*skill_lv;
- break;
- case MO_FINGEROFFENSIVE:
- skillratio+= 50 * skill_lv;
- break;
- case MO_INVESTIGATE:
- skillratio += 75*skill_lv;
- flag.pdef = flag.pdef2 = 2;
- break;
- case MO_EXTREMITYFIST:
- { //Overflow check. [Skotlex]
- unsigned int ratio = skillratio + 100*(8 + sstatus->sp/10);
- //You'd need something like 6K SP to reach this max, so should be fine for most purposes.
- if (ratio > 60000) ratio = 60000; //We leave some room here in case skillratio gets further increased.
- skillratio = (unsigned short)ratio;
- }
- break;
- case MO_TRIPLEATTACK:
- skillratio += 20*skill_lv;
- break;
- case MO_CHAINCOMBO:
- skillratio += 50+50*skill_lv;
- break;
- case MO_COMBOFINISH:
- skillratio += 140+60*skill_lv;
- break;
- case BA_MUSICALSTRIKE:
- case DC_THROWARROW:
- skillratio += 25+25*skill_lv;
- break;
- case CH_TIGERFIST:
- skillratio += 100*skill_lv-60;
- break;
- case CH_CHAINCRUSH:
- skillratio += 300+100*skill_lv;
- break;
- case CH_PALMSTRIKE:
- skillratio += 100+100*skill_lv;
- break;
- case LK_HEADCRUSH:
- skillratio += 40*skill_lv;
- break;
- case LK_JOINTBEAT:
- i = 10*skill_lv-50;
- // Although not clear, it's being assumed that the 2x damage is only for the break neck ailment.
- if (wflag&BREAK_NECK) i*=2;
- skillratio += i;
- break;
-#ifdef RENEWAL
+ switch(skill_id){
+ #ifdef RENEWAL
case LK_SPIRALPIERCE:
case ML_SPIRALPIERCE:
{// Formula: Floor[Floor(Weapon Weight/2)*skill level + ATK ]*(100%+50%*s.lvl) * 5 multi-hits
@@ -2375,575 +4537,26 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
sd->inventory_data[index] &&
sd->inventory_data[index]->type == IT_WEAPON)
weight = sd->inventory_data[index]->weight/20;
- ATK_ADD(weight * skill_lv)
- skillratio += 50*skill_lv;
+ ATK_ADD(weight * skill_lv);
}
- break;
-#endif
- case ASC_METEORASSAULT:
- skillratio += 40*skill_lv-60;
- break;
- case SN_SHARPSHOOTING:
- case MA_SHARPSHOOTING:
- skillratio += 100+50*skill_lv;
- break;
- case CG_ARROWVULCAN:
- skillratio += 100+100*skill_lv;
- break;
- case AS_SPLASHER:
- skillratio += 400+50*skill_lv;
- if(sd)
- skillratio += 20 * pc_checkskill(sd,AS_POISONREACT);
- break;
- case ASC_BREAKER:
- skillratio += 100*skill_lv-100;
- break;
- case PA_SACRIFICE:
- skillratio += 10*skill_lv-10;
- break;
- case PA_SHIELDCHAIN:
- skillratio += 30*skill_lv;
- break;
- case WS_CARTTERMINATION:
- i = 10 * (16 - skill_lv);
- if (i < 1) i = 1;
- //Preserve damage ratio when max cart weight is changed.
- if(sd && sd->cart_weight)
- skillratio += sd->cart_weight/i * 80000/battle_config.max_cart_weight - 100;
- else if (!sd)
- skillratio += 80000 / i - 100;
- break;
- case TK_DOWNKICK:
- skillratio += 60 + 20*skill_lv;
- break;
- case TK_STORMKICK:
- skillratio += 60 + 20*skill_lv;
- break;
- case TK_TURNKICK:
- skillratio += 90 + 30*skill_lv;
- break;
- case TK_COUNTER:
- skillratio += 90 + 30*skill_lv;
- break;
- case TK_JUMPKICK:
- skillratio += -70 + 10*skill_lv;
- if (sc && sc->data[SC_COMBO] && sc->data[SC_COMBO]->val1 == skill_id)
- skillratio += 10*status_get_lv(src)/3; //Tumble bonus
- if (wflag)
- {
- skillratio += 10*status_get_lv(src)/3; //Running bonus (TODO: What is the real bonus?)
- if( sc && sc->data[SC_SPURT] ) // Spurt bonus
- skillratio *= 2;
- }
- break;
- case GS_TRIPLEACTION:
- skillratio += 50*skill_lv;
- break;
- case GS_BULLSEYE:
- //Only works well against brute/demihumans non bosses.
- if((tstatus->race == RC_BRUTE || tstatus->race == RC_DEMIHUMAN)
- && !(tstatus->mode&MD_BOSS))
- skillratio += 400;
- break;
- case GS_TRACKING:
- skillratio += 100 *(skill_lv+1);
- break;
- case GS_PIERCINGSHOT:
- skillratio += 20*skill_lv;
- break;
- case GS_RAPIDSHOWER:
- skillratio += 10*skill_lv;
- break;
- case GS_DESPERADO:
- skillratio += 50*(skill_lv-1);
- break;
- case GS_DUST:
- skillratio += 50*skill_lv;
- break;
- case GS_FULLBUSTER:
- skillratio += 100*(skill_lv+2);
- break;
- case GS_SPREADATTACK:
- #ifdef RENEWAL
- skillratio += 20*(skill_lv);
- #else
- skillratio += 20*(skill_lv-1);
- #endif
- break;
-#ifdef RENEWAL
- case NJ_ISSEN:
- skillratio += 100 * (skill_lv-1);
- break;
-#endif
- case NJ_HUUMA:
- skillratio += 50 + 150*skill_lv;
- break;
case NJ_TATAMIGAESHI:
-#ifdef RENEWAL
- ATK_RATE(200);
-#endif
- skillratio += 10*skill_lv;
- break;
- case NJ_KASUMIKIRI:
- skillratio += 10*skill_lv;
- break;
- case NJ_KIRIKAGE:
- skillratio += 100*(skill_lv-1);
- break;
- case KN_CHARGEATK:
- {
- int k = (wflag-1)/3; //+100% every 3 cells of distance
- if( k > 2 ) k = 2; // ...but hard-limited to 300%.
- skillratio += 100 * k;
- }
- break;
- case HT_PHANTASMIC:
- skillratio += 50;
- break;
- case MO_BALKYOUNG:
- skillratio += 200;
- break;
- case HFLI_MOON: //[orn]
- skillratio += 10+110*skill_lv;
- break;
- case HFLI_SBR44: //[orn]
- skillratio += 100 *(skill_lv-1);
- break;
- case NPC_VAMPIRE_GIFT:
- skillratio += ((skill_lv-1)%5+1)*100;
- break;
- case RK_SONICWAVE:
- skillratio += 400 + 100 * skill_lv;
- RE_LVL_DMOD(100);
- break;
- case RK_HUNDREDSPEAR:
- skillratio += 500 + (80 * skill_lv);
- if( sd )
- {
- short index = sd->equip_index[EQI_HAND_R];
- if( index >= 0 && sd->inventory_data[index]
- && sd->inventory_data[index]->type == IT_WEAPON )
- skillratio += max(10000 - sd->inventory_data[index]->weight, 0) / 10;
- skillratio += 50 * pc_checkskill(sd,LK_SPIRALPIERCE);
- } // (1 + [(Casters Base Level - 100) / 200])
- skillratio = skillratio * (100 + (status_get_lv(src)-100) / 2) / 100;
- break;
- case RK_WINDCUTTER:
- skillratio += 50 * skill_lv;
- RE_LVL_DMOD(100);
- break;
- case RK_IGNITIONBREAK:
- i = distance_bl(src,target);
- if( i < 2 )
- skillratio = 200 + 200 * skill_lv;
- else if( i < 4 )
- skillratio = 100 + 200 * skill_lv;
- else
- skillratio = 100 + 100 * skill_lv;
- RE_LVL_DMOD(100);
- if( sstatus->rhw.ele == ELE_FIRE )
- skillratio += skillratio / 2;
- break;
- case RK_CRUSHSTRIKE:
- if( sd )
- {//ATK [{Weapon Level * (Weapon Upgrade Level + 6) * 100} + (Weapon ATK) + (Weapon Weight)]%
- short index = sd->equip_index[EQI_HAND_R];
- if( index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->type == IT_WEAPON )
- skillratio = sd->inventory_data[index]->weight/10 + sstatus->rhw.atk +
- 100 * sd->inventory_data[index]->wlv * (sd->status.inventory[index].refine + 6);
- }
- break;
- case RK_STORMBLAST:
- skillratio = 100 * (sd ? pc_checkskill(sd,RK_RUNEMASTERY) : 1) + 100 * (sstatus->int_ / 4);
- break;
- case RK_PHANTOMTHRUST:
- skillratio = 50 * skill_lv + 10 * ( sd ? pc_checkskill(sd,KN_SPEARMASTERY) : 10);
- //if( s_level > 100 ) skillratio += skillratio * s_level / 150; // Base level bonus. This is official, but is disabled until I can confirm something with was changed or not. [Rytech]
- //if( s_level > 100 ) skillratio += skillratio * (s_level - 100) / 200; // Base level bonus.
- break;
- /**
- * GC Guilotine Cross
- **/
- case GC_CROSSIMPACT:
- skillratio += 900 + 100 * skill_lv;
- RE_LVL_DMOD(120);
- break;
- case GC_PHANTOMMENACE:
- skillratio += 200;
- break;
- case GC_COUNTERSLASH:
- //ATK [{(Skill Level x 100) + 300} x Caster's Base Level / 120]% + ATK [(AGI x 2) + (Caster's Job Level x 4)]%
- skillratio += 200 + (100 * skill_lv);
- RE_LVL_DMOD(120);
- skillratio += sstatus->agi + (sd?sd->status.job_level:0) * 4;
- break;
- case GC_ROLLINGCUTTER:
- skillratio += -50 + 50 * skill_lv;
- RE_LVL_DMOD(100);
- break;
- case GC_CROSSRIPPERSLASHER:
- skillratio += 300 + 80 * skill_lv;
- RE_LVL_DMOD(100);
- if( sc && sc->data[SC_ROLLINGCUTTER] )
- skillratio += sc->data[SC_ROLLINGCUTTER]->val1 * sstatus->agi;
- break;
- /**
- * Arch Bishop
- **/
- case AB_DUPLELIGHT_MELEE:
- skillratio += 10 * skill_lv;
- break;
- /**
- * Ranger
- **/
- case RA_ARROWSTORM:
- skillratio += 900 + 80 * skill_lv;
- RE_LVL_DMOD(100);
- break;
- case RA_AIMEDBOLT:
- skillratio += 400 + 50 * skill_lv;
- RE_LVL_DMOD(100);
- if( tsc && (tsc->data[SC_BITE] || tsc->data[SC_ANKLE] || tsc->data[SC_ELECTRICSHOCKER]) )
- wd.div_ = tstatus->size + 2 + ( (rnd()%100 < 50-tstatus->size*10) ? 1 : 0 );
- break;
- case RA_CLUSTERBOMB:
- skillratio += 100 + 100 * skill_lv;
- break;
- case RA_WUGDASH:// ATK 300%
- skillratio += 200;
- break;
- case RA_WUGSTRIKE:
- skillratio = 200 * skill_lv;
- break;
- case RA_WUGBITE:
- skillratio += 300 + 200 * skill_lv;
- if ( skill_lv == 5 ) skillratio += 100;
- break;
- case RA_SENSITIVEKEEN:
- skillratio += 50 * skill_lv;
- break;
- /**
- * Mechanic
- **/
- case NC_BOOSTKNUCKLE:
- skillratio += 100 + 100 * skill_lv + sstatus->dex;
- RE_LVL_DMOD(100);
- break;
- case NC_PILEBUNKER:
- skillratio += 200 + 100 * skill_lv + sstatus->str;
- RE_LVL_DMOD(100);
- break;
- case NC_VULCANARM:
- skillratio = 70 * skill_lv + sstatus->dex;
- RE_LVL_DMOD(100);
- break;
- case NC_FLAMELAUNCHER:
- case NC_COLDSLOWER:
- skillratio += 200 + 300 * skill_lv;
- RE_LVL_DMOD(100);
- break;
- case NC_ARMSCANNON:
- switch( tstatus->size ) {
- case SZ_SMALL: skillratio += 100 + 500 * skill_lv; break;// Small
- case SZ_MEDIUM: skillratio += 100 + 400 * skill_lv; break;// Medium
- case SZ_BIG: skillratio += 100 + 300 * skill_lv; break;// Large
- }
- RE_LVL_DMOD(100);
- //NOTE: Their's some other factors that affects damage, but not sure how exactly. Will recheck one day. [Rytech]
- break;
- case NC_AXEBOOMERANG:
- skillratio += 60 + 40 * skill_lv;
- if( sd ) {
- short index = sd->equip_index[EQI_HAND_R];
- if( index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->type == IT_WEAPON )
- skillratio += sd->inventory_data[index]->weight / 10;// Weight is divided by 10 since 10 weight in coding make 1 whole actural weight. [Rytech]
- }
- RE_LVL_DMOD(100);
- break;
- case NC_POWERSWING:
- skillratio += 80 + 20 * skill_lv + sstatus->str + sstatus->dex;
- RE_LVL_DMOD(100);
- break;
- case NC_AXETORNADO:
- skillratio += 100 + 100 * skill_lv + sstatus->vit;
- RE_LVL_DMOD(100);
- break;
- case SC_FATALMENACE:
- skillratio += 100 * skill_lv;
- break;
- case SC_TRIANGLESHOT:
- skillratio += 270 + 30 * skill_lv;
- break;
- case SC_FEINTBOMB:
- skillratio += 100 + 100 * skill_lv;
- break;
- case LG_CANNONSPEAR:// Stimated formula. Still need confirm it.
- skillratio += -100 + (50 + sstatus->str) * skill_lv;
- RE_LVL_DMOD(100);
- break;
- case LG_BANISHINGPOINT:
- skillratio += -100 + ((50 * skill_lv) + (30 * ((sd)?pc_checkskill(sd,SM_BASH):1)));
- RE_LVL_DMOD(100);
- break;
- case LG_SHIELDPRESS:
- skillratio += 60 + 43 * skill_lv;
- RE_LVL_DMOD(100);
- break;
- case LG_PINPOINTATTACK:
- skillratio = ((100 * skill_lv) + (10 * status_get_agi(src)) );
- RE_LVL_DMOD(100);
- break;
- case LG_RAGEBURST:
- if( sd && sd->spiritball_old )
- skillratio += -100 + (sd->spiritball_old * 200);
- else
- skillratio += -100 + 15 * 200;
- RE_LVL_DMOD(100);
- break;
- case LG_SHIELDSPELL:// [(Casters Base Level x 4) + (Shield DEF x 10) + (Casters VIT x 2)] %
- if( sd ) {
- struct item_data *shield_data = sd->inventory_data[sd->equip_index[EQI_HAND_L]];
- skillratio = status_get_lv(src) * 4 + status_get_vit(src) * 2;
- if( shield_data )
- skillratio += shield_data->def * 10;
- } else
- skillratio += 2400; //2500%
- break;
- case LG_MOONSLASHER:
- skillratio += -100 + (120 * skill_lv + ((sd) ? pc_checkskill(sd,LG_OVERBRAND) : 5) * 80);
- RE_LVL_DMOD(100);
- break;
- case LG_OVERBRAND:
- skillratio = 400 * skill_lv + (pc_checkskill(sd,CR_SPEARQUICKEN) * 30);
- RE_LVL_DMOD(100);
- break;
- case LG_OVERBRAND_BRANDISH:
- skillratio = 300 * skill_lv + (2 * (sstatus->str + sstatus->dex) / 3);
- RE_LVL_DMOD(100);
- break;
- case LG_OVERBRAND_PLUSATK:
- skillratio = 150 * skill_lv;
- RE_LVL_DMOD(100);
- break;
- case LG_RAYOFGENESIS:
- skillratio = 300 + 300 * skill_lv;
- RE_LVL_DMOD(100);
- break;
- case LG_EARTHDRIVE:
- skillratio = (skillratio + 100) * skill_lv;
- RE_LVL_DMOD(100);
- break;
- case LG_HESPERUSLIT:
- skillratio += 120 * skill_lv - 100;
- break;
- case SR_DRAGONCOMBO:
- skillratio += 40 * skill_lv;
- RE_LVL_DMOD(100);
- break;
- case SR_SKYNETBLOW:
- //ATK [{(Skill Level x 80) + (Caster AGI)} x Caster Base Level / 100] %
- skillratio = 80 * skill_lv + sstatus->agi;
- if( sc && sc->data[SC_COMBO] && sc->data[SC_COMBO]->val1 == SR_DRAGONCOMBO )//ATK [{(Skill Level x 100) + (Caster AGI) + 150} x Caster Base Level / 100] %
- skillratio = 100 * skill_lv + sstatus->agi + 150;
- RE_LVL_DMOD(100);
- break;
- case SR_EARTHSHAKER:
- if( tsc && (tsc->data[SC_HIDING] || tsc->data[SC_CLOAKING] || // [(Skill Level x 150) x (Caster Base Level / 100) + (Caster INT x 3)] %
- tsc->data[SC_CHASEWALK] || tsc->data[SC_CLOAKINGEXCEED] || tsc->data[SC__INVISIBILITY]) ){
- skillratio = 150 * skill_lv;
- RE_LVL_DMOD(100);
- skillratio += sstatus->int_ * 3;
- }else{ //[(Skill Level x 50) x (Caster Base Level / 100) + (Caster INT x 2)] %
- skillratio += 50 * (skill_lv-2);
- RE_LVL_DMOD(100);
- skillratio += sstatus->int_ * 2;
- }
- break;
- case SR_FALLENEMPIRE:// ATK [(Skill Level x 150 + 100) x Caster Base Level / 150] %
- skillratio += 150 *skill_lv;
- RE_LVL_DMOD(150);
- break;
- case SR_TIGERCANNON:// ATK [((Caster consumed HP + SP) / 4) x Caster Base Level / 100] %
- {
- int hp = sstatus->max_hp * (10 + 2 * skill_lv) / 100,
- sp = sstatus->max_sp * (6 + skill_lv) / 100;
- skillratio = (hp+sp) / 4;
- if( sc && sc->data[SC_COMBO] && sc->data[SC_COMBO]->val1 == SR_FALLENEMPIRE ) // ATK [((Caster consumed HP + SP) / 2) x Caster Base Level / 100] %
- skillratio = hp+sp / 2;
- RE_LVL_DMOD(100);
- }
- break;
- case SR_RAMPAGEBLASTER:
- skillratio += 20 * skill_lv * (sd?sd->spiritball_old:5) - 100;
- if( sc && sc->data[SC_EXPLOSIONSPIRITS] ){
- skillratio += sc->data[SC_EXPLOSIONSPIRITS]->val1 * 20;
- RE_LVL_DMOD(120);
- }else
- RE_LVL_DMOD(150);
- break;
- case SR_KNUCKLEARROW:
- if( wflag&4 ){ // ATK [(Skill Level x 150) + (1000 x Target current weight / Maximum weight) + (Target Base Level x 5) x (Caster Base Level / 150)] %
- skillratio = 150 * skill_lv + status_get_lv(target) * 5 * (status_get_lv(src) / 100) ;
- if( tsd && tsd->weight )
- skillratio += 100 * (tsd->weight / tsd->max_weight);
- }else // ATK [(Skill Level x 100 + 500) x Caster Base Level / 100] %
- skillratio += 400 + (100 * skill_lv);
- RE_LVL_DMOD(100);
- break;
- case SR_WINDMILL: // ATK [(Caster Base Level + Caster DEX) x Caster Base Level / 100] %
- skillratio = status_get_lv(src) + sstatus->dex;
- RE_LVL_DMOD(100);
- break;
- case SR_GATEOFHELL:
- if( sc && sc->data[SC_COMBO]
- && sc->data[SC_COMBO]->val1 == SR_FALLENEMPIRE )
- skillratio += 800 * skill_lv -100;
- else
- skillratio += 500 * skill_lv -100;
- RE_LVL_DMOD(100);
- break;
- case SR_GENTLETOUCH_QUIET:
- skillratio += 100 * skill_lv - 100 + sstatus->dex;
- RE_LVL_DMOD(100);
- break;
- case SR_HOWLINGOFLION:
- skillratio += 300 * skill_lv - 100;
- RE_LVL_DMOD(150);
- break;
- case SR_RIDEINLIGHTNING: // ATK [{(Skill Level x 200) + Additional Damage} x Caster Base Level / 100] %
- if( (sstatus->rhw.ele) == ELE_WIND || (sstatus->lhw.ele) == ELE_WIND )
- skillratio += skill_lv * 50;
- skillratio += -100 + 200 * skill_lv;
- RE_LVL_DMOD(100);
- break;
- case WM_REVERBERATION_MELEE:
- // ATK [{(Skill Level x 100) + 300} x Caster Base Level / 100]
- skillratio += 200 + 100 * pc_checkskill(sd, WM_REVERBERATION);
- RE_LVL_DMOD(100);
- break;
- case WM_SEVERE_RAINSTORM_MELEE:
- //ATK [{(Caster DEX + AGI) x (Skill Level / 5)} x Caster Base Level / 100] %
- skillratio = (sstatus->dex + sstatus->agi) * (skill_lv * 2);
- RE_LVL_DMOD(100);
- skillratio /= 10;
- break;
- case WM_GREAT_ECHO:
- skillratio += 800 + 100 * skill_lv;
- if( sd ) { // Still need official value [pakpil]
- short lv = (short)skill_lv;
- skillratio += 100 * skill->check_pc_partner(sd,skill_id,&lv,skill->get_splash(skill_id,skill_lv),0);
- }
- break;
- case WM_SOUND_OF_DESTRUCTION:
- skillratio += 400;
- break;
- case GN_CART_TORNADO:
- // ATK [( Skill Level x 50 ) + ( Cart Weight / ( 150 - Caster Base STR ))] + ( Cart Remodeling Skill Level x 50 )] %
- skillratio = 50 * skill_lv;
- if( sd && sd->cart_weight)
- skillratio += sd->cart_weight/10 / max(150-sstatus->str,1) + pc_checkskill(sd, GN_REMODELING_CART) * 50;
- break;
- case GN_CARTCANNON:
- // ATK [{( Cart Remodeling Skill Level x 50 ) x ( INT / 40 )} + ( Cart Cannon Skill Level x 60 )] %
- skillratio = 60 * skill_lv;
- if( sd ) skillratio += pc_checkskill(sd, GN_REMODELING_CART) * 50 * (sstatus->int_ / 40);
- break;
- case GN_SPORE_EXPLOSION:
- skillratio += 200 + 100 * skill_lv;
- break;
- case GN_CRAZYWEED_ATK:
- skillratio += 400 + 100 * skill_lv;
- break;
- case GN_SLINGITEM_RANGEMELEEATK:
- if( sd ) {
- switch( sd->itemid ) {
- case 13260: // Apple Bomob
- case 13261: // Coconut Bomb
- case 13262: // Melon Bomb
- case 13263: // Pinapple Bomb
- skillratio += 400; // Unconfirded
- break;
- case 13264: // Banana Bomb 2000%
- skillratio += 1900;
- break;
- case 13265: skillratio -= 75; break; // Black Lump 25%
- case 13266: skillratio -= 25; break; // Hard Black Lump 75%
- case 13267: skillratio += 100; break; // Extremely Hard Black Lump 200%
- }
- } else
- skillratio += 300; // Bombs
- break;
- case SO_VARETYR_SPEAR://ATK [{( Striking Level x 50 ) + ( Varetyr Spear Skill Level x 50 )} x Caster Base Level / 100 ] %
- skillratio = 50 * skill_lv + ( sd ? pc_checkskill(sd, SO_STRIKING) * 50 : 0 );
- if( sc && sc->data[SC_BLAST_OPTION] )
- skillratio += sd ? sd->status.job_level * 5 : 0;
- break;
- // Physical Elemantal Spirits Attack Skills
- case EL_CIRCLE_OF_FIRE:
- case EL_FIRE_BOMB_ATK:
- case EL_STONE_RAIN:
- skillratio += 200;
- break;
- case EL_FIRE_WAVE_ATK:
- skillratio += 500;
- break;
- case EL_TIDAL_WEAPON:
- skillratio += 1400;
- break;
- case EL_WIND_SLASH:
- skillratio += 100;
- break;
- case EL_HURRICANE:
- skillratio += 600;
- break;
- case EL_TYPOON_MIS:
- case EL_WATER_SCREW_ATK:
- skillratio += 900;
- break;
- case EL_STONE_HAMMER:
- skillratio += 400;
- break;
- case EL_ROCK_CRUSHER:
- skillratio += 700;
- break;
- case KO_JYUMONJIKIRI:
- if( tsc && tsc->data[SC_JYUMONJIKIRI] )
- wd.div_ = wd.div_ * -1;// needs more info
- skillratio += -100 + 150 * skill_lv;
- case KO_HUUMARANKA:
- skillratio += -100 + 150 * skill_lv + sstatus->dex/2 + sstatus->agi/2; // needs more info
- break;
- case KO_SETSUDAN:
- skillratio += 100 * (skill_lv-1);
- break;
- case KO_BAKURETSU:
- skillratio = 50 * skill_lv * (sd?pc_checkskill(sd,NJ_TOBIDOUGU):10);
- break;
- case MH_NEEDLE_OF_PARALYZE:
- skillratio += 600 + 100 * skill_lv;
- break;
- case MH_STAHL_HORN:
- skillratio += 400 + 100 * skill_lv;
- break;
- case MH_LAVA_SLIDE:
- skillratio = 70 * skill_lv;
- break;
- case MH_TINDER_BREAKER:
- case MH_MAGMA_FLOW:
- skillratio += -100 + 100 * skill_lv;
- break;
+ if( skill_id != LK_SPIRALPIERCE && skill_id != ML_SPIRALPIERCE )
+ ATK_RATE(200);
+ #endif
+ default:
+ ATK_RATE(battle->calc_skillratio(BF_WEAPON, src, target, skill_id, skill_lv, skillratio, wflag));
}
-#ifdef RENEWAL
- if( sc && sc->data[SC_TRUESIGHT] )
- skillratio += 2*sc->data[SC_TRUESIGHT]->val1;
-#endif
- ATK_RATE(skillratio);
//Constant/misc additions from skills
switch (skill_id) {
case MO_EXTREMITYFIST:
ATK_ADD(250 + 150*skill_lv);
break;
+#ifdef RENEWAL
+ case HW_MAGICCRASHER:
+ ATK_ADD(battle->calc_magic_attack(src, target, skill_id, skill_lv, wflag).damage / 5);
+ break;
+#endif
case TK_DOWNKICK:
case TK_STORMKICK:
case TK_TURNKICK:
@@ -2951,53 +4564,30 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
case TK_JUMPKICK:
//TK_RUN kick damage bonus.
if(sd && sd->weapontype1 == W_FIST && sd->weapontype2 == W_FIST)
- ATK_ADD(10*pc_checkskill(sd, TK_RUN));
+ ATK_ADD(10*pc->checkskill(sd, TK_RUN));
break;
case GS_MAGICALBULLET:
- if(sstatus->matk_max>sstatus->matk_min) {
- ATK_ADD(sstatus->matk_min+rnd()%(sstatus->matk_max-sstatus->matk_min));
- } else {
- ATK_ADD(sstatus->matk_min);
- }
- break;
+#ifndef RENEWAL
+ ATK_ADD( status_get_matk(src, 2) );
+#else
+ ATK_ADD( battle->calc_magic_attack(src, target, skill_id, skill_lv, wflag).damage );
+ flag.tdef = 1;
+#endif
case NJ_SYURIKEN:
ATK_ADD(4*skill_lv);
break;
-#ifdef RENEWAL
- case NJ_ISSEN:
- // Damage = (current HP + atk * skill_lv) - (sdef+edef)
- ATK_ADD(sstatus->hp);
- wd.damage2 = 0;// needs more info if this really 0 for dual weilding KG/OB. [malufett]
- if( sc && sc->data[SC_BUNSINJYUTSU] && (i=sc->data[SC_BUNSINJYUTSU]->val2) > 0){
- wd.div_ = -( i + 2 ); // mirror image number of hits + 2
- ATK_ADDRATE(20 + i*20); // (20 + 20 * mirror image) %
- }
- break;
-#endif
case HT_FREEZINGTRAP:
if(sd)
- ATK_ADD( 40 * pc_checkskill(sd, RA_RESEARCHTRAP) );
+ ATK_ADD( 40 * pc->checkskill(sd, RA_RESEARCHTRAP) );
break;
case RA_WUGDASH ://(Caster Current Weight x 10 / 8)
if( sd && sd->weight )
ATK_ADD( sd->weight / 8 );
- case RA_WUGSTRIKE:
- case RA_WUGBITE:
- if(sd)
- ATK_ADD(30*pc_checkskill(sd, RA_TOOTHOFWUG));
- break;
- case SR_GATEOFHELL:
- ATK_ADD (sstatus->max_hp - status_get_hp(src));
- if(sc && sc->data[SC_COMBO] && sc->data[SC_COMBO]->val1 == SR_FALLENEMPIRE){
- ATK_ADD ( (sstatus->max_sp * (1 + skill_lv * 2 / 10)) + 40 * status_get_lv(src) );
- }else{
- ATK_ADD ( (sstatus->sp * (1 + skill_lv * 2 / 10)) + 10 * status_get_lv(src) );
- }
break;
case SR_TIGERCANNON: // (Tiger Cannon skill level x 240) + (Target Base Level x 40)
ATK_ADD( skill_lv * 240 + status_get_lv(target) * 40 );
- if( sc && sc->data[SC_COMBO]
- && sc->data[SC_COMBO]->val1 == SR_FALLENEMPIRE ) // (Tiger Cannon skill level x 500) + (Target Base Level x 40)
+ if( sc && sc->data[SC_COMBOATTACK]
+ && sc->data[SC_COMBOATTACK]->val1 == SR_FALLENEMPIRE ) // (Tiger Cannon skill level x 500) + (Target Base Level x 40)
ATK_ADD( skill_lv * 500 + status_get_lv(target) * 40 );
break;
case SR_FALLENEMPIRE:// [(Target Size value + Skill Level - 1) x Caster STR] + [(Target current weight x Caster DEX / 120)]
@@ -3009,26 +4599,20 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
}
break;
case KO_SETSUDAN:
- if( tsc && tsc->data[SC_SPIRIT] ){
- ATK_ADDRATE(10*tsc->data[SC_SPIRIT]->val1);// +10% custom value.
- status_change_end(target,SC_SPIRIT,INVALID_TIMER);
+ if( tsc && tsc->data[SC_SOULLINK] ){
+ ATK_ADDRATE(200*tsc->data[SC_SOULLINK]->val1);
+ status_change_end(target,SC_SOULLINK,INVALID_TIMER);
}
break;
- case KO_KAIHOU:
- if( sd ){
- ARR_FIND(1, 6, i, sd->talisman[i] > 0);
- if( i < 5 ){
- s_ele = i;
- ATK_ADDRATE(100 * sd->talisman[i]);// +100% custom value.
- pc_del_talisman(sd, sd->talisman[i], i);
- }
- }
+ case KO_MAKIBISHI:
+ wd.damage = 20 * skill_lv;
break;
}
}
+#ifndef RENEWAL
//Div fix.
damage_div_fix(wd.damage, wd.div_);
-
+#endif
//The following are applied on top of current damage and are stackable.
if ( sc ) {
#ifndef RENEWAL
@@ -3038,46 +4622,39 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if( sc->data[SC_GLOOMYDAY_SK] &&
( skill_id == LK_SPIRALPIERCE || skill_id == KN_BRANDISHSPEAR ||
skill_id == CR_SHIELDBOOMERANG || skill_id == PA_SHIELDCHAIN ||
- skill_id == LG_SHIELDPRESS ) )
+ skill_id == LG_SHIELDPRESS || skill_id == RK_HUNDREDSPEAR ||
+ skill_id == CR_SHIELDCHARGE ) )
ATK_ADDRATE(sc->data[SC_GLOOMYDAY_SK]->val2);
if( sc->data[SC_EDP] ){
switch(skill_id){
- case AS_SPLASHER: case AS_VENOMKNIFE:
#ifndef RENEWAL_EDP
+ case AS_SPLASHER: case AS_VENOMKNIFE:
case AS_GRIMTOOTH:
-#endif
break;
-#ifndef RENEWAL_EDP
- case ASC_BREAKER: case ASC_METEORASSAULT: break;
-#else
- case AS_SONICBLOW:
- case ASC_BREAKER:
- case GC_COUNTERSLASH:
- case GC_CROSSIMPACT:
- ATK_RATE(50); // only modifier is halved but still benefit with the damage bonus
-#endif
+ case ASC_METEORASSAULT: break;
default:
ATK_ADDRATE(sc->data[SC_EDP]->val3);
+#endif
}
}
if(sc->data[SC_STYLE_CHANGE]){
- TBL_HOM *hd = BL_CAST(BL_HOM,src);
- if (hd) ATK_ADD(hd->homunculus.spiritball * 3);
- }
+ TBL_HOM *hd = BL_CAST(BL_HOM,src);
+ if (hd) ATK_ADD(hd->homunculus.spiritball * 3);
+ }
}
switch (skill_id) {
case AS_SONICBLOW:
- if (sc && sc->data[SC_SPIRIT] &&
- sc->data[SC_SPIRIT]->val2 == SL_ASSASIN)
+ if (sc && sc->data[SC_SOULLINK] &&
+ sc->data[SC_SOULLINK]->val2 == SL_ASSASIN)
ATK_ADDRATE(map_flag_gvg(src->m)?25:100); //+25% dmg on woe/+100% dmg on nonwoe
- if(sd && pc_checkskill(sd,AS_SONICACCEL)>0)
+ if(sd && pc->checkskill(sd,AS_SONICACCEL)>0)
ATK_ADDRATE(10);
break;
case CR_SHIELDBOOMERANG:
- if(sc && sc->data[SC_SPIRIT] &&
- sc->data[SC_SPIRIT]->val2 == SL_CRUSADER)
+ if(sc && sc->data[SC_SOULLINK] &&
+ sc->data[SC_SOULLINK]->val2 == SL_CRUSADER)
ATK_ADDRATE(100);
break;
case NC_AXETORNADO:
@@ -3090,9 +4667,11 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
ATK_RATE(i);
if( sd ) {
- if (skill_id && (i = pc_skillatk_bonus(sd, skill_id)))
+ if (skill_id && (i = pc->skillatk_bonus(sd, skill_id)))
ATK_ADDRATE(i);
-
+ if( (i=pc->checkskill(sd,AB_EUCHARISTICA)) > 0 &&
+ (tstatus->race == RC_DEMON || tstatus->def_ele == ELE_DARK) )
+ ATK_ADDRATE(-i);
if( skill_id != PA_SACRIFICE && skill_id != MO_INVESTIGATE && skill_id != CR_GRANDCROSS && skill_id != NPC_GRANDDARKNESS && skill_id != PA_SHIELDCHAIN && !flag.cri )
{ //Elemental/Racial adjustments
if( sd->right_weapon.def_ratio_atk_ele & (1<<tstatus->def_ele) ||
@@ -3135,129 +4714,26 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
}
}
- if (!flag.idef || !flag.idef2)
- { //Defense reduction
- short vit_def;
- defType def1 = status_get_def(target); //Don't use tstatus->def1 due to skill timer reductions.
- short def2 = tstatus->def2;
+ if(!flag.idef || !flag.idef2) { //Defense reduction
+ wd.damage = battle->calc_defense(BF_WEAPON, src, target, skill_id, skill_lv, wd.damage,
+ (flag.idef?1:0)|(flag.pdef?2:0)
#ifdef RENEWAL
- if( tsc && tsc->data[SC_ASSUMPTIO] )
- def1 <<= 1; // only eDEF is doubled
-#endif
- if( sd )
- {
- i = sd->ignore_def[is_boss(target)?RC_BOSS:RC_NONBOSS];
- i += sd->ignore_def[tstatus->race];
- if( i )
- {
- if( i > 100 ) i = 100;
- def1 -= def1 * i / 100;
- def2 -= def2 * i / 100;
- }
- }
-
- if( sc && sc->data[SC_EXPIATIO] ){
- i = 5 * sc->data[SC_EXPIATIO]->val1; // 5% per level
- def1 -= def1 * i / 100;
- def2 -= def2 * i / 100;
- }
-
- if( tsc && tsc->data[SC_GT_REVITALIZE] && tsc->data[SC_GT_REVITALIZE]->val4 )
- def2 += 2 * tsc->data[SC_GT_REVITALIZE]->val4;
-
- if( tsc && tsc->data[SC_CAMOUFLAGE] ){
- i = 5 * (10-tsc->data[SC_CAMOUFLAGE]->val4);
- def1 -= def1 * i / 100;
- def2 -= def2 * i / 100;
- }
-
- if( battle_config.vit_penalty_type && battle_config.vit_penalty_target&target->type ) {
- unsigned char target_count; //256 max targets should be a sane max
- target_count = unit_counttargeted(target);
- if(target_count >= battle_config.vit_penalty_count) {
- if(battle_config.vit_penalty_type == 1) {
- if( !tsc || !tsc->data[SC_STEELBODY] )
- def1 = (def1 * (100 - (target_count - (battle_config.vit_penalty_count - 1))*battle_config.vit_penalty_num))/100;
- def2 = (def2 * (100 - (target_count - (battle_config.vit_penalty_count - 1))*battle_config.vit_penalty_num))/100;
- } else { //Assume type 2
- if( !tsc || !tsc->data[SC_STEELBODY] )
- def1 -= (target_count - (battle_config.vit_penalty_count - 1))*battle_config.vit_penalty_num;
- def2 -= (target_count - (battle_config.vit_penalty_count - 1))*battle_config.vit_penalty_num;
- }
- }
- if(skill_id == AM_ACIDTERROR) def1 = 0; //Acid Terror ignores only armor defense. [Skotlex]
- if(def2 < 1) def2 = 1;
- }
- //Vitality reduction from rodatazone: http://rodatazone.simgaming.net/mechanics/substats.php#def
- if (tsd) //Sd vit-eq
- {
-#ifndef RENEWAL
- //[VIT*0.5] + rnd([VIT*0.3], max([VIT*0.3],[VIT^2/150]-1))
- vit_def = def2*(def2-15)/150;
- vit_def = def2/2 + (vit_def>0?rnd()%vit_def:0);
-#else
- vit_def = def2;
+ |(flag.tdef?4:0)
#endif
- if((battle->check_undead(sstatus->race,sstatus->def_ele) || sstatus->race==RC_DEMON) && //This bonus already doesnt work vs players
- src->type == BL_MOB && (temp=pc_checkskill(tsd,AL_DP)) > 0)
- vit_def += temp*(int)(3 +(tsd->status.base_level+1)*0.04); // submitted by orn
- if( src->type == BL_MOB && (temp=pc_checkskill(tsd,RA_RANGERMAIN))>0 &&
- (sstatus->race == RC_BRUTE || sstatus->race == RC_FISH || sstatus->race == RC_PLANT) )
- vit_def += temp*5;
+ , flag.pdef);
+ if( wd.damage2 )
+ wd.damage2 = battle->calc_defense(BF_WEAPON, src, target, skill_id, skill_lv, wd.damage2,
+ (flag.idef2?1:0)|(flag.pdef2?2:0)
#ifdef RENEWAL
- if( temp == NJ_ISSEN ){//TODO: do better implementation if other skills(same func) are found [malufett]
- vit_def += def1;
- def1 = 0;
- }
+ |(flag.tdef?4:0)
#endif
- }
- else { //Mob-Pet vit-eq
-#ifndef RENEWAL
- //VIT + rnd(0,[VIT/20]^2-1)
- vit_def = (def2/20)*(def2/20);
- vit_def = def2 + (vit_def>0?rnd()%vit_def:0);
-#else
- vit_def = def2;
-#endif
- }
-
-
- if (battle_config.weapon_defense_type) {
- vit_def += def1*battle_config.weapon_defense_type;
- def1 = 0;
- }
- #ifdef RENEWAL
- /**
- * RE DEF Reduction
- * Damage = Attack * (4000+eDEF)/(4000+eDEF) - sDEF
- * Pierce defence gains 1 atk per def/2
- **/
-
- if( def1 == -400 ) /* being hit by a gazillion units, you hit the jackpot and got -400 which creates a division by 0 and subsequently crashes */
- def1 = -399;
-
- ATK_ADD2(
- flag.pdef ?(def1/2):0,
- flag.pdef2?(def1/2):0
- );
- if( !flag.idef && !flag.pdef )
- wd.damage = wd.damage * (4000+def1) / (4000+10*def1) - vit_def;
- if( flag.lh && !flag.idef2 && !flag.pdef2 )
- wd.damage2 = wd.damage2 * (4000+def1) / (4000+10*def1) - vit_def;
-
- #else
- if (def1 > 100) def1 = 100;
- ATK_RATE2(
- flag.idef ?100:(flag.pdef ? flag.pdef*(def1+vit_def) : (100-def1)),
- flag.idef2?100:(flag.pdef2? flag.pdef2*(def1+vit_def) : (100-def1))
- );
- ATK_ADD2(
- flag.idef ||flag.pdef ?0:-vit_def,
- flag.idef2||flag.pdef2?0:-vit_def
- );
- #endif
+ , flag.pdef2);
}
+#ifdef RENEWAL
+ //Div fix.
+ damage_div_fix(wd.damage, wd.div_);
+#endif
//Post skill/vit reduction damage increases
if( sc )
{ //SC skill damages
@@ -3272,20 +4748,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
#endif
ATK_ADD(20*lv);
}
-
- if(sc->data[SC_GN_CARTBOOST])
- ATK_ADD(10*sc->data[SC_GN_CARTBOOST]->val1);
-
- if(sc->data[SC_GT_CHANGE] && sc->data[SC_GT_CHANGE]->val2){
- struct block_list *bl; // ATK increase: ATK [{(Caster DEX / 4) + (Caster STR / 2)} x Skill Level / 5]
- if( (bl = map_id2bl(sc->data[SC_GT_CHANGE]->val2)) )
- ATK_ADD( ( status_get_dex(bl)/4 + status_get_str(bl)/2 ) * sc->data[SC_GT_CHANGE]->val1 / 5 );
- }
-
- if(sc->data[SC_CAMOUFLAGE])
- ATK_ADD(30 * (10-sc->data[SC_CAMOUFLAGE]->val4) );
}
-
+#ifndef RENEWAL
//Refine bonus
if( sd && flag.weapon && skill_id != MO_INVESTIGATE && skill_id != MO_EXTREMITYFIST )
{ // Counts refine bonus multiple times
@@ -3296,83 +4760,38 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
ATK_ADD2(sstatus->rhw.atk2, sstatus->lhw.atk2);
}
}
-
//Set to min of 1
if (flag.rh && wd.damage < 1) wd.damage = 1;
if (flag.lh && wd.damage2 < 1) wd.damage2 = 1;
+#else
+ if (flag.rh && wd.damage < 1) wd.damage = 0;
+ if (flag.lh && wd.damage2 < 1) wd.damage2 = 0;
+#endif
- if (sd && flag.weapon &&
- skill_id != MO_INVESTIGATE &&
- skill_id != MO_EXTREMITYFIST &&
- skill_id != CR_GRANDCROSS)
- { //Add mastery damage
- if(skill_id != ASC_BREAKER && sd->status.weapon == W_KATAR &&
- (temp=pc_checkskill(sd,ASC_KATAR)) > 0)
- { //Adv Katar Mastery is does not applies to ASC_BREAKER,
- // but other masteries DO apply >_>
- ATK_ADDRATE(10+ 2*temp);
- }
-
- wd.damage = battle->add_mastery(sd,target,wd.damage,0);
- if (flag.lh)
- wd.damage2 = battle->add_mastery(sd,target,wd.damage2,1);
-
- if (sc && sc->data[SC_MIRACLE]) i = 2; //Star anger
- else
- ARR_FIND(0, MAX_PC_FEELHATE, i, t_class == sd->hate_mob[i]);
- if (i < MAX_PC_FEELHATE && (temp=pc_checkskill(sd,sg_info[i].anger_id))) {
- skillratio = sd->status.base_level + sstatus->dex + sstatus->luk;
- if (i == 2) skillratio += sstatus->str; //Star Anger
- if (temp<4)
- skillratio /= 12-3*temp;
- ATK_ADDRATE(skillratio);
- }
- if (skill_id == NJ_SYURIKEN && (temp = pc_checkskill(sd,NJ_TOBIDOUGU)) > 0) {
- ATK_ADD(3*temp);
- } else if (skill_id == NJ_KUNAI)
- ATK_ADD(60);
- }
+#ifndef RENEWAL
+ wd.damage = battle->calc_masteryfix(src, target, skill_id, skill_lv, wd.damage, wd.div_, 0, flag.weapon);
+ if( flag.lh)
+ wd.damage2 = battle->calc_masteryfix(src, target, skill_id, skill_lv, wd.damage2, wd.div_, 1, flag.weapon);
+#else
+ if( flag.cri )
+ ATK_ADDRATE(40);
+#endif
} //Here ends flag.hit section, the rest of the function applies to both hitting and missing attacks
else if(wd.div_ < 0) //Since the attack missed...
wd.div_ *= -1;
-
- if(sd && (temp=pc_checkskill(sd,BS_WEAPONRESEARCH)) > 0)
+#ifndef RENEWAL
+ if(sd && (temp=pc->checkskill(sd,BS_WEAPONRESEARCH)) > 0)
ATK_ADD(temp*2);
-
+#endif
if(skill_id==TF_POISON)
ATK_ADD(15*skill_lv);
-
- if( !(nk&NK_NO_ELEFIX) && !n_ele )
- { //Elemental attribute fix
- if( wd.damage > 0 )
- {
- wd.damage=battle->attr_fix(src,target,wd.damage,s_ele,tstatus->def_ele, tstatus->ele_lv);
- if( skill_id == MC_CARTREVOLUTION ) //Cart Revolution applies the element fix once more with neutral element
- wd.damage = battle->attr_fix(src,target,wd.damage,ELE_NEUTRAL,tstatus->def_ele, tstatus->ele_lv);
- if( skill_id== GS_GROUNDDRIFT ) //Additional 50*lv Neutral damage.
- wd.damage += battle->attr_fix(src,target,50*skill_lv,ELE_NEUTRAL,tstatus->def_ele, tstatus->ele_lv);
- }
- if( flag.lh && wd.damage2 > 0 )
- wd.damage2 = battle->attr_fix(src,target,wd.damage2,s_ele_,tstatus->def_ele, tstatus->ele_lv);
- if( sc && sc->data[SC_WATK_ELEMENT] )
- { // Descriptions indicate this means adding a percent of a normal attack in another element. [Skotlex]
- int damage = battle->calc_base_damage(sstatus, &sstatus->rhw, sc, tstatus->size, sd, (flag.arrow?2:0)) * sc->data[SC_WATK_ELEMENT]->val2 / 100;
- wd.damage += battle->attr_fix(src, target, damage, sc->data[SC_WATK_ELEMENT]->val1, tstatus->def_ele, tstatus->ele_lv);
-
- if( flag.lh ) {
- damage = battle->calc_base_damage(sstatus, &sstatus->lhw, sc, tstatus->size, sd, (flag.arrow?2:0)) * sc->data[SC_WATK_ELEMENT]->val2 / 100;
- wd.damage2 += battle->attr_fix(src, target, damage, sc->data[SC_WATK_ELEMENT]->val1, tstatus->def_ele, tstatus->ele_lv);
- }
- }
- #ifdef RENEWAL
- /**
- * In RE Shield Bommerang takes weapon element only for damage calculation,
- * - resist calculation is always against neutral
- **/
- if ( skill_id == CR_SHIELDBOOMERANG )
- s_ele = s_ele_ = ELE_NEUTRAL;
- #endif
- }
+/* temp-fix until malufett adjusts */
+//#ifndef RENEWAL
+#if 1
+ wd.damage = battle->calc_elefix(src, target, skill_id, skill_lv, wd.damage, nk, n_ele, s_ele, s_ele_, false, flag.arrow);
+ if( flag.lh )
+ wd.damage2 = battle->calc_elefix(src, target, skill_id, skill_lv, wd.damage2, nk, n_ele, s_ele, s_ele_, true, flag.arrow);
+#endif
if(skill_id == CR_GRANDCROSS || skill_id == NPC_GRANDDARKNESS)
return wd; //Enough, rest is not needed.
@@ -3395,6 +4814,9 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
}
}
#endif
+/* modiftying until malufett adjusts */
+//#ifndef RENEWAL
+#if 1
if (sd) {
if (skill_id != CR_SHIELDBOOMERANG) //Only Shield boomerang doesn't takes the Star Crumbs bonus.
ATK_ADD2(wd.div_*sd->right_weapon.star, wd.div_*sd->left_weapon.star);
@@ -3403,7 +4825,6 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
} else {
ATK_ADD(wd.div_*sd->spiritball*3);
}
-
//Card Fix, sd side
wd.damage = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, 2, wd.flag);
if( flag.lh )
@@ -3419,11 +4840,11 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
ATK_ADD(10*sd->status.inventory[index].refine);
}
}
-
//Card Fix, tsd side
- if(tsd) //if player on player then it was already measured above
- wd.damage = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, flag.lh, wd.flag);
-
+ if(tsd){ //if player on player then it was already measured above
+ wd.damage = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, 0, wd.flag);
+ }
+#endif
if( flag.infdef ) { //Plants receive 1 damage when hit
short class_ = status_get_class(target);
if( flag.hit || wd.damage > 0 )
@@ -3454,24 +4875,34 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
flag.lh=0;
} else if(flag.rh && flag.lh) { //Dual-wield
if (wd.damage) {
- if( (temp = pc_checkskill(sd,AS_RIGHT)) )
- ATK_RATER(50 + (temp * 10))
- else if( (temp = pc_checkskill(sd,KO_RIGHT)) )
- ATK_RATER(70 + (temp * 10))
- if(wd.damage < 1) wd.damage = 1;
+ temp = pc->checkskill(sd,AS_RIGHT) * 10;
+ if( (sd->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO )
+ temp = pc->checkskill(sd,KO_RIGHT) * 10 + 20;
+ ATK_RATER( 50 + temp );
}
if (wd.damage2) {
- if( (temp = pc_checkskill(sd,AS_LEFT)) )
- ATK_RATEL(30 + (temp * 10))
- else if( (temp = pc_checkskill(sd,KO_LEFT)) )
- ATK_RATEL(50 + (temp * 10))
- if(wd.damage2 < 1) wd.damage2 = 1;
+ temp = pc->checkskill(sd,AS_LEFT) * 10;
+ if( (sd->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO )
+ temp = pc->checkskill(sd,KO_LEFT) * 10 + 20;
+ ATK_RATEL( 30 + temp );
}
+#ifdef RENEWAL
+ if(wd.damage < 0) wd.damage = 0;
+ if(wd.damage2 < 0) wd.damage2 = 0;
+#else
+ if(wd.damage < 1) wd.damage = 1;
+ if(wd.damage2 < 1) wd.damage2 = 1;
+#endif
} else if(sd->status.weapon == W_KATAR && !skill_id) { //Katars (offhand damage only applies to normal attacks, tested on Aegis 10.2)
- temp = pc_checkskill(sd,TF_DOUBLE);
+ temp = pc->checkskill(sd,TF_DOUBLE);
wd.damage2 = wd.damage * (1 + (temp * 2))/100;
- if(wd.damage && !wd.damage2) wd.damage2 = 1;
+ if(wd.damage && !wd.damage2) wd.damage2 =
+#ifdef RENEWAL
+ 0;
+#else
+ 1;
+#endif
flag.lh = 1;
}
}
@@ -3482,8 +4913,82 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if(!flag.lh && wd.damage2)
wd.damage2=0;
+ if( sc ) {
+ //SG_FUSION hp penalty [Komurka]
+ if (sc->data[SC_FUSION]) {
+ int hp= sstatus->max_hp;
+ if (sd && tsd) {
+ hp = 8*hp/100;
+ if ((sstatus->hp * 100) <= (sstatus->max_hp * 20))
+ hp = sstatus->hp;
+ } else
+ hp = 2*hp/100; //2% hp loss per hit
+ status_zap(src, hp, 0);
+ }
+ if( !skill_id ) {
+ if( sc->data[SC_ENCHANTBLADE] ) { // it also works with bear hands..intended in official
+ //[( ( Skill Lv x 20 ) + 100 ) x ( casterBaseLevel / 150 )] + casterInt
+ ATK_ADD(( sc->data[SC_ENCHANTBLADE]->val1 * 20 + 100 ) * status_get_lv(src) / 150 + status_get_int(src));
+ }
+ }
+ status_change_end(src,SC_CAMOUFLAGE, INVALID_TIMER);
+ }
+
+ switch(skill_id){
+ case LG_RAYOFGENESIS:
+ {
+ struct Damage md = battle->calc_magic_attack(src, target, skill_id, skill_lv, wflag);
+ wd.damage += md.damage;
+ break;
+ }
+ case SR_GATEOFHELL:
+ ATK_ADD (sstatus->max_hp - status_get_hp(src));
+ if(sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == SR_FALLENEMPIRE){
+ ATK_ADD ( (sstatus->max_sp * (1 + skill_lv * 2 / 10)) + 40 * status_get_lv(src) );
+ }else{
+ ATK_ADD ( (sstatus->sp * (1 + skill_lv * 2 / 10)) + 10 * status_get_lv(src) );
+ }
+ break;
+ }
+
if( wd.damage + wd.damage2 )
{ //There is a total damage value
+ int damage = wd.damage + wd.damage2, rdamage = 0, rdelay = 0;
+
+ if( src != target &&
+ (!skill_id || skill_id ||
+ ( src->type == BL_SKILL && ( skill_id == SG_SUN_WARM || skill_id == SG_MOON_WARM || skill_id == SG_STAR_WARM ) )) ){
+
+ rdamage = battle->calc_return_damage(target, src, &damage, wd.flag, 0, &rdelay);
+
+ if( tsc && tsc->count ) {
+ if( tsc && tsc->data[SC_DEATHBOUND] ){
+ wd.damage = damage;
+ wd.damage2 = 0;
+ status_change_end(target,SC_DEATHBOUND,INVALID_TIMER);
+ }
+ }
+ if( rdamage > 0 ) {
+ if( tsc && tsc->data[SC_LG_REFLECTDAMAGE] ) {
+ if( src != target ) {// Don't reflect your own damage (Grand Cross)
+ bool change = false;
+ if( sd && !sd->state.autocast )
+ change = true;
+ if( change )
+ sd->state.autocast = 1;
+ iMap->foreachinshootrange(battle->damage_area,target,skill->get_splash(LG_REFLECTDAMAGE,1),BL_CHAR,iTimer->gettick(),target,wd.amotion,sstatus->dmotion,rdamage,tstatus->race);
+ if( change )
+ sd->state.autocast = 0;
+ }
+ } else {
+ //Use Reflect Shield to signal this kind of skill trigger. [Skotlex]
+ if( tsd && src != target )
+ battle->drain(tsd, src, rdamage, rdamage, sstatus->race, is_boss(src));
+ battle->delay_damage(iTimer->gettick(), wd.amotion,target,src,0,CR_REFLECTSHIELD,0,rdamage,ATK_DEF,rdelay,true);
+ skill->additional_effect(target, src, CR_REFLECTSHIELD, 1, BF_WEAPON|BF_SHORT|BF_NORMAL,ATK_DEF,iTimer->gettick());
+ }
+ }
+ }
if(!wd.damage2)
{
wd.damage = battle->calc_damage(src,target,&wd,wd.damage,skill_id,skill_lv);
@@ -3502,1072 +5007,50 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
}
else
{
+#ifdef RENEWAL
+ wd.damage = battle->calc_damage(src,target,&wd,wd.damage,skill_id,skill_lv);
+ wd.damage2 = battle->calc_damage(src,target,&wd,wd.damage2,skill_id,skill_lv);
+#else
int d1 = wd.damage + wd.damage2,d2 = wd.damage2;
wd.damage = battle->calc_damage(src,target,&wd,d1,skill_id,skill_lv);
+#endif
if( map_flag_gvg2(target->m) )
wd.damage = battle->calc_gvg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag);
else if( map[target->m].flag.battleground )
wd.damage = battle->calc_bg_damage(src,target,wd.damage,wd.div_,skill_id,skill_lv,wd.flag);
+#ifndef RENEWAL
wd.damage2 = d2*100/d1 * wd.damage/100;
if(wd.damage > 1 && wd.damage2 < 1) wd.damage2 = 1;
wd.damage-=wd.damage2;
+#endif
}
}
//Reject Sword bugreport:4493 by Daegaladh
- if(wd.damage && tsc && tsc->data[SC_REJECTSWORD] &&
+ if(wd.damage && tsc && tsc->data[SC_SWORDREJECT] &&
(src->type!=BL_PC || (
((TBL_PC *)src)->weapontype1 == W_DAGGER ||
((TBL_PC *)src)->weapontype1 == W_1HSWORD ||
((TBL_PC *)src)->status.weapon == W_2HSWORD
)) &&
- rnd()%100 < tsc->data[SC_REJECTSWORD]->val2
+ rnd()%100 < tsc->data[SC_SWORDREJECT]->val2
) {
ATK_RATER(50)
- status_fix_damage(target,src,wd.damage,clif->damage(target,src,gettick(),0,0,wd.damage,0,0,0));
- clif->skill_nodamage(target,target,ST_REJECTSWORD,tsc->data[SC_REJECTSWORD]->val1,1);
- if( --(tsc->data[SC_REJECTSWORD]->val3) <= 0 )
- status_change_end(target, SC_REJECTSWORD, INVALID_TIMER);
+ status_fix_damage(target,src,wd.damage,clif->damage(target,src,iTimer->gettick(),0,0,wd.damage,0,0,0));
+ clif->skill_nodamage(target,target,ST_REJECTSWORD,tsc->data[SC_SWORDREJECT]->val1,1);
+ if( --(tsc->data[SC_SWORDREJECT]->val3) <= 0 )
+ status_change_end(target, SC_SWORDREJECT, INVALID_TIMER);
}
+#ifndef RENEWAL
if(skill_id == ASC_BREAKER) { //Breaker's int-based damage (a misc attack?)
struct Damage md = battle->calc_misc_attack(src, target, skill_id, skill_lv, wflag);
wd.damage += md.damage;
}
- if( sc ) {
- //SG_FUSION hp penalty [Komurka]
- if (sc->data[SC_FUSION]) {
- int hp= sstatus->max_hp;
- if (sd && tsd) {
- hp = 8*hp/100;
- if ((sstatus->hp * 100) <= (sstatus->max_hp * 20))
- hp = sstatus->hp;
- } else
- hp = 2*hp/100; //2% hp loss per hit
- status_zap(src, hp, 0);
- }
- /**
- * affecting non-skills
- **/
- if( !skill_id ) {
- /**
- * RK Enchant Blade
- **/
- if( sc->data[SC_ENCHANTBLADE] && sd && ( (flag.rh && sd->weapontype1) || (flag.lh && sd->weapontype2) ) ) {
- //[( ( Skill Lv x 20 ) + 100 ) x ( casterBaseLevel / 150 )] + casterInt
- ATK_ADD( ( sc->data[SC_ENCHANTBLADE]->val1*20+100 ) * status_get_lv(src) / 150 + status_get_int(src) );
- }
- }
- status_change_end(src,SC_CAMOUFLAGE, INVALID_TIMER);
- }
- if( skill_id == LG_RAYOFGENESIS ) {
- struct Damage md = battle->calc_magic_attack(src, target, skill_id, skill_lv, wflag);
- wd.damage += md.damage;
- }
-
- return wd;
-}
-
-/*==========================================
- * battle_calc_magic_attack [DracoRPG]
- *------------------------------------------*/
-struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int mflag) {
- int i, nk;
- short s_ele = 0;
- unsigned int skillratio = 100; //Skill dmg modifiers.
-
- TBL_PC *sd;
-// TBL_PC *tsd;
- struct status_change *sc, *tsc;
- struct Damage ad;
- struct status_data *sstatus = status_get_status_data(src);
- struct status_data *tstatus = status_get_status_data(target);
- struct {
- unsigned imdef : 1;
- unsigned infdef : 1;
- } flag;
-
- memset(&ad,0,sizeof(ad));
- memset(&flag,0,sizeof(flag));
-
- if(src==NULL || target==NULL)
- {
- nullpo_info(NLP_MARK);
- return ad;
- }
- //Initial Values
- ad.damage = 1;
- ad.div_=skill->get_num(skill_id,skill_lv);
- ad.amotion=skill->get_inf(skill_id)&INF_GROUND_SKILL?0:sstatus->amotion; //Amotion should be 0 for ground skills.
- ad.dmotion=tstatus->dmotion;
- ad.blewcount = skill->get_blewcount(skill_id,skill_lv);
- ad.flag=BF_MAGIC|BF_SKILL;
- ad.dmg_lv=ATK_DEF;
- nk = skill->get_nk(skill_id);
- flag.imdef = nk&NK_IGNORE_DEF?1:0;
-
- sd = BL_CAST(BL_PC, src);
-// tsd = BL_CAST(BL_PC, target);
- sc = status_get_sc(src);
- tsc = status_get_sc(target);
-
- //Initialize variables that will be used afterwards
- s_ele = skill->get_ele(skill_id, skill_lv);
-
- if (s_ele == -1){ // pl=-1 : the skill takes the weapon's element
- s_ele = sstatus->rhw.ele;
- if( sd ){ //Summoning 10 talisman will endow your weapon
- ARR_FIND(1, 6, i, sd->talisman[i] >= 10);
- if( i < 5 ) s_ele = i;
- }
- }else if (s_ele == -2) //Use status element
- s_ele = status_get_attack_sc_element(src,status_get_sc(src));
- else if( s_ele == -3 ) //Use random element
- s_ele = rnd()%ELE_MAX;
-
- if( skill_id == SO_PSYCHIC_WAVE ) {
- if( sc && sc->count ) {
- if( sc->data[SC_HEATER_OPTION] ) s_ele = sc->data[SC_HEATER_OPTION]->val4;
- else if( sc->data[SC_COOLER_OPTION] ) s_ele = sc->data[SC_COOLER_OPTION]->val4;
- else if( sc->data[SC_BLAST_OPTION] ) s_ele = sc->data[SC_BLAST_OPTION]->val3;
- else if( sc->data[SC_CURSED_SOIL_OPTION] ) s_ele = sc->data[SC_CURSED_SOIL_OPTION]->val4;
- }
- }
-
- //Set miscellaneous data that needs be filled
- if(sd) {
- sd->state.arrow_atk = 0;
- ad.blewcount += battle->blewcount_bonus(sd, skill_id);
- }
-
- //Skill Range Criteria
- ad.flag |= battle->range_type(src, target, skill_id, skill_lv);
- flag.infdef=(tstatus->mode&MD_PLANT?1:0);
- if( target->type == BL_SKILL){
- TBL_SKILL *su = (TBL_SKILL*)target;
- if( su->group && (su->group->skill_id == WM_REVERBERATION || su->group->skill_id == WM_POEMOFNETHERWORLD) )
- flag.infdef = 1;
- }
-
- switch(skill_id)
- {
- case MG_FIREWALL:
- case NJ_KAENSIN:
- ad.dmotion = 0; //No flinch animation.
- if ( tstatus->def_ele == ELE_FIRE || battle->check_undead(tstatus->race, tstatus->def_ele) )
- ad.blewcount = 0; //No knockback
- break;
- case PR_SANCTUARY:
- ad.dmotion = 0; //No flinch animation.
- break;
- }
-
- if (!flag.infdef) //No need to do the math for plants
- {
-#ifdef RENEWAL
- ad.damage = 0; //reinitialize..
#endif
-//MATK_RATE scales the damage. 100 = no change. 50 is halved, 200 is doubled, etc
-#define MATK_RATE( a ) { ad.damage= ad.damage*(a)/100; }
-//Adds dmg%. 100 = +100% (double) damage. 10 = +10% damage
-#define MATK_ADDRATE( a ) { ad.damage+= ad.damage*(a)/100; }
-//Adds an absolute value to damage. 100 = +100 damage
-#define MATK_ADD( a ) { ad.damage+= a; }
-
- switch (skill_id)
- { //Calc base damage according to skill
- case AL_HEAL:
- case PR_BENEDICTIO:
- case PR_SANCTUARY:
- /**
- * Arch Bishop
- **/
- case AB_HIGHNESSHEAL:
- ad.damage = skill->calc_heal(src, target, skill_id, skill_lv, false);
- break;
- case PR_ASPERSIO:
- ad.damage = 40;
- break;
- case ALL_RESURRECTION:
- case PR_TURNUNDEAD:
- //Undead check is on skill_castend_damageid code.
- #ifdef RENEWAL
- i = 10*skill_lv + sstatus->luk + sstatus->int_ + status_get_lv(src)
- + 300 - 300*tstatus->hp/tstatus->max_hp;
- #else
- i = 20*skill_lv + sstatus->luk + sstatus->int_ + status_get_lv(src)
- + 200 - 200*tstatus->hp/tstatus->max_hp;
- #endif
- if(i > 700) i = 700;
- if(rnd()%1000 < i && !(tstatus->mode&MD_BOSS))
- ad.damage = tstatus->hp;
- else {
- #ifdef RENEWAL
- if (sstatus->matk_max > sstatus->matk_min) {
- MATK_ADD(sstatus->matk_min+rnd()%(sstatus->matk_max-sstatus->matk_min));
- } else {
- MATK_ADD(sstatus->matk_min);
- }
- MATK_RATE(skill_lv);
- #else
- ad.damage = status_get_lv(src) + sstatus->int_ + skill_lv * 10;
- #endif
- }
- break;
- case PF_SOULBURN:
- ad.damage = tstatus->sp * 2;
- break;
- /**
- * Arch Bishop
- **/
- case AB_RENOVATIO:
- //Damage calculation from iRO wiki. [Jobbie]
- ad.damage = (int)((15 * status_get_lv(src)) + (1.5 * sstatus->int_));
- break;
- default: {
- if (sstatus->matk_max > sstatus->matk_min) {
- MATK_ADD(sstatus->matk_min+rnd()%(sstatus->matk_max-sstatus->matk_min));
- } else {
- MATK_ADD(sstatus->matk_min);
- }
-
- if (nk&NK_SPLASHSPLIT) { // Divide MATK in case of multiple targets skill
- if(mflag>0)
- ad.damage/= mflag;
- else
- ShowError("0 enemies targeted by %d:%s, divide per 0 avoided!\n", skill_id, skill->get_name(skill_id));
- }
-
- switch(skill_id){
- case MG_NAPALMBEAT:
- skillratio += skill_lv*10-30;
- break;
- case MG_FIREBALL:
- #ifdef RENEWAL
- skillratio += 20*skill_lv;
- #else
- skillratio += skill_lv*10-30;
- #endif
- break;
- case MG_SOULSTRIKE:
- if (battle->check_undead(tstatus->race,tstatus->def_ele))
- skillratio += 5*skill_lv;
- break;
- case MG_FIREWALL:
- skillratio -= 50;
- break;
- case MG_FIREBOLT:
- case MG_COLDBOLT:
- case MG_LIGHTNINGBOLT:
- if ( sc && sc->data[SC_SPELLFIST] && mflag&BF_SHORT ) {
- skillratio += (sc->data[SC_SPELLFIST]->val4 * 100) + (sc->data[SC_SPELLFIST]->val2 * 100) - 100;// val4 = used bolt level, val2 = used spellfist level. [Rytech]
- ad.div_ = 1;// ad mods, to make it work similar to regular hits [Xazax]
- ad.flag = BF_WEAPON|BF_SHORT;
- ad.type = 0;
- }
- break;
- case MG_THUNDERSTORM:
- /**
- * in Renewal Thunder Storm boost is 100% (in pre-re, 80%)
- **/
- #ifndef RENEWAL
- skillratio -= 20;
- #endif
- break;
- case MG_FROSTDIVER:
- skillratio += 10*skill_lv;
- break;
- case AL_HOLYLIGHT:
- skillratio += 25;
- if (sd && sd->sc.data[SC_SPIRIT] && sd->sc.data[SC_SPIRIT]->val2 == SL_PRIEST)
- skillratio *= 5; //Does 5x damage include bonuses from other skills?
- break;
- case AL_RUWACH:
- skillratio += 45;
- break;
- case WZ_FROSTNOVA:
- skillratio += (100+skill_lv*10)*2/3-100;
- break;
- case WZ_FIREPILLAR:
- if (skill_lv > 10)
- skillratio += 100;
- else
- skillratio -= 80;
- break;
- case WZ_SIGHTRASHER:
- skillratio += 20*skill_lv;
- break;
- case WZ_WATERBALL:
- skillratio += 30*skill_lv;
- break;
- case WZ_STORMGUST:
- skillratio += 40*skill_lv;
- break;
- case HW_NAPALMVULCAN:
- skillratio += 10*skill_lv-30;
- break;
- case SL_STIN:
- skillratio += (tstatus->size!=SZ_SMALL?-99:10*skill_lv); //target size must be small (0) for full damage.
- break;
- case SL_STUN:
- skillratio += (tstatus->size!=SZ_BIG?5*skill_lv:-99); //Full damage is dealt on small/medium targets
- break;
- case SL_SMA:
- skillratio += -60 + status_get_lv(src); //Base damage is 40% + lv%
- break;
- case NJ_KOUENKA:
- skillratio -= 10;
- break;
- case NJ_KAENSIN:
- skillratio -= 50;
- break;
- case NJ_BAKUENRYU:
- skillratio += 50*(skill_lv-1);
- break;
- case NJ_HYOUSYOURAKU:
- skillratio += 50*skill_lv;
- break;
- case NJ_RAIGEKISAI:
- skillratio += 60 + 40*skill_lv;
- break;
- case NJ_KAMAITACHI:
- case NPC_ENERGYDRAIN:
- skillratio += 100*skill_lv;
- break;
- case NPC_EARTHQUAKE:
- skillratio += 100 +100*skill_lv +100*(skill_lv/2);
- break;
- #ifdef RENEWAL
- case WZ_HEAVENDRIVE:
- case WZ_METEOR:
- skillratio += 25;
- break;
- case WZ_VERMILION:
- {
- int interval = 0, per = interval, ratio = per;
- while( (per++) < skill_lv ){
- ratio += interval;
- if(per%3==0) interval += 20;
- }
- if( skill_lv > 9 )
- ratio -= 10;
- skillratio += ratio;
- }
- break;
- case NJ_HUUJIN:
- skillratio += 50;
- break;
- #else
- case WZ_VERMILION:
- skillratio += 20*skill_lv-20;
- break;
- #endif
- /**
- * Arch Bishop
- **/
- case AB_JUDEX:
- skillratio += 180 + 20 * skill_lv;
- if (skill_lv > 4) skillratio += 20;
- RE_LVL_DMOD(100);
- break;
- case AB_ADORAMUS:
- skillratio += 400 + 100 * skill_lv;
- RE_LVL_DMOD(100);
- break;
- case AB_DUPLELIGHT_MAGIC:
- skillratio += 100 + 20 * skill_lv;
- break;
- /**
- * Warlock
- **/
- case WL_SOULEXPANSION:
- skillratio += 300 + 100 * skill_lv + sstatus->int_;
- RE_LVL_DMOD(100);
- break;
- case WL_FROSTMISTY:
- skillratio += 100 + 100 * skill_lv;
- RE_LVL_DMOD(100);
- break;
- case WL_JACKFROST:
- if( tsc && tsc->data[SC_FREEZING] ){
- skillratio += 900 + 300 * skill_lv;
- RE_LVL_DMOD(100);
- }else{
- skillratio += 400 + 100 * skill_lv;
- RE_LVL_DMOD(150);
- }
- break;
- case WL_DRAINLIFE:
- skillratio = 200 * skill_lv + sstatus->int_;
- RE_LVL_DMOD(100);
- break;
- case WL_CRIMSONROCK:
- skillratio += 1200 + 300 * skill_lv;
- RE_LVL_DMOD(100);
- break;
- case WL_HELLINFERNO:
- skillratio = 300 * skill_lv;
- RE_LVL_DMOD(100);
- // Shadow: MATK [{( Skill Level x 300 ) x ( Caster Base Level / 100 ) x 4/5 }] %
- // Fire : MATK [{( Skill Level x 300 ) x ( Caster Base Level / 100 ) /5 }] %
- if( mflag&ELE_DARK ){ skillratio *= 4; s_ele = ELE_DARK; }
- skillratio /= 5;
- break;
- case WL_COMET: {
- struct status_change * sc = status_get_sc(src);
- if( sc )
- i = distance_xy(target->x, target->y, sc->comet_x, sc->comet_y);
- else
- i = 8;
- if( i < 2 ) skillratio = 2500 + 500 * skill_lv;
- else
- if( i < 4 ) skillratio = 1600 + 400 * skill_lv;
- else
- if( i < 6 ) skillratio = 1200 + 300 * skill_lv;
- else
- skillratio = 800 + 200 * skill_lv;
- }
- break;
- case WL_CHAINLIGHTNING_ATK:
- skillratio += 100 + 300 * skill_lv;
- RE_LVL_DMOD(100);
- break;
- case WL_EARTHSTRAIN:
- skillratio += 1900 + 100 * skill_lv;
- RE_LVL_DMOD(100);
- break;
- case WL_TETRAVORTEX_FIRE:
- case WL_TETRAVORTEX_WATER:
- case WL_TETRAVORTEX_WIND:
- case WL_TETRAVORTEX_GROUND:
- skillratio += 400 + 500 * skill_lv;
- break;
- case WL_SUMMON_ATK_FIRE:
- case WL_SUMMON_ATK_WATER:
- case WL_SUMMON_ATK_WIND:
- case WL_SUMMON_ATK_GROUND:
- skillratio = skill_lv * (status_get_lv(src) + ( sd ? sd->status.job_level : 50 ));// This is close to official, but lacking a little info to finalize. [Rytech]
- RE_LVL_DMOD(100);
- break;
- case LG_RAYOFGENESIS:
- {
- int16 lv = skill_lv;
- int bandingBonus = 0;
- if( sc && sc->data[SC_BANDING] )
- bandingBonus = 200 * (sd ? skill->check_pc_partner(sd,skill_id,&lv,skill->get_splash(skill_id,skill_lv),0) : 1);
- skillratio = ((300 * skill_lv) + bandingBonus) * (sd ? sd->status.job_level : 1) / 25;
- }
- break;
- case LG_SHIELDSPELL:// [(Casters Base Level x 4) + (Shield MDEF x 100) + (Casters INT x 2)] %
- if( sd ) {
- skillratio = status_get_lv(src) * 4 + sd->bonus.shieldmdef * 100 + status_get_int(src) * 2;
- } else
- skillratio += 1900; //2000%
- break;
- case WM_METALICSOUND:
- skillratio += 120 * skill_lv + 60 * ( sd? pc_checkskill(sd, WM_LESSON) : 10 ) - 100;
- break;
- /*case WM_SEVERE_RAINSTORM:
- skillratio += 50 * skill_lv;
- break;
-
- WM_SEVERE_RAINSTORM just set a unit place,
- refer to WM_SEVERE_RAINSTORM_MELEE to set the formula.
- */
- case WM_REVERBERATION_MAGIC:
- // MATK [{(Skill Level x 100) + 100} x Casters Base Level / 100] %
- skillratio += 100 * (sd ? pc_checkskill(sd, WM_REVERBERATION) : 1);
- RE_LVL_DMOD(100);
- break;
- case SO_FIREWALK:
- skillratio = 300;
- RE_LVL_DMOD(100);
- if( sc && sc->data[SC_HEATER_OPTION] )
- skillratio += sc->data[SC_HEATER_OPTION]->val3;
- break;
- case SO_ELECTRICWALK:
- skillratio = 300;
- RE_LVL_DMOD(100);
- if( sc && sc->data[SC_BLAST_OPTION] )
- skillratio += sd ? sd->status.job_level / 2 : 0;
- break;
- case SO_EARTHGRAVE:
- skillratio = ( 200 * ( sd ? pc_checkskill(sd, SA_SEISMICWEAPON) : 10 ) + sstatus->int_ * skill_lv );
- RE_LVL_DMOD(100);
- if( sc && sc->data[SC_CURSED_SOIL_OPTION] )
- skillratio += sc->data[SC_CURSED_SOIL_OPTION]->val2;
- break;
- case SO_DIAMONDDUST:
- skillratio = ( 200 * ( sd ? pc_checkskill(sd, SA_FROSTWEAPON) : 10 ) + sstatus->int_ * skill_lv );
- RE_LVL_DMOD(100);
- if( sc && sc->data[SC_COOLER_OPTION] )
- skillratio += sc->data[SC_COOLER_OPTION]->val3;
- break;
- case SO_POISON_BUSTER:
- skillratio += 1100 + 300 * skill_lv;
- if( sc && sc->data[SC_CURSED_SOIL_OPTION] )
- skillratio += sc->data[SC_CURSED_SOIL_OPTION]->val2;
- break;
- case SO_PSYCHIC_WAVE:
- skillratio += -100 + skill_lv * 70 + (sstatus->int_ * 3);
- RE_LVL_DMOD(100);
- if( sc ){
- if( sc->data[SC_HEATER_OPTION] )
- skillratio += sc->data[SC_HEATER_OPTION]->val3;
- else if(sc->data[SC_COOLER_OPTION] )
- skillratio += sc->data[SC_COOLER_OPTION]->val3;
- else if(sc->data[SC_BLAST_OPTION] )
- skillratio += sc->data[SC_BLAST_OPTION]->val2;
- else if(sc->data[SC_CURSED_SOIL_OPTION] )
- skillratio += sc->data[SC_CURSED_SOIL_OPTION]->val3;
- }
- break;
- case SO_VARETYR_SPEAR: //MATK [{( Endow Tornado skill level x 50 ) + ( Caster INT x Varetyr Spear Skill level )} x Caster Base Level / 100 ] %
- skillratio = status_get_int(src) * skill_lv + ( sd ? pc_checkskill(sd, SA_LIGHTNINGLOADER) * 50 : 0 );
- RE_LVL_DMOD(100);
- if( sc && sc->data[SC_BLAST_OPTION] )
- skillratio += sd ? sd->status.job_level * 5 : 0;
- break;
- case SO_CLOUD_KILL:
- skillratio += -100 + skill_lv * 40;
- RE_LVL_DMOD(100);
- if( sc && sc->data[SC_CURSED_SOIL_OPTION] )
- skillratio += sc->data[SC_CURSED_SOIL_OPTION]->val2;
- break;
- case GN_DEMONIC_FIRE:
- if( skill_lv > 20)
- { // Fire expansion Lv.2
- skillratio += 110 + 20 * (skill_lv - 20) + status_get_int(src) * 3; // Need official INT bonus. [LimitLine]
- }
- else if( skill_lv > 10 )
- { // Fire expansion Lv.1
- skillratio += 110 + 20 * (skill_lv - 10) / 2;
- }
- else
- skillratio += 110 + 20 * skill_lv;
- break;
- // Magical Elemental Spirits Attack Skills
- case EL_FIRE_MANTLE:
- case EL_WATER_SCREW:
- skillratio += 900;
- break;
- case EL_FIRE_ARROW:
- case EL_ROCK_CRUSHER_ATK:
- skillratio += 200;
- break;
- case EL_FIRE_BOMB:
- case EL_ICE_NEEDLE:
- case EL_HURRICANE_ATK:
- skillratio += 400;
- break;
- case EL_FIRE_WAVE:
- case EL_TYPOON_MIS_ATK:
- skillratio += 1100;
- break;
- case MH_ERASER_CUTTER:
- if(skill_lv%2) skillratio += 400; //600:800:1000
- else skillratio += 700; //1000:1200
- skillratio += 100 * skill_lv;
- break;
- case MH_XENO_SLASHER:
- if(skill_lv%2) skillratio += 350 + 50 * skill_lv; //500:600:700
- else skillratio += 400 + 100 * skill_lv; //700:900
- break;
- case MH_HEILIGE_STANGE:
- skillratio += 400 + 250 * skill_lv;
- break;
- case MH_POISON_MIST:
- skillratio += 100 * skill_lv;
- break;
- }
-
- MATK_RATE(skillratio);
- //Constant/misc additions from skills
- if (skill_id == WZ_FIREPILLAR)
- MATK_ADD(50);
- }
- }
-#ifndef HMAP_ZONE_DAMAGE_CAP_TYPE
- if( target && skill_id ) {
- for(i = 0; i < map[target->m].zone->capped_skills_count; i++) {
- if( skill_id == map[target->m].zone->capped_skills[i]->nameid && (map[target->m].zone->capped_skills[i]->type & target->type) ) {
- if( target->type == BL_MOB && map[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) {
- if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) )
- continue;
- if( ((TBL_MOB*)target)->special_state.clone && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) )
- continue;
- }
- if( ad.damage > map[target->m].zone->capped_skills[i]->cap )
- ad.damage = map[target->m].zone->capped_skills[i]->cap;
- if( ad.damage2 > map[target->m].zone->capped_skills[i]->cap )
- ad.damage2 = map[target->m].zone->capped_skills[i]->cap;
- break;
- }
- }
- }
-#endif
-#ifdef RENEWAL
- ad.damage = battle->calc_cardfix(BF_MAGIC, src, target, nk, s_ele, 0, ad.damage, 0, ad.flag);
-#endif
- if(sd) {
- //Damage bonuses
- if ((i = pc_skillatk_bonus(sd, skill_id)))
- ad.damage += ad.damage*i/100;
-
- if( (i = battle->adjust_skill_damage(src->m,skill_id)) )
- MATK_RATE(i);
-
- //Ignore Defense?
- if (!flag.imdef && (
- sd->bonus.ignore_mdef_ele & ( 1 << tstatus->def_ele ) ||
- sd->bonus.ignore_mdef_race & ( 1 << tstatus->race ) ||
- sd->bonus.ignore_mdef_race & ( is_boss(target) ? 1 << RC_BOSS : 1 << RC_NONBOSS )
- ))
- flag.imdef = 1;
- }
-
- if(!flag.imdef){
- defType mdef = tstatus->mdef;
- int mdef2= tstatus->mdef2;
-#ifdef RENEWAL
- if(tsc && tsc->data[SC_ASSUMPTIO])
- mdef <<= 1; // only eMDEF is doubled
-#endif
- if(sd) {
- i = sd->ignore_mdef[is_boss(target)?RC_BOSS:RC_NONBOSS];
- i+= sd->ignore_mdef[tstatus->race];
- if (i)
- {
- if (i > 100) i = 100;
- mdef -= mdef * i/100;
- //mdef2-= mdef2* i/100;
- }
- }
- #ifdef RENEWAL
- /**
- * RE MDEF Reduction
- * Damage = Magic Attack * (1000+eMDEF)/(1000+eMDEF) - sMDEF
- **/
- ad.damage = ad.damage * (1000 + mdef) / (1000 + mdef * 10) - mdef2;
- #else
- if(battle_config.magic_defense_type)
- ad.damage = ad.damage - mdef*battle_config.magic_defense_type - mdef2;
- else
- ad.damage = ad.damage * (100-mdef)/100 - mdef2;
- #endif
- }
-
- if (skill_id == NPC_EARTHQUAKE)
- { //Adds atk2 to the damage, should be influenced by number of hits and skill-ratio, but not mdef reductions. [Skotlex]
- //Also divide the extra bonuses from atk2 based on the number in range [Kevin]
- if(mflag>0)
- ad.damage+= (sstatus->rhw.atk2*skillratio/100)/mflag;
- else
- ShowError("Zero range by %d:%s, divide per 0 avoided!\n", skill_id, skill->get_name(skill_id));
- }
-
- if(ad.damage<1)
- ad.damage=1;
- else if(sc){//only applies when hit
- // TODO: there is another factor that contribute with the damage and need to be formulated. [malufett]
- switch(skill_id){
- case MG_LIGHTNINGBOLT:
- case MG_THUNDERSTORM:
- case MG_FIREBOLT:
- case MG_FIREWALL:
- case MG_COLDBOLT:
- case MG_FROSTDIVER:
- case WZ_EARTHSPIKE:
- case WZ_HEAVENDRIVE:
- if(sc->data[SC_GUST_OPTION] || sc->data[SC_PETROLOGY_OPTION]
- || sc->data[SC_PYROTECHNIC_OPTION] || sc->data[SC_AQUAPLAY_OPTION])
- ad.damage += (6 + sstatus->int_/4) + max(sstatus->dex-10,0)/30;
- break;
- }
- }
-
- if (!(nk&NK_NO_ELEFIX))
- ad.damage=battle->attr_fix(src, target, ad.damage, s_ele, tstatus->def_ele, tstatus->ele_lv);
-
- if( skill_id == CR_GRANDCROSS || skill_id == NPC_GRANDDARKNESS )
- { //Apply the physical part of the skill's damage. [Skotlex]
- struct Damage wd = battle->calc_weapon_attack(src,target,skill_id,skill_lv,mflag);
- ad.damage = battle->attr_fix(src, target, wd.damage + ad.damage, s_ele, tstatus->def_ele, tstatus->ele_lv) * (100 + 40*skill_lv)/100;
- if( src == target )
- {
- if( src->type == BL_PC )
- ad.damage = ad.damage/2;
- else
- ad.damage = 0;
- }
- }
-
-#ifndef RENEWAL
- ad.damage = battle->calc_cardfix(BF_MAGIC, src, target, nk, s_ele, 0, ad.damage, 0, ad.flag);
-#endif
- }
-
- damage_div_fix(ad.damage, ad.div_);
-
- if (flag.infdef && ad.damage)
- ad.damage = ad.damage>0?1:-1;
-
- ad.damage=battle->calc_damage(src,target,&ad,ad.damage,skill_id,skill_lv);
- if( map_flag_gvg2(target->m) )
- ad.damage=battle->calc_gvg_damage(src,target,ad.damage,ad.div_,skill_id,skill_lv,ad.flag);
- else if( map[target->m].flag.battleground )
- ad.damage=battle->calc_bg_damage(src,target,ad.damage,ad.div_,skill_id,skill_lv,ad.flag);
-
- switch( skill_id ) { /* post-calc modifiers */
- case SO_VARETYR_SPEAR: { // Physical damage.
- struct Damage wd = battle->calc_weapon_attack(src,target,skill_id,skill_lv,mflag);
- if(!flag.infdef && ad.damage > 1)
- ad.damage += wd.damage;
- break;
- }
- //case HM_ERASER_CUTTER:
- }
-
- return ad;
+ return wd;
}
/*==========================================
- * Calculate Misc dammage for skill_id
- *------------------------------------------*/
-struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int mflag) {
- int temp;
- short i, nk;
- short s_ele;
-
- struct map_session_data *sd, *tsd;
- struct Damage md; //DO NOT CONFUSE with md of mob_data!
- struct status_data *sstatus = status_get_status_data(src);
- struct status_data *tstatus = status_get_status_data(target);
-
- memset(&md,0,sizeof(md));
-
- if( src == NULL || target == NULL ){
- nullpo_info(NLP_MARK);
- return md;
- }
-
- //Some initial values
- md.amotion=skill->get_inf(skill_id)&INF_GROUND_SKILL?0:sstatus->amotion;
- md.dmotion=tstatus->dmotion;
- md.div_=skill->get_num( skill_id,skill_lv );
- md.blewcount=skill->get_blewcount(skill_id,skill_lv);
- md.dmg_lv=ATK_DEF;
- md.flag=BF_MISC|BF_SKILL;
-
- nk = skill->get_nk(skill_id);
-
- sd = BL_CAST(BL_PC, src);
- tsd = BL_CAST(BL_PC, target);
-
- if(sd) {
- sd->state.arrow_atk = 0;
- md.blewcount += battle->blewcount_bonus(sd, skill_id);
- }
-
- s_ele = skill->get_ele(skill_id, skill_lv);
- if (s_ele < 0 && s_ele != -3) //Attack that takes weapon's element for misc attacks? Make it neutral [Skotlex]
- s_ele = ELE_NEUTRAL;
- else if (s_ele == -3) //Use random element
- s_ele = rnd()%ELE_MAX;
-
- //Skill Range Criteria
- md.flag |= battle->range_type(src, target, skill_id, skill_lv);
-
- switch( skill_id )
- {
-#ifdef RENEWAL
- case HT_LANDMINE:
- case MA_LANDMINE:
- case HT_BLASTMINE:
- case HT_CLAYMORETRAP:
- md.damage = skill_lv * sstatus->dex * (3+status_get_lv(src)/100) * (1+sstatus->int_/35);
- md.damage += md.damage * (rnd()%20-10) / 100;
- md.damage += 40 * (sd?pc_checkskill(sd,RA_RESEARCHTRAP):0);
- break;
-#else
- case HT_LANDMINE:
- case MA_LANDMINE:
- md.damage=skill_lv*(sstatus->dex+75)*(100+sstatus->int_)/100;
- break;
- case HT_BLASTMINE:
- md.damage=skill_lv*(sstatus->dex/2+50)*(100+sstatus->int_)/100;
- break;
- case HT_CLAYMORETRAP:
- md.damage=skill_lv*(sstatus->dex/2+75)*(100+sstatus->int_)/100;
- break;
-#endif
- case HT_BLITZBEAT:
- case SN_FALCONASSAULT:
- //Blitz-beat Damage.
- if(!sd || (temp = pc_checkskill(sd,HT_STEELCROW)) <= 0)
- temp=0;
- md.damage=(sstatus->dex/10+sstatus->int_/2+temp*3+40)*2;
- if(mflag > 1) //Autocasted Blitz.
- nk|=NK_SPLASHSPLIT;
-
- if (skill_id == SN_FALCONASSAULT) {
- //Div fix of Blitzbeat
- temp = skill->get_num(HT_BLITZBEAT, 5);
- damage_div_fix(md.damage, temp);
-
- //Falcon Assault Modifier
- md.damage=md.damage*(150+70*skill_lv)/100;
- }
- break;
- case TF_THROWSTONE:
- md.damage=50;
- break;
- case BA_DISSONANCE:
- md.damage=30+skill_lv*10;
- if (sd)
- md.damage+= 3*pc_checkskill(sd,BA_MUSICALLESSON);
- break;
- case NPC_SELFDESTRUCTION:
- md.damage = sstatus->hp;
- break;
- case NPC_SMOKING:
- md.damage=3;
- break;
- case NPC_DARKBREATH:
- md.damage = 500 + (skill_lv-1)*1000 + rnd()%1000;
- if(md.damage > 9999) md.damage = 9999;
- break;
- case PA_PRESSURE:
- md.damage=500+300*skill_lv;
- break;
- case PA_GOSPEL:
- md.damage = 1+rnd()%9999;
- break;
- case CR_ACIDDEMONSTRATION: // updated the formula based on a Japanese formula found to be exact [Reddozen]
- if(tstatus->vit+sstatus->int_) //crash fix
- md.damage = (int)(7*tstatus->vit*sstatus->int_*sstatus->int_ / (10*(tstatus->vit+sstatus->int_)));
- else
- md.damage = 0;
- if (tsd) md.damage>>=1;
- if (md.damage < 0 || md.damage > INT_MAX>>1)
- //Overflow prevention, will anyone whine if I cap it to a few billion?
- //Not capped to INT_MAX to give some room for further damage increase.
- md.damage = INT_MAX>>1;
- break;
- case NJ_ZENYNAGE:
- case KO_MUCHANAGE:
- md.damage = skill->get_zeny(skill_id ,skill_lv);
- if (!md.damage) md.damage = 2;
- md.damage = rand()%md.damage + md.damage / (skill_id==NJ_ZENYNAGE?1:2) ;
- if (is_boss(target))
- md.damage=md.damage / (skill_id==NJ_ZENYNAGE?3:2);
- else if (tsd) // need confirmation for KO_MUCHANAGE
- md.damage=md.damage/2;
- break;
- case GS_FLING:
- md.damage = sd?sd->status.job_level:status_get_lv(src);
- break;
- case HVAN_EXPLOSION: //[orn]
- md.damage = sstatus->max_hp * (50 + 50 * skill_lv) / 100;
- break ;
- case ASC_BREAKER:
- md.damage = 500+rnd()%500 + 5*skill_lv * sstatus->int_;
- nk|=NK_IGNORE_FLEE|NK_NO_ELEFIX; //These two are not properties of the weapon based part.
- break;
- case HW_GRAVITATION:
- md.damage = 200+200*skill_lv;
- md.dmotion = 0; //No flinch animation.
- break;
- case NPC_EVILLAND:
- md.damage = skill->calc_heal(src,target,skill_id,skill_lv,false);
- break;
- case RK_DRAGONBREATH:
- md.damage = ((status_get_hp(src) / 50) + (status_get_max_sp(src) / 4)) * skill_lv;
- RE_LVL_MDMOD(150);
- if (sd) md.damage = md.damage * (100 + 5 * (pc_checkskill(sd,RK_DRAGONTRAINING) - 1)) / 100;
- md.flag |= BF_LONG|BF_WEAPON;
- break;
- /**
- * Ranger
- **/
- case RA_CLUSTERBOMB:
- case RA_FIRINGTRAP:
- case RA_ICEBOUNDTRAP:
- md.damage = skill_lv * sstatus->dex + sstatus->int_ * 5 ;
- RE_LVL_TMDMOD();
- if(sd)
- {
- int researchskill_lv = pc_checkskill(sd,RA_RESEARCHTRAP);
- if(researchskill_lv)
- md.damage = md.damage * 20 * researchskill_lv / (skill_id == RA_CLUSTERBOMB?50:100);
- else
- md.damage = 0;
- }else
- md.damage = md.damage * 200 / (skill_id == RA_CLUSTERBOMB?50:100);
-
- break;
- /**
- * Mechanic
- **/
- case NC_SELFDESTRUCTION:
- {
- short totaldef = tstatus->def2 + (short)status_get_def(target);
- md.damage = ( (sd?pc_checkskill(sd,NC_MAINFRAME):10) + 8 ) * ( skill_lv + 1 ) * ( status_get_sp(src) + sstatus->vit );
- RE_LVL_MDMOD(100);
- md.damage += status_get_hp(src) - totaldef;
- }
- break;
- case GN_THORNS_TRAP:
- md.damage = 100 + 200 * skill_lv + sstatus->int_;
- break;
- case GN_HELLS_PLANT_ATK:
- //[{( Hell Plant Skill Level x Casters Base Level ) x 10 } + {( Casters INT x 7 ) / 2 } x { 18 + ( Casters Job Level / 4 )] x ( 5 / ( 10 - Summon Flora Skill Level ))
- md.damage = ( skill_lv * status_get_lv(src) * 10 ) + ( sstatus->int_ * 7 / 2 ) * ( 18 + (sd?sd->status.job_level:0) / 4 ) * ( 5 / (10 - (sd?pc_checkskill(sd,AM_CANNIBALIZE):0)) );
- break;
- case KO_HAPPOKUNAI:
- {
- struct Damage wd = battle->calc_weapon_attack(src,target,skill_id,skill_lv,mflag);
- short totaldef = tstatus->def2 + (short)status_get_def(target);
- md.damage = wd.damage * 60 * (5 + skill_lv) / 100;
- md.damage -= totaldef;
- }
- break;
- case KO_MAKIBISHI:
- md.damage = 20 * skill_lv;
- break;
- }
-
- if (nk&NK_SPLASHSPLIT){ // Divide ATK among targets
- if(mflag>0)
- md.damage/= mflag;
- else
- ShowError("0 enemies targeted by %d:%s, divide per 0 avoided!\n", skill_id, skill->get_name(skill_id));
- }
-
- damage_div_fix(md.damage, md.div_);
-
- if (!(nk&NK_IGNORE_FLEE))
- {
- struct status_change *sc = status_get_sc(target);
- i = 0; //Temp for "hit or no hit"
- if(sc && sc->opt1 && sc->opt1 != OPT1_STONEWAIT && sc->opt1 != OPT1_BURNING)
- i = 1;
- else {
- short
- flee = tstatus->flee,
-#ifdef RENEWAL
- hitrate = 0; //Default hitrate
-#else
- hitrate = 80; //Default hitrate
-#endif
-
- if(battle_config.agi_penalty_type && battle_config.agi_penalty_target&target->type) {
- unsigned char attacker_count; //256 max targets should be a sane max
- attacker_count = unit_counttargeted(target);
- if(attacker_count >= battle_config.agi_penalty_count)
- {
- if (battle_config.agi_penalty_type == 1)
- flee = (flee * (100 - (attacker_count - (battle_config.agi_penalty_count - 1))*battle_config.agi_penalty_num))/100;
- else //asume type 2: absolute reduction
- flee -= (attacker_count - (battle_config.agi_penalty_count - 1))*battle_config.agi_penalty_num;
- if(flee < 1) flee = 1;
- }
- }
-
- hitrate+= sstatus->hit - flee;
-#ifdef RENEWAL
- if( sd ) //in Renewal hit bonus from Vultures Eye is not anymore shown in status window
- hitrate += pc_checkskill(sd,AC_VULTURE);
-#endif
- hitrate = cap_value(hitrate, battle_config.min_hitrate, battle_config.max_hitrate);
-
- if(rnd()%100 < hitrate)
- i = 1;
- }
- if (!i) {
- md.damage = 0;
- md.dmg_lv=ATK_FLEE;
- }
- }
-#ifndef HMAP_ZONE_DAMAGE_CAP_TYPE
- if( target && skill_id ) {
- for(i = 0; i < map[target->m].zone->capped_skills_count; i++) {
- if( skill_id == map[target->m].zone->capped_skills[i]->nameid && (map[target->m].zone->capped_skills[i]->type & target->type) ) {
- if( target->type == BL_MOB && map[target->m].zone->capped_skills[i]->subtype != MZS_NONE ) {
- if( (((TBL_MOB*)target)->status.mode&MD_BOSS) && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_BOSS) )
- continue;
- if( ((TBL_MOB*)target)->special_state.clone && !(map[target->m].zone->disabled_skills[i]->subtype&MZS_CLONE) )
- continue;
- }
- if( md.damage > map[target->m].zone->capped_skills[i]->cap )
- md.damage = map[target->m].zone->capped_skills[i]->cap;
- if( md.damage2 > map[target->m].zone->capped_skills[i]->cap )
- md.damage2 = map[target->m].zone->capped_skills[i]->cap;
- break;
- }
- }
- }
-#endif
- md.damage = battle->calc_cardfix(BF_MISC, src, target, nk, s_ele, 0, md.damage, 0, md.flag);
-
- if (sd && (i = pc_skillatk_bonus(sd, skill_id)))
- md.damage += md.damage*i/100;
-
- if( (i = battle->adjust_skill_damage(src->m,skill_id)) )
- md.damage = md.damage * i / 100;
-
- if(md.damage < 0)
- md.damage = 0;
- else if(md.damage && tstatus->mode&MD_PLANT){
- switch(skill_id){
- case HT_LANDMINE:
- case MA_LANDMINE:
- case HT_BLASTMINE:
- case HT_CLAYMORETRAP:
- case RA_CLUSTERBOMB:
-#ifdef RENEWAL
- break;
-#endif
- default:
- md.damage = 1;
- }
- }else if( target->type == BL_SKILL ){
- TBL_SKILL *su = (TBL_SKILL*)target;
- if( su->group && (su->group->skill_id == WM_REVERBERATION || su->group->skill_id == WM_POEMOFNETHERWORLD) )
- md.damage = 1;
- }
-
- if(!(nk&NK_NO_ELEFIX))
- md.damage=battle->attr_fix(src, target, md.damage, s_ele, tstatus->def_ele, tstatus->ele_lv);
-
- md.damage=battle->calc_damage(src,target,&md,md.damage,skill_id,skill_lv);
- if( map_flag_gvg2(target->m) )
- md.damage=battle->calc_gvg_damage(src,target,md.damage,md.div_,skill_id,skill_lv,md.flag);
- else if( map[target->m].flag.battleground )
- md.damage=battle->calc_bg_damage(src,target,md.damage,md.div_,skill_id,skill_lv,md.flag);
-
- switch( skill_id ) {
- case RA_FIRINGTRAP:
- case RA_ICEBOUNDTRAP:
- if( md.damage == 1 ) break;
- case RA_CLUSTERBOMB:
- {
- struct Damage wd;
- wd = battle->calc_weapon_attack(src,target,skill_id,skill_lv,mflag);
- md.damage += wd.damage;
- }
- break;
- case NJ_ZENYNAGE:
- if( sd ) {
- if ( md.damage > sd->status.zeny )
- md.damage = sd->status.zeny;
- pc_payzeny(sd, md.damage,LOG_TYPE_STEAL,NULL);
- }
- break;
- }
-
- return md;
-}
-/*==========================================
* Battle main entry, from skill->attack
*------------------------------------------*/
struct Damage battle_calc_attack(int attack_type,struct block_list *bl,struct block_list *target,uint16 skill_id,uint16 skill_lv,int count)
@@ -4615,66 +5098,80 @@ struct Damage battle_calc_attack(int attack_type,struct block_list *bl,struct bl
}
//Calculates BF_WEAPON returned damage.
-int battle_calc_return_damage(struct block_list* bl, struct block_list *src, int *dmg, int flag, uint16 skill_id){
+int battle_calc_return_damage(struct block_list* bl, struct block_list *src, int *dmg, int flag, uint16 skill_id, int *delay){
+ int rdamage = 0, damage = *dmg, rdelay = *delay, trdamage = 0;
struct map_session_data* sd;
- int rdamage = 0, damage = *dmg;
struct status_change* sc;
+ int max_reflect_damage;
sd = BL_CAST(BL_PC, bl);
sc = status_get_sc(bl);
+ max_reflect_damage = max(status_get_max_hp(bl), status_get_max_hp(bl) * status_get_lv(bl) / 100);
- if( sc && sc->data[SC_REFLECTDAMAGE] ) {
- int max_damage = status_get_max_hp(bl) * status_get_lv(bl) / 100;
- rdamage = (*dmg) * sc->data[SC_REFLECTDAMAGE]->val2 / 100;
- if( rdamage > max_damage ) rdamage = max_damage;
- }else if( sc && sc->data[SC_CRESCENTELBOW] && !is_boss(src) && rnd()%100 < sc->data[SC_CRESCENTELBOW]->val2 ){
+#define NORMALIZE_RDAMAGE(d){ trdamage += rdamage = max(1, min(max_reflect_damage, d)); }
+
+ if( sc && sc->data[SC_CRESCENTELBOW] && !is_boss(src) && rnd()%100 < sc->data[SC_CRESCENTELBOW]->val2 ){
//ATK [{(Target HP / 100) x Skill Level} x Caster Base Level / 125] % + [Received damage x {1 + (Skill Level x 0.2)}]
int ratio = (status_get_hp(src) / 100) * sc->data[SC_CRESCENTELBOW]->val1 * status_get_lv(bl) / 125;
if (ratio > 5000) ratio = 5000; // Maximum of 5000% ATK
rdamage = rdamage * ratio / 100 + (*dmg) * (10 + sc->data[SC_CRESCENTELBOW]->val1 * 20 / 10) / 10;
skill->blown(bl, src, skill->get_blewcount(SR_CRESCENTELBOW_AUTOSPELL, sc->data[SC_CRESCENTELBOW]->val1), unit_getdir(src), 0);
- clif->skill_damage(bl, src, gettick(), status_get_amotion(src), 0, rdamage,
+ clif->skill_damage(bl, src, iTimer->gettick(), status_get_amotion(src), 0, rdamage,
1, SR_CRESCENTELBOW_AUTOSPELL, sc->data[SC_CRESCENTELBOW]->val1, 6); // This is how official does
- clif->damage(src, bl, gettick(), status_get_amotion(src)+1000, 0, rdamage/10, 1, 0, 0);
+ clif->damage(src, bl, iTimer->gettick(), status_get_amotion(src)+1000, 0, rdamage/10, 1, 0, 0);
status_damage(src, bl, status_damage(bl, src, rdamage, 0, 0, 1)/10, 0, 0, 1);
status_change_end(bl, SC_CRESCENTELBOW, INVALID_TIMER);
return 0; // Just put here to minimize redundancy
- }else if (flag & BF_SHORT) {//Bounces back part of the damage.
- if ( sd && sd->bonus.short_weapon_damage_return ) {
- rdamage += damage * sd->bonus.short_weapon_damage_return / 100;
- if(rdamage < 1) rdamage = 1;
+ }
+ if( flag & BF_SHORT) {//Bounces back part of the damage.
+ if ( sd && sd->bonus.short_weapon_damage_return ){
+ NORMALIZE_RDAMAGE(damage * sd->bonus.short_weapon_damage_return / 100);
+ rdelay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0);
}
if( sc && sc->count ) {
- if ( sc->data[SC_REFLECTSHIELD] && skill_id != WS_CARTTERMINATION ) {
- rdamage += damage * sc->data[SC_REFLECTSHIELD]->val2 / 100;
- if (rdamage < 1) rdamage = 1;
+ if( sc->data[SC_REFLECTSHIELD] && skill_id != WS_CARTTERMINATION ){
+ NORMALIZE_RDAMAGE(damage * sc->data[SC_REFLECTSHIELD]->val2 / 100);
+ rdelay = clif->skill_damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, CR_REFLECTSHIELD, 1, 4);
+ }
+ if( sc->data[SC_LG_REFLECTDAMAGE] && rand()%100 < (30 + 10*sc->data[SC_LG_REFLECTDAMAGE]->val1) ) {
+ if( skill_id != HT_LANDMINE && skill_id != HT_CLAYMORETRAP
+ && skill_id != RA_CLUSTERBOMB && (skill_id <= RA_VERDURETRAP || skill_id > RA_ICEBOUNDTRAP) && skill_id != MA_LANDMINE ){
+ NORMALIZE_RDAMAGE((*dmg) * sc->data[SC_LG_REFLECTDAMAGE]->val2 / 100);
+ rdelay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0);
+ }
}
- if(sc->data[SC_DEATHBOUND] && skill_id != WS_CARTTERMINATION && !(src->type == BL_MOB && is_boss(src)) ) {
- uint8 dir = map_calc_dir(bl,src->x,src->y),
- t_dir = unit_getdir(bl);
-
- if( distance_bl(src,bl) <= 0 || !map_check_dir(dir,t_dir) ) {
- int rd1 = 0;
- rd1 = min(damage,status_get_max_hp(bl)) * sc->data[SC_DEATHBOUND]->val2 / 100; // Amplify damage.
- *dmg = rd1 * 30 / 100; // Received damage = 30% of amplifly damage.
- clif->skill_damage(src,bl,gettick(), status_get_amotion(src), 0, -30000, 1, RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1,6);
- status_change_end(bl,SC_DEATHBOUND,INVALID_TIMER);
- rdamage += rd1;
- if (rdamage < 1) rdamage = 1;
+ if( sc->data[SC_DEATHBOUND] && skill_id != WS_CARTTERMINATION && !is_boss(src) ) {
+ uint8 dir = iMap->calc_dir(bl,src->x,src->y),
+ t_dir = unit_getdir(bl);
+
+ if( !iMap->check_dir(dir,t_dir) ) {
+ int rd1 = damage * sc->data[SC_DEATHBOUND]->val2 / 100; // Amplify damage.
+ trdamage += rdamage = rd1 - (*dmg = rd1 * 30 / 100); // not normalized as intended.
+ clif->skill_damage(src, bl, iTimer->gettick(), status_get_amotion(src), 0, -3000, 1, RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1, 6);
+ skill->blown(bl, src, skill->get_blewcount(RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1), unit_getdir(src), 0);
+ if( skill_id )
+ status_change_end(bl, SC_DEATHBOUND, INVALID_TIMER);
+ rdelay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0);
}
}
+ if( sc->data[SC_SHIELDSPELL_DEF] && sc->data[SC_SHIELDSPELL_DEF]->val1 == 2 && !is_boss(src) ){
+ NORMALIZE_RDAMAGE(damage * sc->data[SC_SHIELDSPELL_DEF]->val2 / 100);
+ rdelay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0);
+ }
}
} else {
- if (sd && sd->bonus.long_weapon_damage_return) {
- rdamage += damage * sd->bonus.long_weapon_damage_return / 100;
- if (rdamage < 1) rdamage = 1;
+ if (sd && sd->bonus.long_weapon_damage_return){
+ NORMALIZE_RDAMAGE(damage * sd->bonus.long_weapon_damage_return / 100);
+ rdelay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0);
}
}
+
+ if( !(sc && sc->data[SC_DEATHBOUND]) ){
+ if( sc && sc->data[SC_KYOMU] ) // Nullify reflecting ability
+ return 0;
+ }
- if( sc && sc->data[SC_KYOMU] ) // Nullify reflecting ability
- rdamage = 0;
-
- return rdamage;
+ return max(0, trdamage);
}
void battle_drain(TBL_PC *sd, struct block_list *tbl, int rdamage, int ldamage, int race, int boss)
@@ -4743,7 +5240,7 @@ int battle_damage_area( struct block_list *bl, va_list ap) {
if( bl->type == BL_MOB && ((TBL_MOB*)bl)->class_ == MOBID_EMPERIUM )
return 0;
if( bl != src && battle->check_target(src,bl,BCT_ENEMY) > 0 ) {
- map_freeblock_lock();
+ iMap->freeblock_lock();
if( src->type == BL_PC )
battle->drain((TBL_PC*)src, bl, damage, damage, status_get_race(bl), is_boss(bl));
if( amotion )
@@ -4753,7 +5250,7 @@ int battle_damage_area( struct block_list *bl, va_list ap) {
clif->damage(bl,bl,tick,amotion,dmotion,damage,1,ATK_BLOCK,0);
if( !(src && src->type == BL_PC && ((TBL_PC*)src)->state.autocast) )
skill->additional_effect(src, bl, CR_REFLECTSHIELD, 1, BF_WEAPON|BF_SHORT|BF_NORMAL,ATK_DEF,tick);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
}
return 0;
@@ -4765,7 +5262,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
struct map_session_data *sd = NULL, *tsd = NULL;
struct status_data *sstatus, *tstatus;
struct status_change *sc, *tsc;
- int damage,rdamage=0,rdelay=0;
+ int damage;
int skillv;
struct Damage wd;
@@ -4834,10 +5331,10 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
}
if( tsc && tsc->data[SC_AUTOCOUNTER] && status_check_skilluse(target, src, KN_AUTOCOUNTER, 1) )
{
- uint8 dir = map_calc_dir(target,src->x,src->y);
+ uint8 dir = iMap->calc_dir(target,src->x,src->y);
int t_dir = unit_getdir(target);
int dist = distance_bl(src, target);
- if(dist <= 0 || (!map_check_dir(dir,t_dir) && dist <= tstatus->rhw.range+1))
+ if(dist <= 0 || (!iMap->check_dir(dir,t_dir) && dist <= tstatus->rhw.range+1))
{
uint16 skill_lv = tsc->data[SC_AUTOCOUNTER]->val1;
clif->skillcastcancel(target); //Remove the casting bar. [Skotlex]
@@ -4853,7 +5350,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
uint16 skill_lv = tsc->data[SC_BLADESTOP_WAIT]->val1;
int duration = skill->get_time2(MO_BLADESTOP,skill_lv);
status_change_end(target, SC_BLADESTOP_WAIT, INVALID_TIMER);
- if(sc_start4(src, SC_BLADESTOP, 100, sd?pc_checkskill(sd, MO_BLADESTOP):5, 0, 0, target->id, duration))
+ if(sc_start4(src, SC_BLADESTOP, 100, sd?pc->checkskill(sd, MO_BLADESTOP):5, 0, 0, target->id, duration))
{ //Target locked.
clif->damage(src, target, tick, sstatus->amotion, 1, 0, 1, 0, 0); //Display MISS.
clif->bladestop(target, src->id, 1);
@@ -4862,7 +5359,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
}
}
- if(sd && (skillv = pc_checkskill(sd,MO_TRIPLEATTACK)) > 0) {
+ if(sd && (skillv = pc->checkskill(sd,MO_TRIPLEATTACK)) > 0) {
int triple_rate= 30 - skillv; //Base Rate
if (sc && sc->data[SC_SKILLRATE_UP] && sc->data[SC_SKILLRATE_UP]->val1 == MO_TRIPLEATTACK) {
triple_rate+= triple_rate*(sc->data[SC_SKILLRATE_UP]->val2)/100;
@@ -4899,17 +5396,17 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
return ATK_DEF;
return ATK_MISS;
}
- if( sc->data[SC_GT_ENERGYGAIN] ) {
- if( sd && rnd()%100 < 10 + 5 * sc->data[SC_GT_ENERGYGAIN]->val1)
- pc_addspiritball(sd,
- skill->get_time(MO_CALLSPIRITS, sc->data[SC_GT_ENERGYGAIN]->val1),
- sc->data[SC_GT_ENERGYGAIN]->val1);
+ if( sc->data[SC_GENTLETOUCH_ENERGYGAIN] ) {
+ if( sd && rnd()%100 < 10 + 5 * sc->data[SC_GENTLETOUCH_ENERGYGAIN]->val1)
+ pc->addspiritball(sd,
+ skill->get_time(MO_CALLSPIRITS, sc->data[SC_GENTLETOUCH_ENERGYGAIN]->val1),
+ sc->data[SC_GENTLETOUCH_ENERGYGAIN]->val1);
}
- if( tsc && tsc->data[SC_GT_ENERGYGAIN] ) {
- if( tsd && rnd()%100 < 10 + 5 * tsc->data[SC_GT_ENERGYGAIN]->val1)
- pc_addspiritball(tsd,
- skill->get_time(MO_CALLSPIRITS, tsc->data[SC_GT_ENERGYGAIN]->val1),
- tsc->data[SC_GT_ENERGYGAIN]->val1);
+ if( tsc && tsc->data[SC_GENTLETOUCH_ENERGYGAIN] ) {
+ if( tsd && rnd()%100 < 10 + 5 * tsc->data[SC_GENTLETOUCH_ENERGYGAIN]->val1)
+ pc->addspiritball(tsd,
+ skill->get_time(MO_CALLSPIRITS, tsc->data[SC_GENTLETOUCH_ENERGYGAIN]->val1),
+ tsc->data[SC_GENTLETOUCH_ENERGYGAIN]->val1);
}
if( sc && sc->data[SC_CRUSHSTRIKE] ){
uint16 skill_lv = sc->data[SC_CRUSHSTRIKE]->val1;
@@ -4921,7 +5418,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
}
if(tsc && tsc->data[SC_KAAHI] && tsc->data[SC_KAAHI]->val4 == INVALID_TIMER && tstatus->hp < tstatus->max_hp)
- tsc->data[SC_KAAHI]->val4 = add_timer(tick + skill->get_time2(SL_KAAHI,tsc->data[SC_KAAHI]->val1), kaahi_heal_timer, target->id, SC_KAAHI); //Activate heal.
+ tsc->data[SC_KAAHI]->val4 = iTimer->add_timer(tick + skill->get_time2(SL_KAAHI,tsc->data[SC_KAAHI]->val1), kaahi_heal_timer, target->id, SC_KAAHI); //Activate heal.
wd = battle->calc_attack(BF_WEAPON, src, target, 0, 0, flag);
@@ -4941,7 +5438,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
wd.damage *= 3; // Triple Damage
if( sd && sc->data[SC_FEARBREEZE] && sc->data[SC_FEARBREEZE]->val4 > 0 && sd->status.inventory[sd->equip_index[EQI_AMMO]].amount >= sc->data[SC_FEARBREEZE]->val4 && battle_config.arrow_decrement){
- pc_delitem(sd,sd->equip_index[EQI_AMMO],sc->data[SC_FEARBREEZE]->val4,0,1,LOG_TYPE_CONSUME);
+ pc->delitem(sd,sd->equip_index[EQI_AMMO],sc->data[SC_FEARBREEZE]->val4,0,1,LOG_TYPE_CONSUME);
sc->data[SC_FEARBREEZE]->val4 = 0;
}
}
@@ -4959,19 +5456,6 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
skill_id = AB_DUPLELIGHT_MAGIC;
skill->attack(skill->get_type(skill_id), src, src, target, skill_id, sc->data[SC_DUPLELIGHT]->val1, tick, SD_LEVEL);
}
-
- rdamage = battle->calc_return_damage(target,src, &damage, wd.flag, 0);
- if( rdamage > 0 ) {
- if( tsc && tsc->data[SC_REFLECTDAMAGE] ) {
- if( src != target ) {// Don't reflect your own damage (Grand Cross)
- map_foreachinshootrange(battle->damage_area,target,skill->get_splash(LG_REFLECTDAMAGE,1),BL_CHAR,tick,target,wd.amotion,wd.dmotion,rdamage,tstatus->race);
- }
- } else {
- rdelay = clif->damage(src, src, tick, wd.amotion, sstatus->dmotion, rdamage, 1, 4, 0);
- //Use Reflect Shield to signal this kind of skill trigger. [Skotlex]
- skill->additional_effect(target,src,CR_REFLECTSHIELD,1,BF_WEAPON|BF_SHORT|BF_NORMAL,ATK_DEF,tick);
- }
- }
}
wd.dmotion = clif->damage(src, target, tick, wd.amotion, wd.dmotion, wd.damage, wd.div_ , wd.type, wd.damage2);
@@ -4983,20 +5467,20 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
if( su->group && su->group->skill_id == HT_BLASTMINE)
skill->blown(src, target, 3, -1, 0);
}
- map_freeblock_lock();
+ iMap->freeblock_lock();
battle->delay_damage(tick, wd.amotion, src, target, wd.flag, 0, 0, damage, wd.dmg_lv, wd.dmotion, true);
if( tsc ) {
if( tsc->data[SC_DEVOTION] ) {
struct status_change_entry *sce = tsc->data[SC_DEVOTION];
- struct block_list *d_bl = map_id2bl(sce->val1);
+ struct block_list *d_bl = iMap->id2bl(sce->val1);
if( d_bl && (
(d_bl->type == BL_MER && ((TBL_MER*)d_bl)->master && ((TBL_MER*)d_bl)->master->bl.id == target->id) ||
(d_bl->type == BL_PC && ((TBL_PC*)d_bl)->devotion[sce->val2] == target->id)
) && check_distance_bl(target, d_bl, sce->val3) )
{
- clif->damage(d_bl, d_bl, gettick(), 0, 0, damage, 0, 0, 0);
+ clif->damage(d_bl, d_bl, iTimer->gettick(), 0, 0, damage, 0, 0, 0);
status_fix_damage(NULL, d_bl, damage, 0);
}
else
@@ -5008,13 +5492,13 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
skill->attack(BF_MAGIC,&ed->bl,&ed->bl,src,EL_CIRCLE_OF_FIRE,tsc->data[SC_CIRCLE_OF_FIRE_OPTION]->val1,tick,wd.flag);
}
} else if( tsc->data[SC_WATER_SCREEN_OPTION] && tsc->data[SC_WATER_SCREEN_OPTION]->val1 ) {
- struct block_list *e_bl = map_id2bl(tsc->data[SC_WATER_SCREEN_OPTION]->val1);
+ struct block_list *e_bl = iMap->id2bl(tsc->data[SC_WATER_SCREEN_OPTION]->val1);
if( e_bl && !status_isdead(e_bl) ) {
clif->damage(e_bl,e_bl,tick,wd.amotion,wd.dmotion,damage,wd.div_,wd.type,wd.damage2);
status_damage(target,e_bl,damage,0,0,0);
// Just show damage in target.
clif->damage(src, target, tick, wd.amotion, wd.dmotion, damage, wd.div_, wd.type, wd.damage2 );
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return ATK_NONE;
}
}
@@ -5024,7 +5508,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
uint16 skill_id = sc->data[SC_AUTOSPELL]->val2;
uint16 skill_lv = sc->data[SC_AUTOSPELL]->val3;
int i = rnd()%100;
- if (sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_SAGE)
+ if (sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_SAGE)
i = 0; //Max chance, no skill_lv reduction. [Skotlex]
if (i >= 50) skill_lv -= 2;
else if (i >= 15) skill_lv--;
@@ -5079,7 +5563,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
if( type != CAST_GROUND ){
clif->skill_fail(sd,r_skill,USESKILL_FAIL_LEVEL,0);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return wd.dmg_lv;
}
}
@@ -5100,7 +5584,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
sd->state.autocast = 0;
sd->ud.canact_tick = tick + skill->delay_fix(src, r_skill, r_lv);
- clif->status_change(src, SI_ACTIONDELAY, 1, skill->delay_fix(src, r_skill, r_lv), 0, 0, 1);
+ clif->status_change(src, SI_POSTDELAY, 1, skill->delay_fix(src, r_skill, r_lv), 0, 0, 1);
}
}
@@ -5111,11 +5595,6 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
battle->drain(sd, target, wd.damage, wd.damage2, tstatus->race, is_boss(target));
}
}
- if (rdamage > 0 && !(tsc && tsc->data[SC_REFLECTDAMAGE])) { //By sending attack type "none" skill->additional_effect won't be invoked. [Skotlex]
- if(tsd && src != target)
- battle->drain(tsd, src, rdamage, rdamage, sstatus->race, is_boss(src));
- battle->delay_damage(tick, wd.amotion, target, src, 0, CR_REFLECTSHIELD, 0, rdamage, ATK_DEF, rdelay, true);
- }
if (tsc) {
if (tsc->data[SC_POISONREACT] &&
@@ -5136,7 +5615,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
status_change_end(target, SC_POISONREACT, INVALID_TIMER);
}
}
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return wd.dmg_lv;
}
@@ -5170,7 +5649,7 @@ struct block_list* battle_get_master(struct block_list *src)
break;
case BL_MOB:
if (((TBL_MOB*)src)->master_id)
- src = map_id2bl(((TBL_MOB*)src)->master_id);
+ src = iMap->id2bl(((TBL_MOB*)src)->master_id);
break;
case BL_HOM:
if (((TBL_HOM*)src)->master)
@@ -5186,7 +5665,7 @@ struct block_list* battle_get_master(struct block_list *src)
break;
case BL_SKILL:
if (((TBL_SKILL*)src)->group && ((TBL_SKILL*)src)->group->src_id)
- src = map_id2bl(((TBL_SKILL*)src)->group->src_id);
+ src = iMap->id2bl(((TBL_SKILL*)src)->group->src_id);
break;
}
} while (src && src != prev);
@@ -5244,7 +5723,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
if (((TBL_PC*)target)->invincible_timer != INVALID_TIMER || pc_isinvisible((TBL_PC*)target))
return -1; //Cannot be targeted yet.
if( sc && sc->count ) {
- if( sc->data[SC_VOICEOFSIREN] && sc->data[SC_VOICEOFSIREN]->val2 == target->id )
+ if( sc->data[SC_SIREN] && sc->data[SC_SIREN]->val2 == target->id )
return -1;
}
}
@@ -5266,6 +5745,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
if( skill->get_inf2(su->group->skill_id)&INF2_TRAP ) { //Only a few skills can target traps...
switch( battle->get_current_skill(src) ) {
case RK_DRAGONBREATH:// it can only hit traps in pvp/gvg maps
+ case RK_DRAGONBREATH_WATER:
if( !map[m].flag.pvp && !map[m].flag.gvg )
break;
case 0://you can hit them without skills
@@ -5349,7 +5829,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
{
struct mob_data *md = BL_CAST(BL_MOB, t_bl);
- if( !((agit_flag || agit2_flag) && map[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id )
+ if( !((iMap->agit_flag || iMap->agit2_flag) && map[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id )
return 0; // Disable guardians/emperiums owned by Guilds on non-woe times.
break;
}
@@ -5412,7 +5892,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
case BL_MOB:
{
struct mob_data *md = BL_CAST(BL_MOB, s_bl);
- if( !((agit_flag || agit2_flag) && map[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id )
+ if( !((iMap->agit_flag || iMap->agit2_flag) && map[m].flag.gvg_castle) && md->guardian_data && md->guardian_data->guild_id )
return 0; // Disable guardians/emperium owned by Guilds on non-woe times.
if( !md->special_state.ai )
@@ -5477,7 +5957,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
{
int s_guild = status_get_guild_id(s_bl);
int t_guild = status_get_guild_id(t_bl);
- if( !(map[m].flag.pvp && map[m].flag.pvp_noguild) && s_guild && t_guild && (s_guild == t_guild || guild->isallied(s_guild, t_guild)) && (!map[m].flag.battleground || sbg_id == tbg_id) )
+ if( !(map[m].flag.pvp && map[m].flag.pvp_noguild) && s_guild && t_guild && (s_guild == t_guild || (!(flag&BCT_SAMEGUILD) && guild->isallied(s_guild, t_guild))) && (!map[m].flag.battleground || sbg_id == tbg_id) )
state |= BCT_GUILD;
else
state |= BCT_ENEMY;
@@ -5510,7 +5990,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
{
int s_guild = status_get_guild_id(s_bl);
int t_guild = status_get_guild_id(t_bl);
- if(s_guild && t_guild && (s_guild == t_guild || guild->isallied(s_guild, t_guild)))
+ if(s_guild && t_guild && (s_guild == t_guild || (!(flag&BCT_SAMEGUILD) && guild->isallied(s_guild, t_guild))))
state |= BCT_GUILD;
}
} //end non pvp/gvg chk rivality
@@ -5820,7 +6300,6 @@ static const struct _battle_data {
{ "mobs_level_up_exp_rate", &battle_config.mobs_level_up_exp_rate, 1, 1, INT_MAX, },
{ "pk_min_level", &battle_config.pk_min_level, 55, 1, INT_MAX, },
{ "skill_steal_max_tries", &battle_config.skill_steal_max_tries, 0, 0, UCHAR_MAX, },
- { "finding_ore_rate", &battle_config.finding_ore_rate, 100, 0, INT_MAX, },
{ "exp_calc_type", &battle_config.exp_calc_type, 0, 0, 1, },
{ "exp_bonus_attacker", &battle_config.exp_bonus_attacker, 25, 0, INT_MAX, },
{ "exp_bonus_max_attacker", &battle_config.exp_bonus_max_attacker, 12, 2, INT_MAX, },
@@ -5839,7 +6318,6 @@ static const struct _battle_data {
{ "ignore_items_gender", &battle_config.ignore_items_gender, 1, 0, 1, },
{ "copyskill_restrict", &battle_config.copyskill_restrict, 2, 0, 2, },
{ "berserk_cancels_buffs", &battle_config.berserk_cancels_buffs, 0, 0, 1, },
- { "debuff_on_logout", &battle_config.debuff_on_logout, 1|2, 0, 1|2, },
{ "monster_ai", &battle_config.mob_ai, 0x000, 0x000, 0x77F, },
{ "hom_setting", &battle_config.hom_setting, 0xFFFF, 0x0000, 0xFFFF, },
{ "dynamic_mobs", &battle_config.dynamic_mobs, 1, 0, 1, },
@@ -5909,7 +6387,7 @@ static const struct _battle_data {
{ "cashshop_show_points", &battle_config.cashshop_show_points, 0, 0, 1, },
{ "mail_show_status", &battle_config.mail_show_status, 0, 0, 2, },
{ "client_limit_unit_lv", &battle_config.client_limit_unit_lv, 0, 0, BL_ALL, },
-// BattleGround Settings
+ // BattleGround Settings
{ "bg_update_interval", &battle_config.bg_update_interval, 1000, 100, INT_MAX, },
{ "bg_flee_penalty", &battle_config.bg_flee_penalty, 20, 0, INT_MAX, },
/**
@@ -5934,6 +6412,7 @@ static const struct _battle_data {
{ "max_walk_path", &battle_config.max_walk_path, 17, 1, MAX_WALKPATH, },
{ "item_enabled_npc", &battle_config.item_enabled_npc, 1, 0, 1, },
{ "gm_ignore_warpable_area", &battle_config.gm_ignore_warpable_area, 0, 2, 100, },
+ { "packet_obfuscation", &battle_config.packet_obfuscation, 1, 0, 3, },
};
#ifndef STATS_OPT_OUT
/**
@@ -6027,7 +6506,7 @@ void Hercules_report(char* date, char *time_c) {
#endif
/* non-define part */
- if( db_use_sqldbs )
+ if( iMap->db_use_sqldbs )
config |= C_SQL_DBS;
if( logs->config.sql_logs )
@@ -6062,7 +6541,7 @@ void Hercules_report(char* date, char *time_c) {
safestrncpy((char*)WBUFP(buf,6 + 12 + 9), timestring, 24);
safestrncpy((char*)WBUFP(buf,6 + 12 + 9 + 24), git[0] != HERC_UNKNOWN_VER ? git : svn[0] != HERC_UNKNOWN_VER ? svn : "Unknown", 41);
- WBUFL(buf,6 + 12 + 9 + 24 + 41) = map_getusers();
+ WBUFL(buf,6 + 12 + 9 + 24 + 41) = iMap->getusers();
WBUFL(buf,6 + 12 + 9 + 24 + 41 + 4) = config;
WBUFL(buf,6 + 12 + 9 + 24 + 41 + 4 + 4) = bd_size;
@@ -6158,7 +6637,7 @@ void battle_adjust_conf(void) {
#ifndef CELL_NOSTACK
if (battle_config.cell_stack_limit != 1)
- ShowWarning("Battle setting 'cell_stack_limit' takes no effect as this server was compiled without Cell Stack Limit support.\n");
+ ShowWarning("Battle setting 'cell_stack_limit' takes no effect as this server was compiled without Cell Stack Limit support (CELL_NOSTACK).\n");
#endif
}
@@ -6206,11 +6685,11 @@ int battle_config_read(const char* cfgName)
void do_init_battle(void) {
delay_damage_ers = ers_new(sizeof(struct delay_damage),"battle.c::delay_damage_ers",ERS_OPT_CLEAR);
- add_timer_func_list(battle_delay_damage_sub, "battle_delay_damage_sub");
+ iTimer->add_timer_func_list(battle_delay_damage_sub, "battle_delay_damage_sub");
#ifndef STATS_OPT_OUT
- add_timer_func_list(Hercules_report_timer, "Hercules_report_timer");
- add_timer_interval(gettick()+30000, Hercules_report_timer, 0, 0, 60000 * 30);
+ iTimer->add_timer_func_list(Hercules_report_timer, "Hercules_report_timer");
+ iTimer->add_timer_interval(iTimer->gettick()+30000, Hercules_report_timer, 0, 0, 60000 * 30);
#endif
}
@@ -6222,8 +6701,12 @@ void do_final_battle(void) {
/* initialize the interface */
void battle_defaults(void) {
battle = &battle_s;
+
+ battle->bc = &battle_config;
+
battle->init = do_init_battle;
battle->final = do_final_battle;
+
battle->calc_attack = battle_calc_attack;
battle->calc_damage = battle_calc_damage;
battle->calc_gvg_damage = battle_calc_gvg_damage;
@@ -6236,9 +6719,17 @@ void battle_defaults(void) {
battle->drain = battle_drain;
battle->calc_return_damage = battle_calc_return_damage;
battle->calc_weapon_attack = battle_calc_weapon_attack;
+#ifdef RENEWAL
+ battle->calc_weapon_damage = battle_calc_weapon_damage;
+#endif
+ battle->calc_defense = battle_calc_defense;
battle->attr_ratio = battle_attr_ratio;
battle->attr_fix = battle_attr_fix;
battle->calc_cardfix = battle_calc_cardfix;
+ battle->calc_elefix = battle_calc_elefix;
+ battle->calc_masteryfix = battle_calc_masteryfix;
+ battle->calc_skillratio = battle_calc_skillratio;
+ battle->calc_sizefix = battle_calc_sizefix;
battle->get_master = battle_get_master;
battle->get_targeted = battle_gettargeted;
battle->get_enemy = battle_getenemy;
diff --git a/src/map/battle.h b/src/map/battle.h
index 9d578d224..2b502beaf 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -55,16 +55,19 @@ typedef enum damage_lv {
} damage_lv;
enum e_battle_check_target { //New definitions [Skotlex]
- BCT_ENEMY = 0x020000,
- BCT_NOENEMY = 0x1d0000, //This should be (~BCT_ENEMY&BCT_ALL)
- BCT_PARTY = 0x040000,
- BCT_NOPARTY = 0x1b0000, //This should be (~BCT_PARTY&BCT_ALL)
- BCT_GUILD = 0x080000,
- BCT_NOGUILD = 0x170000, //This should be (~BCT_GUILD&BCT_ALL)
- BCT_ALL = 0x1f0000,
- BCT_NOONE = 0x000000,
- BCT_SELF = 0x010000,
- BCT_NEUTRAL = 0x100000,
+ BCT_NOONE = 0x000000,
+ BCT_SELF = 0x010000,
+ BCT_ENEMY = 0x020000,
+ BCT_PARTY = 0x040000,
+ BCT_GUILD = 0x080000,
+ BCT_NEUTRAL = 0x100000,
+ BCT_SAMEGUILD = 0x200000, // No Guild Allies
+
+ BCT_NOGUILD = 0x170000, // This should be (~BCT_GUILD&BCT_ALL)
+ BCT_NOPARTY = 0x1b0000, // This should be (~BCT_PARTY&BCT_ALL)
+ BCT_NOENEMY = 0x1d0000, // This should be (~BCT_ENEMY&BCT_ALL)
+
+ BCT_ALL = 0x1f0000, // Sum of BCT_NOONE to BCT_NEUTRAL
};
/**
@@ -322,7 +325,6 @@ struct Battle_Config {
int mobs_level_up_exp_rate; // [Valaris]
int pk_min_level; // [celest]
int skill_steal_max_tries; //max steal skill tries on a mob. if 0, then w/o limit [Lupus]
- int finding_ore_rate; // orn
int exp_calc_type;
int exp_bonus_attacker;
int exp_bonus_max_attacker;
@@ -345,7 +347,6 @@ struct Battle_Config {
int copyskill_restrict; // [Aru]
int berserk_cancels_buffs; // [Aru]
- int debuff_on_logout; // Removes a few "official" negative Scs on logout. [Skotlex]
int mob_ai; //Configures various mob_ai settings to make them smarter or dumber(official). [Skotlex]
int hom_setting; //Configures various homunc settings which make them behave unlike normal characters.. [Skotlex]
int dynamic_mobs; // Dynamic Mobs [Wizputer] - battle.conf flag implemented by [random]
@@ -447,6 +448,7 @@ struct Battle_Config {
int item_restricted_consumption_type;
int max_walk_path;
int item_enabled_npc;
+ int packet_obfuscation;
int gm_ignore_warpable_area;
@@ -463,6 +465,8 @@ extern int attr_fix_table[4][10][10];
* Battle.c Interface
**/
struct battle_interface {
+ /* */
+ struct Battle_Config *bc;
/* init */
void (*init) (void);
/* final */
@@ -484,13 +488,27 @@ struct battle_interface {
/* drain damage */
void (*drain) (struct map_session_data *sd, struct block_list *tbl, int rdamage, int ldamage, int race, int boss);
/* damage return/reflect */
- int (*calc_return_damage) (struct block_list *bl, struct block_list *src, int *, int flag, uint16 skill_id);
+ int (*calc_return_damage) (struct block_list *bl, struct block_list *src, int *, int flag, uint16 skill_id, int*);
/* attribute rate */
int (*attr_ratio) (int atk_elem, int def_type, int def_lv);
/* applies attribute modifiers */
int (*attr_fix) (struct block_list *src, struct block_list *target, int damage, int atk_elem, int def_type, int def_lv);
/* applies card modifiers */
int (*calc_cardfix) (int attack_type, struct block_list *src, struct block_list *target, int nk, int s_ele, int s_ele_, int damage, int left, int flag);
+ /* applies element modifiers */
+ int (*calc_elefix) (struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int damage, int nk, int n_ele, int s_ele, int s_ele_, bool left, int flag);
+ /* applies mastery modifiers */
+ int (*calc_masteryfix) (struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int damage, int div, bool left, bool weapon);
+ /* applies skill modifiers */
+ int (*calc_skillratio) (int attack_type, struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int skillratio, int flag);
+ /* applies size modifiers */
+ int (*calc_sizefix) (struct map_session_data *sd, int damage, int type, int size, bool ignore);
+#ifdef RENEWAL
+ /* get weapon damage */
+ int (*calc_weapon_damage) (struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, struct weapon_atk *watk, int nk, bool n_ele, short s_ele, short s_ele_, int size, int type, int flag, int flag2);
+#endif
+ /* applies defense reductions */
+ int (*calc_defense) (int attack_type, struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int damage, int flag, int pdef);
/* get master (who does this unit respond to?) */
struct block_list *(*get_master) (struct block_list *src);
/* returns a random unit who is targeting this unit */
@@ -516,7 +534,14 @@ struct battle_interface {
int (*blewcount_bonus) (struct map_session_data *sd, uint16 skill_id);
/* skill range criteria */
int (*range_type) (struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv);
- int (*calc_base_damage) (struct status_data *status, struct weapon_atk *wa, struct status_change *sc, unsigned short t_size, struct map_session_data *sd, int flag);
+ int (*calc_base_damage)
+/* temporary until malufett is able to adjust the formula */
+//#ifdef RENEWAL
+#if 0
+ (struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int nk, bool n_ele, short s_ele, short s_ele_, int type, int flag, int flag2);
+#else
+ (struct status_data *status, struct weapon_atk *wa, struct status_change *sc, unsigned short t_size, struct map_session_data *sd, int flag);
+#endif
struct Damage (*calc_misc_attack) (struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int mflag);
struct Damage (*calc_magic_attack) (struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int mflag);
int (*adjust_skill_damage) (int m, unsigned short skill_id);
diff --git a/src/map/battleground.c b/src/map/battleground.c
index 618679406..88cc323bf 100644
--- a/src/map/battleground.c
+++ b/src/map/battleground.c
@@ -9,6 +9,7 @@
#include "../common/showmsg.h"
#include "../common/socket.h"
#include "../common/strlib.h"
+#include "../common/conf.h"
#include "battleground.h"
#include "battle.h"
@@ -16,6 +17,7 @@
#include "map.h"
#include "npc.h"
#include "pc.h"
+#include "party.h"
#include "pet.h"
#include "homunculus.h"
#include "mercenary.h"
@@ -26,14 +28,12 @@
static DBMap* bg_team_db; // int bg_id -> struct battleground_data*
static unsigned int bg_team_counter = 0; // Next bg_id
-struct battleground_data* bg_team_search(int bg_id)
-{ // Search a BG Team using bg_id
+struct battleground_data* bg_team_search(int bg_id) { // Search a BG Team using bg_id
if( !bg_id ) return NULL;
return (struct battleground_data *)idb_get(bg_team_db, bg_id);
}
-struct map_session_data* bg_getavailablesd(struct battleground_data *bg)
-{
+struct map_session_data* bg_getavailablesd(struct battleground_data *bg) {
int i;
nullpo_retr(NULL, bg);
ARR_FIND(0, MAX_BG_MEMBERS, i, bg->members[i].sd != NULL);
@@ -65,7 +65,7 @@ int bg_team_warp(int bg_id, unsigned short mapindex, short x, short y)
struct battleground_data *bg = bg_team_search(bg_id);
if( bg == NULL ) return 0;
for( i = 0; i < MAX_BG_MEMBERS; i++ )
- if( bg->members[i].sd != NULL ) pc_setpos(bg->members[i].sd, mapindex, x, y, CLR_TELEPORT);
+ if( bg->members[i].sd != NULL ) pc->setpos(bg->members[i].sd, mapindex, x, y, CLR_TELEPORT);
return 1;
}
@@ -95,8 +95,7 @@ int bg_team_join(int bg_id, struct map_session_data *sd)
guild->send_dot_remove(sd);
- for( i = 0; i < MAX_BG_MEMBERS; i++ )
- {
+ for( i = 0; i < MAX_BG_MEMBERS; i++ ) {
if( (pl_sd = bg->members[i].sd) != NULL && pl_sd != sd )
clif->hpmeter_single(sd->fd, pl_sd->bl.id, pl_sd->battle_status.hp, pl_sd->battle_status.max_hp);
}
@@ -146,14 +145,13 @@ int bg_member_respawn(struct map_session_data *sd)
return 0;
if( bg->mapindex == 0 )
return 0; // Respawn not handled by Core
- pc_setpos(sd, bg->mapindex, bg->x, bg->y, CLR_OUTSIGHT);
+ pc->setpos(sd, bg->mapindex, bg->x, bg->y, CLR_OUTSIGHT);
status_revive(&sd->bl, 1, 100);
return 1; // Warped
}
-int bg_create(unsigned short mapindex, short rx, short ry, const char *ev, const char *dev)
-{
+int bg_create(unsigned short mapindex, short rx, short ry, const char *ev, const char *dev) {
struct battleground_data *bg;
bg_team_counter++;
@@ -187,7 +185,7 @@ int bg_team_get_id(struct block_list *bl)
{
struct map_session_data *msd;
struct mob_data *md = (TBL_MOB*)bl;
- if( md->special_state.ai && (msd = map_id2sd(md->master_id)) != NULL )
+ if( md->special_state.ai && (msd = iMap->id2sd(md->master_id)) != NULL )
return msd->bg_id;
return md->bg_id;
}
@@ -226,12 +224,10 @@ int bg_send_xy_timer_sub(DBKey key, DBData *data, va_list ap)
struct map_session_data *sd;
int i;
nullpo_ret(bg);
- for( i = 0; i < MAX_BG_MEMBERS; i++ )
- {
+ for( i = 0; i < MAX_BG_MEMBERS; i++ ) {
if( (sd = bg->members[i].sd) == NULL )
continue;
- if( sd->bl.x != bg->members[i].x || sd->bl.y != bg->members[i].y )
- { // xy update
+ if( sd->bl.x != bg->members[i].x || sd->bl.y != bg->members[i].y ) { // xy update
bg->members[i].x = sd->bl.x;
bg->members[i].y = sd->bl.y;
clif->bg_xy(sd);
@@ -240,20 +236,508 @@ int bg_send_xy_timer_sub(DBKey key, DBData *data, va_list ap)
return 0;
}
-int bg_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data)
-{
+int bg_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data) {
bg_team_db->foreach(bg_team_db, bg_send_xy_timer_sub, tick);
return 0;
}
+void bg_config_read(void) {
+ config_t bg_conf;
+ config_setting_t *data = NULL;
+ const char *config_filename = "conf/battlegrounds.conf"; // FIXME hardcoded name
+
+ if (conf_read_file(&bg_conf, config_filename))
+ return;
+
+ data = config_lookup(&bg_conf, "battlegrounds");
+
+ if (data != NULL) {
+ config_setting_t *settings = config_setting_get_elem(data, 0);
+ config_setting_t *arenas;
+ const char *delay_var;
+ int i, arena_count = 0, total = 0, offline = 0;
+
+ if( !config_setting_lookup_string(settings, "global_delay_var", &delay_var) )
+ delay_var = "BG_Delay_Tick";
+
+ safestrncpy(bg->gdelay_var, delay_var, BG_DELAY_VAR_LENGTH);
+
+ config_setting_lookup_int(settings, "maximum_afk_seconds", &bg->mafksec);
+
+ config_setting_lookup_bool(settings, "feature_off", &offline);
+
+ if( offline == 0 )
+ bg->queue_on = true;
+
+ if( (arenas = config_setting_get_member(settings, "arenas")) != NULL ) {
+ arena_count = config_setting_length(arenas);
+ CREATE( bg->arena, struct bg_arena *, arena_count );
+ for(i = 0; i < arena_count; i++) {
+ config_setting_t *arena = config_setting_get_elem(arenas, i);
+ config_setting_t *reward;
+ const char *aName, *aEvent, *aDelayVar;
+ int minLevel = 0, maxLevel = 0;
+ int prizeWin, prizeLoss, prizeDraw;
+ int minPlayers, maxPlayers, minTeamPlayers;
+ int maxDuration;
+ int fillup_duration, pregame_duration;
+
+ bg->arena[i] = NULL;
+
+ if( !config_setting_lookup_string(arena, "name", &aName) ) {
+ ShowError("bg_config_read: failed to find 'name' for arena #%d\n",i);
+ continue;
+ }
+
+ if( !config_setting_lookup_string(arena, "event", &aEvent) ) {
+ ShowError("bg_config_read: failed to find 'event' for arena #%d\n",i);
+ continue;
+ }
+
+ config_setting_lookup_int(arena, "minLevel", &minLevel);
+ config_setting_lookup_int(arena, "maxLevel", &maxLevel);
+
+ if( minLevel < 0 ) {
+ ShowWarning("bg_config_read: invalid %d value for arena '%s' minLevel\n",minLevel,aName);
+ minLevel = 0;
+ }
+ if( maxLevel > MAX_LEVEL ) {
+ ShowWarning("bg_config_read: invalid %d value for arena '%s' maxLevel\n",maxLevel,aName);
+ maxLevel = MAX_LEVEL;
+ }
+
+ if( !(reward = config_setting_get_member(settings, "reward")) ) {
+ ShowError("bg_config_read: failed to find 'reward' for arena '%s'/#%d\n",aName,i);
+ continue;
+ }
+
+ config_setting_lookup_int(reward, "win", &prizeWin);
+ config_setting_lookup_int(reward, "loss", &prizeLoss);
+ config_setting_lookup_int(reward, "draw", &prizeDraw);
+
+ if( prizeWin < 0 ) {
+ ShowWarning("bg_config_read: invalid %d value for arena '%s' reward:win\n",prizeWin,aName);
+ prizeWin = 0;
+ }
+ if( prizeLoss < 0 ) {
+ ShowWarning("bg_config_read: invalid %d value for arena '%s' reward:loss\n",prizeLoss,aName);
+ prizeLoss = 0;
+ }
+ if( prizeDraw < 0 ) {
+ ShowWarning("bg_config_read: invalid %d value for arena '%s' reward:draw\n",prizeDraw,aName);
+ prizeDraw = 0;
+ }
+
+ config_setting_lookup_int(arena, "minPlayers", &minPlayers);
+ config_setting_lookup_int(arena, "maxPlayers", &maxPlayers);
+ config_setting_lookup_int(arena, "minTeamPlayers", &minTeamPlayers);
+
+ if( minPlayers < 0 ) {
+ ShowWarning("bg_config_read: invalid %d value for arena '%s' minPlayers\n",minPlayers,aName);
+ minPlayers = 0;
+ }
+ if( maxPlayers > MAX_BG_MEMBERS * 2 ) {
+ ShowWarning("bg_config_read: invalid %d value for arena '%s' maxPlayers, change #define MAX_BG_MEMBERS\n",maxPlayers,aName);
+ maxPlayers = 0;
+ }
+ if( minTeamPlayers < 0 ) {
+ ShowWarning("bg_config_read: invalid %d value for arena '%s' minTeamPlayers\n",minTeamPlayers,aName);
+ minTeamPlayers = 0;
+ }
+
+ if( !config_setting_lookup_string(arena, "delay_var", &aDelayVar) ) {
+ ShowError("bg_config_read: failed to find 'delay_var' for arena '%s'/#%d\n",aName,i);
+ continue;
+ }
+
+ config_setting_lookup_int(arena, "maxDuration", &maxDuration);
+
+ if( maxDuration < 0 ) {
+ ShowWarning("bg_config_read: invalid %d value for arena '%s' maxDuration\n",maxDuration,aName);
+ maxDuration = 30;
+ }
+
+ config_setting_lookup_int(arena, "fillDuration", &fillup_duration);
+ config_setting_lookup_int(arena, "pGameDuration", &pregame_duration);
+
+ if( fillup_duration < 20 ) {
+ ShowWarning("bg_config_read: invalid %d value for arena '%s' fillDuration, minimum has to be 20, defaulting to 20.\n",fillup_duration,aName);
+ fillup_duration = 20;
+ }
+
+ if( pregame_duration < 20 ) {
+ ShowWarning("bg_config_read: invalid %d value for arena '%s' pGameDuration, minimum has to be 20, defaulting to 20.\n",pregame_duration,aName);
+ pregame_duration = 20;
+ }
+
+
+ CREATE( bg->arena[i], struct bg_arena, 1 );
+
+ bg->arena[i]->id = i;
+ safestrncpy(bg->arena[i]->name, aName, NAME_LENGTH);
+ safestrncpy(bg->arena[i]->npc_event, aEvent, EVENT_NAME_LENGTH);
+ bg->arena[i]->min_level = minLevel;
+ bg->arena[i]->max_level = maxLevel;
+ bg->arena[i]->prize_win = prizeWin;
+ bg->arena[i]->prize_loss = prizeLoss;
+ bg->arena[i]->prize_draw = prizeDraw;
+ bg->arena[i]->min_players = minPlayers;
+ bg->arena[i]->max_players = maxPlayers;
+ bg->arena[i]->min_team_players = minTeamPlayers;
+ safestrncpy(bg->arena[i]->delay_var, aDelayVar, NAME_LENGTH);
+ bg->arena[i]->maxDuration = maxDuration;
+ bg->arena[i]->queue_id = -1;
+ bg->arena[i]->begin_timer = INVALID_TIMER;
+ bg->arena[i]->fillup_timer = INVALID_TIMER;
+ bg->arena[i]->pregame_duration = pregame_duration;
+ bg->arena[i]->fillup_duration = fillup_duration;
+
+ total++;
+ }
+ bg->arenas = arena_count;
+ }
+
+ ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' arenas in '"CL_WHITE"%s"CL_RESET"'.\n", total, config_filename);
+ config_destroy(&bg_conf);
+ }
+}
+struct bg_arena *bg_name2arena (char *name) {
+ int i;
+ for(i = 0; i < bg->arenas; i++) {
+ if( strcmpi(bg->arena[i]->name,name) == 0 )
+ return bg->arena[i];
+ }
+ return NULL;
+}
+int bg_id2pos ( int queue_id, int account_id ) {
+ struct hQueue *queue = script->queue(queue_id);
+ if( queue ) {
+ int i;
+ for(i = 0; i < queue->items; i++ ) {
+ if( queue->item[i] == account_id ) {
+ return i;
+ }
+ }
+ }
+ return 0;
+}
+void bg_queue_ready_ack (struct bg_arena *arena, struct map_session_data *sd, bool response) {
+ if( arena->begin_timer == INVALID_TIMER || !sd->bg_queue.arena || sd->bg_queue.arena != arena ) {
+ bg->queue_pc_cleanup(sd);
+ return;
+ }
+ if( response ) {
+ sd->bg_queue.ready = 1;
+ /* check if all are ready then cancell timer, and start game */
+ } else
+ bg->queue_pc_cleanup(sd);
+}
+void bg_queue_player_cleanup(struct map_session_data *sd) {
+ if ( sd->bg_queue.client_has_bg_data ) {
+ clif->bgqueue_notice_delete(sd,BGQND_CLOSEWINDOW, sd->bg_queue.arena ? sd->bg_queue.arena->id : 0);
+ }
+ script->queue_remove(sd->bg_queue.arena->queue_id,sd->status.account_id);
+ sd->bg_queue.arena = NULL;
+ sd->bg_queue.ready = 0;
+ sd->bg_queue.client_has_bg_data = 0;
+ sd->bg_queue.type = 0;
+}
+void bg_match_over(struct bg_arena *arena, bool canceled) {
+ struct hQueue *queue = &script->hq[arena->queue_id];
+ int i;//, count = 0;
+
+ /* if( !canceled ) <check time/score> */
+
+ for( i = 0; i < queue->items; i++ ) {
+ struct map_session_data * sd = NULL;
+
+ if( ( sd = iMap->id2sd(queue->item[i]) ) ) {
+ bg->queue_pc_cleanup(sd);
+ clif->colormes(sd->fd,COLOR_RED,"BG Match Cancelled: not enough players");
+ }
+ }
-void do_init_battleground(void)
-{
+ bg->arena[i]->begin_timer = INVALID_TIMER;
+ bg->arena[i]->fillup_timer = INVALID_TIMER;
+ /* reset queue */
+}
+void bg_begin(struct bg_arena *arena) {
+ struct hQueue *queue = &script->hq[arena->queue_id];
+ int i, count = 0;
+
+ for( i = 0; i < queue->items; i++ ) {
+ struct map_session_data * sd = NULL;
+
+ if( ( sd = iMap->id2sd(queue->item[i]) ) ) {
+ if( sd->bg_queue.ready == 1 )
+ count++;
+ else
+ bg->queue_pc_cleanup(sd);
+ }
+ }
+
+ if( count < arena->min_players ) {
+ bg_match_over(arena,true);
+ } else {
+ ;
+ /* we split evenly? */
+ /* but if a party of say 10 joins, it cant be split evenly unless by luck there are 10 soloers in the queue besides them */
+ /* not sure how to split T_T needs more info */
+ }
+}
+int bg_begin_timer(int tid, unsigned int tick, int id, intptr_t data) {
+ bg->begin(bg->arena[id]);
+ return 0;
+}
+
+void bg_queue_pregame(struct bg_arena *arena) {
+ struct hQueue *queue = &script->hq[arena->queue_id];
+ int i;
+
+ for( i = 0; i < queue->items; i++ ) {
+ struct map_session_data * sd = NULL;
+
+ if( ( sd = iMap->id2sd(queue->item[i]) ) ) {
+ clif->bgqueue_battlebegins(sd,arena->id,SELF);
+ }
+ }
+ arena->begin_timer = iTimer->add_timer( iTimer->gettick() + (arena->pregame_duration*1000), bg->begin_timer, arena->id, 0 );
+}
+int bg_fillup_timer(int tid, unsigned int tick, int id, intptr_t data) {
+ bg->queue_pregame(bg->arena[id]);
+ return 0;
+}
+
+void bg_queue_check(struct bg_arena *arena) {
+ int count = script->hq[arena->queue_id].items;
+
+ if( count == arena->max_players ) {
+ if( arena->fillup_timer != INVALID_TIMER ) {
+ iTimer->delete_timer(arena->fillup_timer,bg_fillup_timer);
+ arena->fillup_timer = INVALID_TIMER;
+ }
+ bg->queue_pregame(arena);
+ } else if( count >= arena->min_players && arena->fillup_timer == INVALID_TIMER ) {
+ arena->fillup_timer = iTimer->add_timer( iTimer->gettick() + (arena->fillup_duration*1000), bg->fillup_timer, arena->id, 0 );
+ }
+}
+void bg_queue_add(struct map_session_data *sd, struct bg_arena *arena, enum bg_queue_types type) {
+ enum BATTLEGROUNDS_QUEUE_ACK result = bg->can_queue(sd,arena,type);
+ struct hQueue *queue;
+ int i, count = 0;
+
+ if( arena->begin_timer != INVALID_TIMER ) {
+ clif->bgqueue_ack(sd,BGQA_FAIL_QUEUING_FINISHED,arena->id);
+ return;
+ }
+
+ if( result != BGQA_SUCCESS ) {
+ clif->bgqueue_ack(sd,result,arena->id);
+ return;
+ }
+
+ switch( type ) { /* guild/party already validated in can_queue */
+ case BGQT_PARTY: {
+ struct party_data *p = party->search(sd->status.party_id);
+ for( i = 0; i < MAX_PARTY; i++ ) {
+ if( !p->data[i].sd || p->data[i].sd->bg_queue.arena != NULL ) continue;
+ count++;
+ }
+ }
+ break;
+ case BGQT_GUILD:
+ for ( i=0; i<sd->guild->max_member; i++ ) {
+ if ( !sd->guild->member[i].sd || sd->guild->member[i].sd->bg_queue.arena != NULL )
+ continue;
+ count++;
+ }
+ break;
+ case BGQT_INDIVIDUAL:
+ count = 1;
+ break;
+ }
+
+ if( !(queue = script->queue(arena->queue_id)) || (queue->items+count) >= arena->max_players ) {
+ clif->bgqueue_ack(sd,BGQA_FAIL_PPL_OVERAMOUNT,arena->id);
+ return;
+ }
+
+ switch( type ) {
+ case BGQT_INDIVIDUAL:
+ sd->bg_queue.type = type;
+ sd->bg_queue.arena = arena;
+ sd->bg_queue.ready = 0;
+ script->queue_add(arena->queue_id,sd->status.account_id);
+ clif->bgqueue_joined(sd,script->hq[arena->queue_id].items);
+ clif->bgqueue_update_info(sd,arena->id,script->hq[arena->queue_id].items);
+ break;
+ case BGQT_PARTY: {
+ struct party_data *p = party->search(sd->status.party_id);
+ for( i = 0; i < MAX_PARTY; i++ ) {
+ if( !p->data[i].sd || p->data[i].sd->bg_queue.arena != NULL ) continue;
+ p->data[i].sd->bg_queue.type = type;
+ p->data[i].sd->bg_queue.arena = arena;
+ p->data[i].sd->bg_queue.ready = 0;
+ script->queue_add(arena->queue_id,p->data[i].sd->status.account_id);
+ clif->bgqueue_joined(p->data[i].sd,script->hq[arena->queue_id].items);
+ clif->bgqueue_update_info(p->data[i].sd,arena->id,script->hq[arena->queue_id].items);
+ }
+ }
+ break;
+ case BGQT_GUILD:
+ for ( i=0; i<sd->guild->max_member; i++ ) {
+ if ( !sd->guild->member[i].sd || sd->guild->member[i].sd->bg_queue.arena != NULL )
+ continue;
+ sd->guild->member[i].sd->bg_queue.type = type;
+ sd->guild->member[i].sd->bg_queue.arena = arena;
+ sd->guild->member[i].sd->bg_queue.ready = 0;
+ script->queue_add(arena->queue_id,sd->guild->member[i].sd->status.account_id);
+ clif->bgqueue_joined(sd->guild->member[i].sd,script->hq[arena->queue_id].items);
+ clif->bgqueue_update_info(sd->guild->member[i].sd,arena->id,script->hq[arena->queue_id].items);
+ }
+ break;
+ }
+
+ clif->bgqueue_ack(sd,BGQA_SUCCESS,arena->id);
+
+}
+enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_arena *arena, enum bg_queue_types type) {
+ int tick;
+ unsigned int tsec;
+ if ( sd->status.base_level > arena->max_level || sd->status.base_level < arena->max_level )
+ return BGQA_FAIL_LEVEL_INCORRECT;
+
+ if ( !(sd->class_&JOBL_2) ) /* TODO: maybe make this a per-arena setting, so users may make custom arenas like baby-only,whatever. */
+ return BGQA_FAIL_CLASS_INVALID;
+
+ tsec = (unsigned int)time(NULL);
+
+ if ( ( tick = pc_readglobalreg(sd, bg->gdelay_var) ) && tsec < tick ) {
+ char response[100];
+ if( (tick-tsec) > 60 )
+ sprintf(response, "You are a deserter! Wait %d minute(s) before you can apply again",(tick-tsec)/60);
+ else
+ sprintf(response, "You are a deserter! Wait %d seconds before you can apply again",(tick-tsec));
+ clif->colormes(sd->fd,COLOR_RED,response);
+ return BGQA_FAIL_DESERTER;
+ }
+
+ if ( ( tick = pc_readglobalreg(sd, arena->cooldown_variable) ) && tsec < tick ) {
+ char response[100];
+ if( (tick-tsec) > 60 )
+ sprintf(response, "You can't reapply to this arena so fast. Apply to the different arena or wait %d minute(s)",(tick-tsec)/60);
+ else
+ sprintf(response, "You can't reapply to this arena so fast. Apply to the different arena or wait %d seconds",(tick-tsec));
+ clif->colormes(sd->fd,COLOR_RED,response);
+ return BGQA_FAIL_COOLDOWN;
+ }
+
+ if( sd->bg_queue.arena != NULL )
+ return BGQA_DUPLICATE_REQUEST;
+
+ switch(type) {
+ case BGQT_GUILD:
+ if( !sd->guild || !sd->state.gmaster_flag )
+ return BGQA_NOT_PARTY_GUILD_LEADER;
+ else {
+ int i, count = 0;
+ for ( i=0; i<sd->guild->max_member; i++ ) {
+ if ( !sd->guild->member[i].sd || sd->guild->member[i].sd->bg_queue.arena != NULL )
+ continue;
+ count++;
+ }
+ if ( count < arena->min_team_players ) {
+ char response[100];
+ if( count != sd->guild->connect_member && sd->guild->connect_member >= arena->min_team_players )
+ sprintf(response, "Can't apply: not enough members in your team/guild that have not entered the queue in individual mode, minimum is %d",arena->min_team_players);
+ else
+ sprintf(response, "Can't apply: not enough members in your team/guild, minimum is %d",arena->min_team_players);
+ clif->colormes(sd->fd,COLOR_RED,response);
+ return BGQA_FAIL_TEAM_COUNT;
+ }
+ }
+ break;
+ case BGQT_PARTY:
+ if( !sd->status.party_id )
+ return BGQA_NOT_PARTY_GUILD_LEADER;
+ else {
+ struct party_data *p;
+ if( (p = party->search(sd->status.party_id) ) ) {
+ int i, count = 0;
+ bool is_leader = false;
+
+ for(i = 0; i < MAX_PARTY; i++) {
+ if( !p->data[i].sd )
+ continue;
+ if( p->party.member[i].leader && sd == p->data[i].sd )
+ is_leader = true;
+ if( p->data[i].sd->bg_queue.arena == NULL )
+ count++;
+ }
+
+ if( !is_leader )
+ return BGQA_NOT_PARTY_GUILD_LEADER;
+
+ if( count < arena->min_team_players ) {
+ char response[100];
+ if( count != p->party.count && p->party.count >= arena->min_team_players )
+ sprintf(response, "Can't apply: not enough members in your team/party that have not entered the queue in individual mode, minimum is %d",arena->min_team_players);
+ else
+ sprintf(response, "Can't apply: not enough members in your team/party, minimum is %d",arena->min_team_players);
+ clif->colormes(sd->fd,COLOR_RED,response);
+ return BGQA_FAIL_TEAM_COUNT;
+ }
+
+ } else
+ return BGQA_NOT_PARTY_GUILD_LEADER;
+ }
+ break;
+ case BGQT_INDIVIDUAL:/* already did */
+ break;
+ default:
+ ShowDebug("bg_canqueue: unknown/unsupported type %d\n",type);
+ return BGQA_DUPLICATE_REQUEST;
+ }
+
+ return BGQA_SUCCESS;
+}
+void do_init_battleground(void) {
bg_team_db = idb_alloc(DB_OPT_RELEASE_DATA);
- add_timer_func_list(bg_send_xy_timer, "bg_send_xy_timer");
- add_timer_interval(gettick() + battle_config.bg_update_interval, bg_send_xy_timer, 0, 0, battle_config.bg_update_interval);
+ iTimer->add_timer_func_list(bg_send_xy_timer, "bg_send_xy_timer");
+ iTimer->add_timer_interval(iTimer->gettick() + battle_config.bg_update_interval, bg_send_xy_timer, 0, 0, battle_config.bg_update_interval);
}
-void do_final_battleground(void)
-{
+void do_final_battleground(void) {
+ int i;
+
bg_team_db->destroy(bg_team_db, NULL);
+
+ for( i = 0; i < bg->arenas; i++ ) {
+ if( bg->arena[i] )
+ aFree(bg->arena[i]);
+ }
+
+ if( bg->arena )
+ aFree(bg->arena);
+}
+void battleground_defaults(void) {
+ bg = &bg_s;
+
+ bg->queue_on = false;
+
+ bg->mafksec = 0;
+ bg->arena = NULL;
+ bg->arenas = 0;
+ /* */
+ bg->name2arena = bg_name2arena;
+ bg->queue_add = bg_queue_add;
+ bg->can_queue = bg_canqueue;
+ bg->id2pos = bg_id2pos;
+ bg->queue_pc_cleanup = bg_queue_player_cleanup;
+ bg->begin = bg_begin;
+ bg->begin_timer = bg_begin_timer;
+ bg->queue_pregame = bg_queue_pregame;
+ bg->fillup_timer = bg_fillup_timer;
+ bg->queue_ready_ack = bg_queue_ready_ack;
+ /* */
+ bg->config_read = bg_config_read;
}
diff --git a/src/map/battleground.h b/src/map/battleground.h
index c2b74a534..030d13d90 100644
--- a/src/map/battleground.h
+++ b/src/map/battleground.h
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#ifndef _BATTLEGROUND_H_
#define _BATTLEGROUND_H_
@@ -7,7 +8,21 @@
#include "../common/mmo.h" // struct party
#include "guild.h"
+/**
+ * Defines
+ **/
#define MAX_BG_MEMBERS 30
+#define BG_DELAY_VAR_LENGTH 30
+
+/**
+ * Enumerations
+ **/
+enum bg_queue_types {
+ BGQT_INVALID,
+ BGQT_INDIVIDUAL,
+ BGQT_PARTY,
+ BGQT_GUILD
+};
struct battleground_member_data {
unsigned short x, y;
@@ -42,4 +57,52 @@ int bg_team_warp(int bg_id, unsigned short mapindex, short x, short y);
int bg_member_respawn(struct map_session_data *sd);
int bg_send_message(struct map_session_data *sd, const char *mes, int len);
+struct bg_arena {
+ char name[NAME_LENGTH];
+ unsigned char id;
+ char npc_event[EVENT_NAME_LENGTH];
+ short min_level, max_level;
+ short prize_win, prize_loss, prize_draw;
+ short min_players;
+ short max_players;
+ short min_team_players;
+ char cooldown_variable[NAME_LENGTH];
+ char delay_var[NAME_LENGTH];
+ unsigned short maxDuration;
+ int queue_id;
+ int begin_timer;
+ int fillup_timer;
+ int game_timer;
+ unsigned short fillup_duration;
+ unsigned short pregame_duration;
+};
+
+/* battleground.c interface (incomplete) */
+struct battleground_interface {
+ bool queue_on;
+ /* */
+ int mafksec;
+ char gdelay_var[BG_DELAY_VAR_LENGTH];
+ /* */
+ struct bg_arena **arena;
+ unsigned char arenas;
+ /* */
+ struct bg_arena *(*name2arena) (char *name);
+ void (*queue_add) (struct map_session_data *sd, struct bg_arena *arena, enum bg_queue_types type);
+ enum BATTLEGROUNDS_QUEUE_ACK (*can_queue) (struct map_session_data *sd, struct bg_arena *arena, enum bg_queue_types type);
+ int (*id2pos) (int queue_id, int account_id);
+ void (*queue_pc_cleanup) (struct map_session_data *sd);
+ void (*begin) (struct bg_arena *arena);
+ int (*begin_timer) (int tid, unsigned int tick, int id, intptr_t data);
+ void (*queue_pregame) (struct bg_arena *arena);
+ int (*fillup_timer) (int tid, unsigned int tick, int id, intptr_t data);
+ void (*queue_ready_ack) (struct bg_arena *arena, struct map_session_data *sd, bool response);
+ /* */
+ void (*config_read) (void);
+} bg_s;
+
+struct battleground_interface *bg;
+
+void battleground_defaults(void);
+
#endif /* _BATTLEGROUND_H_ */
diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c
index 0b59e8f1e..dc07c2409 100644
--- a/src/map/buyingstore.c
+++ b/src/map/buyingstore.c
@@ -64,7 +64,7 @@ bool buyingstore_setup(struct map_session_data* sd, unsigned char slots)
return false;
}
- if( map_getcell(sd->bl.m, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING) )
+ if( iMap->getcell(sd->bl.m, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING) )
{// custom: no vending cells
clif->message(sd->fd, msg_txt(204)); // "You can't open a shop on this cell."
return false;
@@ -100,7 +100,7 @@ void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha
return;
}
- if( !pc_can_give_items(sd) )
+ if( !pc->can_give_items(sd) )
{// custom: GM is not allowed to buy (give zeny)
sd->buyingstore.slots = 0;
clif->message(sd->fd, msg_txt(246));
@@ -119,7 +119,7 @@ void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha
return;
}
- if( map_getcell(sd->bl.m, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING) )
+ if( iMap->getcell(sd->bl.m, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING) )
{// custom: no vending cells
clif->message(sd->fd, msg_txt(204)); // "You can't open a shop on this cell."
return;
@@ -137,7 +137,7 @@ void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha
amount = RBUFW(itemlist,i*8+2);
price = RBUFL(itemlist,i*8+4);
- if( ( id = itemdb_exists(nameid) ) == NULL || amount == 0 )
+ if( ( id = itemdb->exists(nameid) ) == NULL || amount == 0 )
{// invalid input
break;
}
@@ -147,7 +147,7 @@ void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha
break;
}
- if( !id->flag.buyingstore || !itemdb_cantrade_sub(id, pc_get_group_level(sd), pc_get_group_level(sd)) || ( idx = pc_search_inventory(sd, nameid) ) == -1 )
+ if( !id->flag.buyingstore || !itemdb_cantrade_sub(id, pc->get_group_level(sd), pc->get_group_level(sd)) || ( idx = pc->search_inventory(sd, nameid) ) == -1 )
{// restrictions: allowed, no character-bound items and at least one must be owned
break;
}
@@ -221,13 +221,13 @@ void buyingstore_open(struct map_session_data* sd, int account_id)
return;
}
- if( !pc_can_give_items(sd) )
+ if( !pc->can_give_items(sd) )
{// custom: GM is not allowed to sell
clif->message(sd->fd, msg_txt(246));
return;
}
- if( ( pl_sd = map_id2sd(account_id) ) == NULL || !pl_sd->state.buyingstore )
+ if( ( pl_sd = iMap->id2sd(account_id) ) == NULL || !pl_sd->state.buyingstore )
{// not online or not buying
return;
}
@@ -259,14 +259,14 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int
return;
}
- if( !pc_can_give_items(sd) )
+ if( !pc->can_give_items(sd) )
{// custom: GM is not allowed to sell
clif->message(sd->fd, msg_txt(246));
clif->buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, 0);
return;
}
- if( ( pl_sd = map_id2sd(account_id) ) == NULL || !pl_sd->state.buyingstore || pl_sd->buyer_id != buyer_id )
+ if( ( pl_sd = iMap->id2sd(account_id) ) == NULL || !pl_sd->state.buyingstore || pl_sd->buyer_id != buyer_id )
{// not online, not buying or not same store
clif->buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, 0);
return;
@@ -314,7 +314,7 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int
return;
}
- if( sd->status.inventory[index].expire_time || !itemdb_cantrade(&sd->status.inventory[index], pc_get_group_level(sd), pc_get_group_level(pl_sd)) || memcmp(sd->status.inventory[index].card, buyingstore_blankslots, sizeof(buyingstore_blankslots)) )
+ if( sd->status.inventory[index].expire_time || !itemdb_cantrade(&sd->status.inventory[index], pc->get_group_level(sd), pc->get_group_level(pl_sd)) || memcmp(sd->status.inventory[index].card, buyingstore_blankslots, sizeof(buyingstore_blankslots)) )
{// non-tradable item
clif->buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, nameid);
return;
@@ -333,7 +333,7 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int
return;
}
- if( pc_checkadditem(pl_sd, nameid, amount) == ADDITEM_OVERAMOUNT )
+ if( pc->checkadditem(pl_sd, nameid, amount) == ADDITEM_OVERAMOUNT )
{// buyer does not have enough space for this item
clif->buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, nameid);
return;
@@ -369,13 +369,13 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int
zeny = amount*pl_sd->buyingstore.items[listidx].price;
// move item
- pc_additem(pl_sd, &sd->status.inventory[index], amount, LOG_TYPE_BUYING_STORE);
- pc_delitem(sd, index, amount, 1, 0, LOG_TYPE_BUYING_STORE);
+ pc->additem(pl_sd, &sd->status.inventory[index], amount, LOG_TYPE_BUYING_STORE);
+ pc->delitem(sd, index, amount, 1, 0, LOG_TYPE_BUYING_STORE);
pl_sd->buyingstore.items[listidx].amount-= amount;
// pay up
- pc_payzeny(pl_sd, zeny, LOG_TYPE_BUYING_STORE, sd);
- pc_getzeny(sd, zeny, LOG_TYPE_BUYING_STORE, pl_sd);
+ pc->payzeny(pl_sd, zeny, LOG_TYPE_BUYING_STORE, sd);
+ pc->getzeny(sd, zeny, LOG_TYPE_BUYING_STORE, pl_sd);
pl_sd->buyingstore.zenylimit-= zeny;
// notify clients
@@ -383,7 +383,7 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int
clif->buyingstore_update_item(pl_sd, nameid, amount);
}
- if( save_settings&128 ) {
+ if( iMap->save_settings&128 ) {
chrif_save(sd, 0);
chrif_save(pl_sd, 0);
}
@@ -409,7 +409,7 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int
// remove auto-trader
if( pl_sd->state.autotrade )
{
- map_quit(pl_sd);
+ iMap->quit(pl_sd);
}
}
diff --git a/src/map/chat.c b/src/map/chat.c
index a18e87eef..c0452f2c5 100644
--- a/src/map/chat.c
+++ b/src/map/chat.c
@@ -44,7 +44,7 @@ static struct chat_data* chat_createchat(struct block_list* bl, const char* titl
cd->owner = bl;
safestrncpy(cd->npc_event, ev, sizeof(cd->npc_event));
- cd->bl.id = map_get_new_object_id();
+ cd->bl.id = iMap->get_new_object_id();
cd->bl.m = bl->m;
cd->bl.x = bl->x;
cd->bl.y = bl->y;
@@ -57,7 +57,7 @@ static struct chat_data* chat_createchat(struct block_list* bl, const char* titl
cd = NULL;
}
- map_addiddb(&cd->bl);
+ iMap->addiddb(&cd->bl);
if( bl->type != BL_NPC )
cd->kick_list = idb_alloc(DB_OPT_BASE);
@@ -87,7 +87,7 @@ int chat_createpcchat(struct map_session_data* sd, const char* title, const char
return 0; //Can't create chatrooms on this map.
}
- if( map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOCHAT) )
+ if( iMap->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOCHAT) )
{
clif->message (sd->fd, msg_txt(665));
return 0;
@@ -117,7 +117,7 @@ int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass)
struct chat_data* cd;
nullpo_ret(sd);
- cd = (struct chat_data*)map_id2bl(chatid);
+ cd = (struct chat_data*)iMap->id2bl(chatid);
if( cd == NULL || cd->bl.type != BL_CHAT || cd->bl.m != sd->bl.m || sd->state.vending || sd->state.buyingstore || sd->chatID || ((cd->owner->type == BL_NPC) ? cd->users+1 : cd->users) >= cd->limit )
{
@@ -177,7 +177,7 @@ int chat_leavechat(struct map_session_data* sd, bool kicked)
nullpo_retr(1, sd);
- cd = (struct chat_data*)map_id2bl(sd->chatID);
+ cd = (struct chat_data*)iMap->id2bl(sd->chatID);
if( cd == NULL )
{
pc_setchatid(sd, 0);
@@ -207,11 +207,11 @@ int chat_leavechat(struct map_session_data* sd, bool kicked)
clif->clearchat(cd, 0);
db_destroy(cd->kick_list);
- map_deliddb(&cd->bl);
- map_delblock(&cd->bl);
- map_freeblock(&cd->bl);
+ iMap->deliddb(&cd->bl);
+ iMap->delblock(&cd->bl);
+ iMap->freeblock(&cd->bl);
- unit = map_find_skill_unit_oncell(&sd->bl, sd->bl.x, sd->bl.y, AL_WARP, NULL, 0);
+ unit = iMap->find_skill_unit_oncell(&sd->bl, sd->bl.x, sd->bl.y, AL_WARP, NULL, 0);
group = (unit != NULL) ? unit->group : NULL;
if (group != NULL)
skill->unit_onplace(unit, &sd->bl, group->tick);
@@ -226,10 +226,10 @@ int chat_leavechat(struct map_session_data* sd, bool kicked)
clif->clearchat(cd, 0);
//Adjust Chat location after owner has been changed.
- map_delblock( &cd->bl );
+ iMap->delblock( &cd->bl );
cd->bl.x=cd->usersd[0]->bl.x;
cd->bl.y=cd->usersd[0]->bl.y;
- map_addblock( &cd->bl );
+ iMap->addblock( &cd->bl );
clif->dispchat(cd,0);
}
@@ -250,7 +250,7 @@ int chat_changechatowner(struct map_session_data* sd, const char* nextownername)
nullpo_retr(1, sd);
- cd = (struct chat_data*)map_id2bl(sd->chatID);
+ cd = (struct chat_data*)iMap->id2bl(sd->chatID);
if( cd == NULL || (struct block_list*) sd != cd->owner )
return 1;
@@ -271,10 +271,10 @@ int chat_changechatowner(struct map_session_data* sd, const char* nextownername)
cd->usersd[0] = tmpsd;
// set the new chatroom position
- map_delblock( &cd->bl );
+ iMap->delblock( &cd->bl );
cd->bl.x = cd->owner->x;
cd->bl.y = cd->owner->y;
- map_addblock( &cd->bl );
+ iMap->addblock( &cd->bl );
// and display again
clif->dispchat(cd,0);
@@ -291,7 +291,7 @@ int chat_changechatstatus(struct map_session_data* sd, const char* title, const
nullpo_retr(1, sd);
- cd = (struct chat_data*)map_id2bl(sd->chatID);
+ cd = (struct chat_data*)iMap->id2bl(sd->chatID);
if( cd==NULL || (struct block_list *)sd != cd->owner )
return 1;
@@ -316,7 +316,7 @@ int chat_kickchat(struct map_session_data* sd, const char* kickusername)
nullpo_retr(1, sd);
- cd = (struct chat_data *)map_id2bl(sd->chatID);
+ cd = (struct chat_data *)iMap->id2bl(sd->chatID);
if( cd==NULL || (struct block_list *)sd != cd->owner )
return -1;
@@ -366,15 +366,15 @@ int chat_deletenpcchat(struct npc_data* nd)
struct chat_data *cd;
nullpo_ret(nd);
- cd = (struct chat_data*)map_id2bl(nd->chat_id);
+ cd = (struct chat_data*)iMap->id2bl(nd->chat_id);
if( cd == NULL )
return 0;
chat_npckickall(cd);
clif->clearchat(cd, 0);
- map_deliddb(&cd->bl);
- map_delblock(&cd->bl);
- map_freeblock(&cd->bl);
+ iMap->deliddb(&cd->bl);
+ iMap->delblock(&cd->bl);
+ iMap->freeblock(&cd->bl);
nd->chat_id = 0;
return 0;
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 06956e731..a95193363 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -53,11 +53,11 @@ static const int packet_len_table[0x3d] = { // U - used, F - free
//2af9: Incoming, chrif_connectack -> 'answer of the 2af8 login(ok / fail)'
//2afa: Outgoing, chrif_sendmap -> 'sending our maps'
//2afb: Incoming, chrif_sendmapack -> 'Maps received successfully / or not ..'
-//2afc: Outgoing, chrif_scdata_request -> request sc_data for pc_authok'ed char. <- new command reuses previous one.
+//2afc: Outgoing, chrif_scdata_request -> request sc_data for pc->authok'ed char. <- new command reuses previous one.
//2afd: Incoming, chrif_authok -> 'client authentication ok'
//2afe: Outgoing, send_usercount_tochar -> 'sends player count of this map server to charserver'
//2aff: Outgoing, send_users_tochar -> 'sends all actual connected character ids to charserver'
-//2b00: Incoming, map_setusers -> 'set the actual usercount? PACKET.2B COUNT.L.. ?' (not sure)
+//2b00: Incoming, iMap->setusers -> 'set the actual usercount? PACKET.2B COUNT.L.. ?' (not sure)
//2b01: Outgoing, chrif_save -> 'charsave of char XY account XY (complete struct)'
//2b02: Outgoing, chrif_charselectreq -> 'player returns from ingame to charserver to select another char.., this packets includes sessid etc' ? (not 100% sure)
//2b03: Incoming, clif_charselectok -> '' (i think its the packet after enterworld?) (not sure)
@@ -185,7 +185,7 @@ static bool chrif_sd_to_auth(TBL_PC* sd, enum sd_state state) {
node->sex = sd->status.sex;
node->fd = sd->fd;
node->sd = sd; //Data from logged on char.
- node->node_created = gettick(); //timestamp for node timeouts
+ node->node_created = iTimer->gettick(); //timestamp for node timeouts
node->state = state;
sd->state.active = 0;
@@ -272,7 +272,7 @@ int chrif_isconnected(void) {
int chrif_save(struct map_session_data *sd, int flag) {
nullpo_retr(-1, sd);
- pc_makesavestatus(sd);
+ pc->makesavestatus(sd);
if (flag && sd->state.active) { //Store player data which is quitting
//FIXME: SC are lost if there's no connection at save-time because of the way its related data is cleared immediately after this function. [Skotlex]
@@ -286,7 +286,7 @@ int chrif_save(struct map_session_data *sd, int flag) {
//For data sync
if (sd->state.storage_flag == 2)
- storage_guild_storagesave(sd->status.account_id, sd->status.guild_id, flag);
+ gstorage->save(sd->status.account_id, sd->status.guild_id, flag);
if (flag)
sd->state.storage_flag = 0; //Force close it.
@@ -344,9 +344,9 @@ int chrif_sendmap(int fd) {
ShowStatus("Sending maps to char server...\n");
// Sending normal maps, not instances
- WFIFOHEAD(fd, 4 + instance_start * 4);
+ WFIFOHEAD(fd, 4 + instance->start_id * 4);
WFIFOW(fd,0) = 0x2afa;
- for(i = 0; i < instance_start; i++)
+ for(i = 0; i < instance->start_id; i++)
WFIFOW(fd,4+i*4) = map[i].index;
WFIFOW(fd,2) = 4 + i * 4;
WFIFOSET(fd,WFIFOW(fd,2));
@@ -361,7 +361,7 @@ int chrif_recvmap(int fd) {
uint16 port = ntohs(RFIFOW(fd,8));
for(i = 10, j = 0; i < RFIFOW(fd,2); i += 4, j++) {
- map_setipport(RFIFOW(fd,i), ip, port);
+ iMap->setipport(RFIFOW(fd,i), ip, port);
}
if (battle_config.etc_log)
@@ -379,7 +379,7 @@ int chrif_removemap(int fd) {
uint16 port = RFIFOW(fd,8);
for(i = 10, j = 0; i < RFIFOW(fd, 2); i += 4, j++)
- map_eraseipport(RFIFOW(fd, i), ip, port);
+ iMap->eraseipport(RFIFOW(fd, i), ip, port);
other_mapserver_count--;
@@ -484,7 +484,7 @@ static int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
switch (node->state) {
case ST_LOGIN:
if ( node->sd && node->char_dat == NULL ) {//Since there is no way to request the char auth, make it fail.
- pc_authfail(node->sd);
+ pc->authfail(node->sd);
chrif_char_offline(node->sd);
chrif_auth_delete(node->account_id, node->char_id, ST_LOGIN);
}
@@ -498,7 +498,7 @@ static int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
uint32 ip;
uint16 port;
- if( map_mapname2ipport(sd->mapindex,&ip,&port) == 0 )
+ if( iMap->mapname2ipport(sd->mapindex,&ip,&port) == 0 )
chrif_changemapserver(sd, ip, port);
else //too much lag/timeout is the closest explanation for this error.
clif->authfail_fd(sd->fd, 3);
@@ -526,7 +526,7 @@ void chrif_on_ready(void) {
auth_db->foreach(auth_db,chrif_reconnect);
//Re-save any storages that were modified in the disconnection time. [Skotlex]
- do_reconnect_storage();
+ storage->reconnect();
//Re-save any guild castles that were modified in the disconnection time.
guild->castle_reconnect(-1, 0, 0);
@@ -543,7 +543,7 @@ int chrif_sendmapack(int fd) {
exit(EXIT_FAILURE);
}
- memcpy(wisp_server_name, RFIFOP(fd,3), NAME_LENGTH);
+ memcpy(iMap->wisp_server_name, RFIFOP(fd,3), NAME_LENGTH);
chrif_on_ready();
@@ -619,7 +619,7 @@ void chrif_authok(int fd) {
//Check if we don't already have player data in our server
//Causes problems if the currently connected player tries to quit or this data belongs to an already connected player which is trying to re-auth.
- if ( ( sd = map_id2sd(account_id) ) != NULL )
+ if ( ( sd = iMap->id2sd(account_id) ) != NULL )
return;
if ( ( node = chrif_search(account_id) ) == NULL )
@@ -645,10 +645,10 @@ void chrif_authok(int fd) {
node->char_id == char_id &&
node->login_id1 == login_id1 )
{ //Auth Ok
- if (pc_authok(sd, login_id2, expiration_time, group_id, status, changing_mapservers))
+ if (pc->authok(sd, login_id2, expiration_time, group_id, status, changing_mapservers))
return;
} else { //Auth Failed
- pc_authfail(sd);
+ pc->authfail(sd);
}
chrif_char_offline(sd); //Set him offline, the char server likely has it set as online already.
@@ -690,11 +690,11 @@ int auth_db_cleanup_sub(DBKey key, DBData *data, va_list ap) {
struct auth_node *node = DB->data2ptr(data);
const char* states[] = { "Login", "Logout", "Map change" };
- if(DIFF_TICK(gettick(),node->node_created)>60000) {
+ if(DIFF_TICK(iTimer->gettick(),node->node_created)>60000) {
switch (node->state) {
case ST_LOGOUT:
//Re-save attempt (->sd should never be null here).
- node->node_created = gettick(); //Refresh tick (avoid char-server load if connection is really bad)
+ node->node_created = iTimer->gettick(); //Refresh tick (avoid char-server load if connection is really bad)
chrif_save(node->sd, 1);
break;
default:
@@ -819,7 +819,7 @@ int chrif_changesex(struct map_session_data *sd) {
if (sd->fd)
clif->authfail_fd(sd->fd, 15);
else
- map_quit(sd);
+ iMap->quit(sd);
return 0;
}
@@ -839,7 +839,7 @@ static void chrif_char_ask_name_answer(int acc, const char* player_name, uint16
char action[25];
char output[256];
- sd = map_id2sd(acc);
+ sd = iMap->id2sd(acc);
if( acc < 0 || sd == NULL ) {
ShowError("chrif_char_ask_name_answer failed - player not online.\n");
@@ -875,7 +875,7 @@ int chrif_changedsex(int fd) {
if ( battle_config.etc_log )
ShowNotice("chrif_changedsex %d.\n", acc);
- sd = map_id2sd(acc);
+ sd = iMap->id2sd(acc);
if ( sd ) { //Normally there should not be a char logged on right now!
if ( sd->status.sex == sex )
return 0; //Do nothing? Likely safe.
@@ -915,7 +915,7 @@ int chrif_changedsex(int fd) {
// do same modify in login-server for the account, but no in char-server (it ask again login_id1 to login, and don't remember it)
clif->message(sd->fd, msg_txt(409)); //"Your sex has been changed (need disconnection by the server)..."
set_eof(sd->fd); // forced to disconnect for the change
- map_quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X]
+ iMap->quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X]
}
return 0;
}
@@ -945,18 +945,18 @@ int chrif_divorceack(int char_id, int partner_id) {
if( !char_id || !partner_id )
return 0;
- if( ( sd = map_charid2sd(char_id) ) != NULL && sd->status.partner_id == partner_id ) {
+ if( ( sd = iMap->charid2sd(char_id) ) != NULL && sd->status.partner_id == partner_id ) {
sd->status.partner_id = 0;
for(i = 0; i < MAX_INVENTORY; i++)
if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F)
- pc_delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
+ pc->delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
}
- if( ( sd = map_charid2sd(partner_id) ) != NULL && sd->status.partner_id == char_id ) {
+ if( ( sd = iMap->charid2sd(partner_id) ) != NULL && sd->status.partner_id == char_id ) {
sd->status.partner_id = 0;
for(i = 0; i < MAX_INVENTORY; i++)
if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F)
- pc_delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
+ pc->delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
}
return 0;
@@ -968,7 +968,7 @@ int chrif_deadopt(int father_id, int mother_id, int child_id) {
struct map_session_data* sd;
int idx = skill->get_index(WE_CALLBABY);
- if( father_id && ( sd = map_charid2sd(father_id) ) != NULL && sd->status.child == child_id ) {
+ if( father_id && ( sd = iMap->charid2sd(father_id) ) != NULL && sd->status.child == child_id ) {
sd->status.child = 0;
sd->status.skill[idx].id = 0;
sd->status.skill[idx].lv = 0;
@@ -976,7 +976,7 @@ int chrif_deadopt(int father_id, int mother_id, int child_id) {
clif->deleteskill(sd,WE_CALLBABY);
}
- if( mother_id && ( sd = map_charid2sd(mother_id) ) != NULL && sd->status.child == child_id ) {
+ if( mother_id && ( sd = iMap->charid2sd(mother_id) ) != NULL && sd->status.child == child_id ) {
sd->status.child = 0;
sd->status.skill[idx].id = 0;
sd->status.skill[idx].lv = 0;
@@ -999,7 +999,7 @@ int chrif_accountban(int fd) {
if ( battle_config.etc_log )
ShowNotice("chrif_accountban %d.\n", acc);
- sd = map_id2sd(acc);
+ sd = iMap->id2sd(acc);
if ( acc < 0 || sd == NULL ) {
ShowError("chrif_accountban failed - player not online.\n");
@@ -1025,7 +1025,7 @@ int chrif_accountban(int fd) {
}
set_eof(sd->fd); // forced to disconnect for the change
- map_quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X]
+ iMap->quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X]
return 0;
}
@@ -1035,7 +1035,7 @@ int chrif_disconnectplayer(int fd) {
struct map_session_data* sd;
int account_id = RFIFOL(fd, 2);
- sd = map_id2sd(account_id);
+ sd = iMap->id2sd(account_id);
if( sd == NULL ) {
struct auth_node* auth = chrif_search(account_id);
@@ -1047,7 +1047,7 @@ int chrif_disconnectplayer(int fd) {
if (!sd->fd) { //No connection
if (sd->state.autotrade)
- map_quit(sd); //Remove it.
+ iMap->quit(sd); //Remove it.
//Else we don't remove it because the char should have a timer to remove the player because it force-quit before,
//and we don't want them kicking their previous instance before the 10 secs penalty time passes. [Skotlex]
return 0;
@@ -1172,7 +1172,7 @@ int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the
const struct TimerData *timer;
chrif_check(-1);
- tick = gettick();
+ tick = iTimer->gettick();
WFIFOHEAD(char_fd, 14 + SC_MAX*sizeof(struct status_change_data));
WFIFOW(char_fd,0) = 0x2b1c;
@@ -1183,7 +1183,7 @@ int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the
if (!sc->data[i])
continue;
if (sc->data[i]->timer != INVALID_TIMER) {
- timer = get_timer(sc->data[i]->timer);
+ timer = iTimer->get_timer(sc->data[i]->timer);
if (timer == NULL || timer->func != status_change_timer || DIFF_TICK(timer->tick,tick) < 0)
continue;
data.tick = DIFF_TICK(timer->tick,tick); //Duration that is left before ending.
@@ -1221,7 +1221,7 @@ int chrif_load_scdata(int fd) {
aid = RFIFOL(fd,4); //Player Account ID
cid = RFIFOL(fd,8); //Player Char ID
- sd = map_id2sd(aid);
+ sd = iMap->id2sd(aid);
if ( !sd ) {
ShowError("chrif_load_scdata: Player of AID %d not found!\n", aid);
@@ -1338,10 +1338,10 @@ void chrif_on_disconnect(void) {
chrif_connected = 0;
other_mapserver_count = 0; //Reset counter. We receive ALL maps from all map-servers on reconnect.
- map_eraseallipport();
+ iMap->eraseallipport();
//Attempt to reconnect in a second. [Skotlex]
- add_timer(gettick() + 1000, check_connect_char_server, 0, 0);
+ iTimer->add_timer(iTimer->gettick() + 1000, check_connect_char_server, 0, 0);
}
@@ -1448,11 +1448,11 @@ int chrif_parse(int fd) {
case 0x2af9: chrif_connectack(fd); break;
case 0x2afb: chrif_sendmapack(fd); break;
case 0x2afd: chrif_authok(fd); break;
- case 0x2b00: map_setusers(RFIFOL(fd,2)); chrif_keepalive(fd); break;
+ case 0x2b00: iMap->setusers(RFIFOL(fd,2)); chrif_keepalive(fd); break;
case 0x2b03: clif->charselectok(RFIFOL(fd,2), RFIFOB(fd,6)); break;
case 0x2b04: chrif_recvmap(fd); break;
case 0x2b06: chrif_changemapserverack(RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), RFIFOW(fd,18), RFIFOW(fd,20), RFIFOW(fd,22), RFIFOL(fd,24), RFIFOW(fd,28)); break;
- case 0x2b09: map_addnickdb(RFIFOL(fd,2), (char*)RFIFOP(fd,6)); break;
+ case 0x2b09: iMap->addnickdb(RFIFOL(fd,2), (char*)RFIFOP(fd,6)); break;
case 0x2b0a: socket_datasync(fd, false); break;
case 0x2b0d: chrif_changedsex(fd); break;
case 0x2b0f: chrif_char_ask_name_answer(RFIFOL(fd,2), (char*)RFIFOP(fd,6), RFIFOW(fd,30), RFIFOW(fd,32)); break;
@@ -1486,7 +1486,7 @@ int send_usercount_tochar(int tid, unsigned int tick, int id, intptr_t data) {
WFIFOHEAD(char_fd,4);
WFIFOW(char_fd,0) = 0x2afe;
- WFIFOW(char_fd,2) = map_usercount();
+ WFIFOW(char_fd,2) = iMap->usercount();
WFIFOSET(char_fd,4);
return 0;
}
@@ -1502,7 +1502,7 @@ int send_users_tochar(void) {
chrif_check(-1);
- users = map_usercount();
+ users = iMap->usercount();
WFIFOHEAD(char_fd, 6+8*users);
WFIFOW(char_fd,0) = 0x2aff;
@@ -1537,9 +1537,8 @@ static int check_connect_char_server(int tid, unsigned int tick, int id, intptr_
}
chrif_state = 0;
- char_fd = make_connection(char_ip, char_port,false);
- if (char_fd == -1)//Attempt to connect later. [Skotlex]
+ if ( ( char_fd = make_connection(char_ip, char_port,NULL) ) == -1) //Attempt to connect later. [Skotlex]
return 0;
session[char_fd]->func_parse = chrif_parse;
@@ -1634,17 +1633,17 @@ int do_init_chrif(void) {
auth_db = idb_alloc(DB_OPT_BASE);
auth_db_ers = ers_new(sizeof(struct auth_node),"chrif.c::auth_db_ers",ERS_OPT_NONE);
- add_timer_func_list(check_connect_char_server, "check_connect_char_server");
- add_timer_func_list(auth_db_cleanup, "auth_db_cleanup");
+ iTimer->add_timer_func_list(check_connect_char_server, "check_connect_char_server");
+ iTimer->add_timer_func_list(auth_db_cleanup, "auth_db_cleanup");
// establish map-char connection if not present
- add_timer_interval(gettick() + 1000, check_connect_char_server, 0, 0, 10 * 1000);
+ iTimer->add_timer_interval(iTimer->gettick() + 1000, check_connect_char_server, 0, 0, 10 * 1000);
// wipe stale data for timed-out client connection requests
- add_timer_interval(gettick() + 1000, auth_db_cleanup, 0, 0, 30 * 1000);
+ iTimer->add_timer_interval(iTimer->gettick() + 1000, auth_db_cleanup, 0, 0, 30 * 1000);
// send the user count every 10 seconds, to hide the charserver's online counting problem
- add_timer_interval(gettick() + 1000, send_usercount_tochar, 0, 0, UPDATE_INTERVAL);
+ iTimer->add_timer_interval(iTimer->gettick() + 1000, send_usercount_tochar, 0, 0, UPDATE_INTERVAL);
return 0;
}
diff --git a/src/map/clif.c b/src/map/clif.c
index 2f69ce2fd..2bb272cd2 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -226,7 +226,6 @@ uint32 clif_refresh_ip(void) {
}
return 0;
}
-
#if PACKETVER >= 20071106
static inline unsigned char clif_bl_type(struct block_list *bl) {
switch (bl->type) {
@@ -362,11 +361,11 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target
clif->send (buf, len, bl, SELF);
case AREA_WOC:
case AREA_WOS:
- map_foreachinarea(clif->send_sub, bl->m, bl->x-AREA_SIZE, bl->y-AREA_SIZE, bl->x+AREA_SIZE, bl->y+AREA_SIZE,
+ iMap->foreachinarea(clif->send_sub, bl->m, bl->x-AREA_SIZE, bl->y-AREA_SIZE, bl->x+AREA_SIZE, bl->y+AREA_SIZE,
BL_PC, buf, len, bl, type);
break;
case AREA_CHAT_WOC:
- map_foreachinarea(clif->send_sub, bl->m, bl->x-(AREA_SIZE-5), bl->y-(AREA_SIZE-5),
+ iMap->foreachinarea(clif->send_sub, bl->m, bl->x-(AREA_SIZE-5), bl->y-(AREA_SIZE-5),
bl->x+(AREA_SIZE-5), bl->y+(AREA_SIZE-5), BL_PC, buf, len, bl, AREA_WOC);
break;
@@ -375,7 +374,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target
{
struct chat_data *cd;
if (sd) {
- cd = (struct chat_data*)map_id2bl(sd->chatID);
+ cd = (struct chat_data*)iMap->id2bl(sd->chatID);
} else if (bl->type == BL_CHAT) {
cd = (struct chat_data*)bl;
} else break;
@@ -404,7 +403,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target
case PARTY_SAMEMAP:
case PARTY_SAMEMAP_WOS:
if (sd && sd->status.party_id)
- p = party_search(sd->status.party_id);
+ p = party->search(sd->status.party_id);
if (p) {
for(i=0;i<MAX_PARTY;i++){
@@ -427,7 +426,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target
memcpy(WFIFOP(fd,0), buf, len);
WFIFOSET(fd,len);
}
- if (!enable_spy) //Skip unnecessary parsing. [Skotlex]
+ if (!iMap->enable_spy) //Skip unnecessary parsing. [Skotlex]
break;
iter = mapit_getallusers();
@@ -504,7 +503,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target
WFIFOSET(fd,len);
}
}
- if (!enable_spy) //Skip unnecessary parsing. [Skotlex]
+ if (!iMap->enable_spy) //Skip unnecessary parsing. [Skotlex]
break;
iter = mapit_getallusers();
@@ -562,7 +561,7 @@ void clif_authok(struct map_session_data *sd)
struct packet_authok p;
p.PacketType = authokType;
- p.startTime = gettick();
+ p.startTime = iTimer->gettick();
WBUFPOS(&p.PosDir[0],0,sd->bl.x,sd->bl.y,sd->ud.dir); /* do the stupid client math */
p.xSize = p.ySize = 5; /* not-used */
@@ -633,6 +632,7 @@ void clif_authfail_fd(int fd, int type)
WFIFOB(fd,2) = type;
WFIFOSET(fd,packet_len(0x81));
set_eof(fd);
+
}
@@ -646,7 +646,7 @@ void clif_charselectok(int id, uint8 ok)
struct map_session_data* sd;
int fd;
- if ((sd = map_id2sd(id)) == NULL || !sd->fd)
+ if ((sd = iMap->id2sd(id)) == NULL || !sd->fd)
return;
fd = sd->fd;
@@ -764,7 +764,7 @@ void clif_clearunit_delayed(struct block_list* bl, clr_type type, unsigned int t
{
struct block_list *tbl = ers_alloc(clif->delay_clearunit_ers, struct block_list);
memcpy (tbl, bl, sizeof (struct block_list));
- add_timer(tick, clif->clearunit_delayed_sub, (int)type, (intptr_t)tbl);
+ iTimer->add_timer(tick, clif->clearunit_delayed_sub, (int)type, (intptr_t)tbl);
}
void clif_get_weapon_view(struct map_session_data* sd, unsigned short *rhand, unsigned short *lhand)
@@ -850,7 +850,7 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu
p.speed = status_get_speed(bl);
p.bodyState = (sc) ? sc->opt1 : 0;
p.healthState = (sc) ? sc->opt2 : 0;
- p.effectState = (sc) ? sc->option : 0;
+ p.effectState = (sc) ? sc->option : bl->type == BL_NPC ? ((TBL_NPC*)bl)->option : 0;
p.job = vd->class_;
p.head = vd->hair_style;
p.weapon = vd->weapon;
@@ -1092,7 +1092,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) {
p.speed = status_get_speed(bl);
p.bodyState = (sc) ? sc->opt1 : 0;
p.healthState = (sc) ? sc->opt2 : 0;
- p.effectState = (sc) ? sc->option : 0;
+ p.effectState = (sc) ? sc->option : bl->type == BL_NPC ? ((TBL_NPC*)bl)->option : 0;
p.job = vd->class_;
p.head = vd->hair_style;
p.weapon = vd->weapon;
@@ -1172,12 +1172,12 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd,
p.speed = status_get_speed(bl);
p.bodyState = (sc) ? sc->opt1 : 0;
p.healthState = (sc) ? sc->opt2 : 0;
- p.effectState = (sc) ? sc->option : 0;
+ p.effectState = (sc) ? sc->option : bl->type == BL_NPC ? ((TBL_NPC*)bl)->option : 0;
p.job = vd->class_;
p.head = vd->hair_style;
p.weapon = vd->weapon;
p.accessory = vd->head_bottom;
- p.moveStartTime = gettick();
+ p.moveStartTime = iTimer->gettick();
#if PACKETVER < 7
p.shield = vd->shield;
#endif
@@ -1260,12 +1260,12 @@ void clif_spiritball_single(int fd, struct map_session_data *sd) {
/*==========================================
* Kagerou/Oboro amulet spirit
*------------------------------------------*/
-void clif_talisman_single(int fd, struct map_session_data *sd, short type) {
+void clif_charm_single(int fd, struct map_session_data *sd, short type) {
WFIFOHEAD(fd, packet_len(0x08cf));
WFIFOW(fd,0)=0x08cf;
WFIFOL(fd,2)=sd->bl.id;
WFIFOW(fd,6)=type;
- WFIFOW(fd,8)=sd->talisman[type];
+ WFIFOW(fd,8)=sd->charm[type];
WFIFOSET(fd, packet_len(0x08cf));
}
@@ -1333,7 +1333,7 @@ int clif_spawn(struct block_list *bl)
/**
* Hide NPC from maya purple card.
**/
- if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE))
+ if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->option&OPTION_INVISIBLE))
return 0;
clif->spawn_unit(bl,AREA_WOS);
@@ -1359,8 +1359,8 @@ int clif_spawn(struct block_list *bl)
clif->sc_load(&sd->bl, sd->bl.id,AREA,StatusIconChangeTable[sd->sc_display[i]->type],sd->sc_display[i]->val1,sd->sc_display[i]->val2,sd->sc_display[i]->val3);
}
for(i = 1; i < 5; i++){
- if( sd->talisman[i] > 0 )
- clif->talisman(sd, i);
+ if( sd->charm[i] > 0 )
+ clif->charm(sd, i);
}
if (sd->status.robe)
clif->refreshlook(bl,bl->id,LOOK_ROBE,sd->status.robe,AREA);
@@ -1555,7 +1555,7 @@ void clif_walkok(struct map_session_data *sd)
WFIFOHEAD(fd, packet_len(0x87));
WFIFOW(fd,0)=0x87;
- WFIFOL(fd,2)=gettick();
+ WFIFOL(fd,2)=iTimer->gettick();
WFIFOPOS2(fd,6,sd->bl.x,sd->bl.y,sd->ud.to_x,sd->ud.to_y,8,8);
WFIFOSET(fd,packet_len(0x87));
}
@@ -1612,7 +1612,7 @@ void clif_move(struct unit_data *ud)
/**
* Hide NPC from maya purple card.
**/
- if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE))
+ if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->option&OPTION_INVISIBLE))
return;
if (ud->state.speed_changed) {
@@ -1626,10 +1626,9 @@ void clif_move(struct unit_data *ud)
WBUFW(buf,0)=0x86;
WBUFL(buf,2)=bl->id;
WBUFPOS2(buf,6,bl->x,bl->y,ud->to_x,ud->to_y,8,8);
- WBUFL(buf,12)=gettick();
+ WBUFL(buf,12)=iTimer->gettick();
clif->send(buf, packet_len(0x86), bl, AREA_WOS);
- if (disguised(bl))
- {
+ if (disguised(bl)) {
WBUFL(buf,2)=-bl->id;
clif->send(buf, packet_len(0x86), bl, SELF);
}
@@ -1637,14 +1636,14 @@ void clif_move(struct unit_data *ud)
/*==========================================
- * Delays the map_quit of a player after they are disconnected. [Skotlex]
+ * Delays the iMap->quit of a player after they are disconnected. [Skotlex]
*------------------------------------------*/
int clif_delayquit(int tid, unsigned int tick, int id, intptr_t data) {
struct map_session_data *sd = NULL;
//Remove player from map server
- if ((sd = map_id2sd(id)) != NULL && sd->fd == 0) //Should be a disconnected player.
- map_quit(sd);
+ if ((sd = iMap->id2sd(id)) != NULL && sd->fd == 0) //Should be a disconnected player.
+ iMap->quit(sd);
return 0;
}
@@ -1653,28 +1652,27 @@ int clif_delayquit(int tid, unsigned int tick, int id, intptr_t data) {
*------------------------------------------*/
void clif_quitsave(int fd,struct map_session_data *sd) {
if (!battle_config.prevent_logout ||
- DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout)
- map_quit(sd);
+ DIFF_TICK(iTimer->gettick(), sd->canlog_tick) > battle_config.prevent_logout)
+ iMap->quit(sd);
else if (sd->fd) {
//Disassociate session from player (session is deleted after this function was called)
//And set a timer to make him quit later.
session[sd->fd]->session_data = NULL;
sd->fd = 0;
- add_timer(gettick() + 10000, clif->delayquit, sd->bl.id, 0);
+ iTimer->add_timer(iTimer->gettick() + 10000, clif->delayquit, sd->bl.id, 0);
}
}
/// Notifies the client of a position change to coordinates on given map (ZC_NPCACK_MAPMOVE).
/// 0091 <map name>.16B <x>.W <y>.W
-void clif_changemap(struct map_session_data *sd, short map, int x, int y)
-{
+void clif_changemap(struct map_session_data *sd, short m, int x, int y) {
int fd;
nullpo_retv(sd);
fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x91));
WFIFOW(fd,0) = 0x91;
- mapindex_getmapname_ext(mapindex_id2name(map), (char*)WFIFOP(fd,2));
+ mapindex_getmapname_ext(map[m].cName ? map[m].cName : map[m].name, (char*)WFIFOP(fd,2));
WFIFOW(fd,18) = x;
WFIFOW(fd,20) = y;
WFIFOSET(fd,packet_len(0x91));
@@ -1683,8 +1681,7 @@ void clif_changemap(struct map_session_data *sd, short map, int x, int y)
/// Notifies the client of a position change to coordinates on given map, which is on another map-server (ZC_NPCACK_SERVERMOVE).
/// 0092 <map name>.16B <x>.W <y>.W <ip>.L <port>.W
-void clif_changemapserver(struct map_session_data* sd, unsigned short map_index, int x, int y, uint32 ip, uint16 port)
-{
+void clif_changemapserver(struct map_session_data* sd, unsigned short map_index, int x, int y, uint32 ip, uint16 port) {
int fd;
nullpo_retv(sd);
fd = sd->fd;
@@ -1762,12 +1759,12 @@ void clif_buylist(struct map_session_data *sd, struct npc_data *nd)
c = 0;
for( i = 0; i < nd->u.shop.count; i++ )
{
- struct item_data* id = itemdb_exists(nd->u.shop.shop_item[i].nameid);
+ struct item_data* id = itemdb->exists(nd->u.shop.shop_item[i].nameid);
int val = nd->u.shop.shop_item[i].value;
if( id == NULL )
continue;
WFIFOL(fd, 4+c*11) = val;
- WFIFOL(fd, 8+c*11) = pc_modifybuyvalue(sd,val);
+ WFIFOL(fd, 8+c*11) = pc->modifybuyvalue(sd,val);
WFIFOB(fd,12+c*11) = itemtype(id->type);
WFIFOW(fd,13+c*11) = ( id->view_id > 0 ) ? id->view_id : id->nameid;
c++;
@@ -1810,7 +1807,7 @@ void clif_selllist(struct map_session_data *sd)
{
if( sd->status.inventory[i].nameid > 0 && sd->inventory_data[i] )
{
- if( !itemdb_cansell(&sd->status.inventory[i], pc_get_group_level(sd)) )
+ if( !itemdb_cansell(&sd->status.inventory[i], pc->get_group_level(sd)) )
continue;
if( sd->status.inventory[i].expire_time )
@@ -1821,7 +1818,7 @@ void clif_selllist(struct map_session_data *sd)
continue;
WFIFOW(fd,4+c*10)=i+2;
WFIFOL(fd,6+c*10)=val;
- WFIFOL(fd,10+c*10)=pc_modifysellvalue(sd,val);
+ WFIFOL(fd,10+c*10)=pc->modifysellvalue(sd,val);
c++;
}
}
@@ -1838,11 +1835,12 @@ void clif_selllist(struct map_session_data *sd)
/// - set npcid of dialog window (0 by default)
/// - if set to clear on next mes, clear contents
/// - append this text
-void clif_scriptmes(struct map_session_data *sd, int npcid, const char *mes)
-{
+void clif_scriptmes(struct map_session_data *sd, int npcid, const char *mes) {
int fd = sd->fd;
int slen = strlen(mes) + 9;
+ sd->state.dialog = 1;
+
WFIFOHEAD(fd, slen);
WFIFOW(fd,0)=0xb4;
WFIFOW(fd,2)=slen;
@@ -1955,7 +1953,7 @@ void clif_scriptmenu(struct map_session_data* sd, int npcid, const char* mes)
int slen = strlen(mes) + 9;
struct block_list *bl = NULL;
- if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
+ if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m ||
bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
clif->sendfakenpc(sd, npcid);
@@ -1987,7 +1985,7 @@ void clif_scriptinput(struct map_session_data *sd, int npcid)
nullpo_retv(sd);
- if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
+ if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m ||
bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
clif->sendfakenpc(sd, npcid);
@@ -2018,7 +2016,7 @@ void clif_scriptinputstr(struct map_session_data *sd, int npcid)
nullpo_retv(sd);
- if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
+ if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m ||
bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
clif->sendfakenpc(sd, npcid);
@@ -2236,7 +2234,7 @@ void clif_additem(struct map_session_data *sd, int n, int amount, int fail) {
p.IsDamaged = sd->status.inventory[n].attribute;
p.refiningLevel =sd->status.inventory[n].refine;
clif->addcards2(&p.slot.card[0], &sd->status.inventory[n]);
- p.location = pc_equippoint(sd,n);
+ p.location = pc->equippoint(sd,n);
p.type = itemtype(sd->inventory_data[n]->type);
#if PACKETVER >= 20061218
p.HireExpireDate = sd->status.inventory[n].expire_time;
@@ -2356,7 +2354,7 @@ void clif_inventorylist(struct map_session_data *sd) {
if( !itemdb_isstackable2(sd->inventory_data[i]) )
{ //Non-stackable (Equippable)
WBUFW(bufe,ne*se+4)=i+2;
- clif->item_sub(bufe, ne*se+6, &sd->status.inventory[i], sd->inventory_data[i], pc_equippoint(sd,i));
+ clif->item_sub(bufe, ne*se+6, &sd->status.inventory[i], sd->inventory_data[i], pc->equippoint(sd,i));
clif->addcards(WBUFP(bufe, ne*se+16), &sd->status.inventory[i]);
#if PACKETVER >= 20071002
WBUFL(bufe,ne*se+24)=sd->status.inventory[i].expire_time;
@@ -2446,7 +2444,7 @@ void clif_equiplist(struct map_session_data *sd)
continue;
//Equippable
WBUFW(buf,n*cmd+4)=i+2;
- clif->item_sub(buf, n*cmd+6, &sd->status.inventory[i], sd->inventory_data[i], pc_equippoint(sd,i));
+ clif->item_sub(buf, n*cmd+6, &sd->status.inventory[i], sd->inventory_data[i], pc->equippoint(sd,i));
clif->addcards(WBUFP(buf, n*cmd+16), &sd->status.inventory[i]);
#if PACKETVER >= 20071002
WBUFL(buf,n*cmd+24)=sd->status.inventory[i].expire_time;
@@ -2499,7 +2497,7 @@ void clif_storagelist(struct map_session_data* sd, struct item* items, int items
{
if( items[i].nameid <= 0 )
continue;
- id = itemdb_search(items[i].nameid);
+ id = itemdb->search(items[i].nameid);
if( !itemdb_isstackable2(id) )
{ //Equippable
WBUFW(bufe,ne*cmd+4)=i+1;
@@ -2579,7 +2577,7 @@ void clif_cartlist(struct map_session_data *sd)
{
if( sd->status.cart[i].nameid <= 0 )
continue;
- id = itemdb_search(sd->status.cart[i].nameid);
+ id = itemdb->search(sd->status.cart[i].nameid);
if( !itemdb_isstackable2(id) )
{ //Equippable
WBUFW(bufe,ne*cmd+4)=i+2;
@@ -2748,6 +2746,9 @@ void read_channels_config(void) {
} else {
unsigned char d = 0, dlen = strlen(irc_server);
char server[40];
+
+ memset(server, '\0', sizeof(server));
+
for(d = 0; d < dlen; d++) {
if(irc_server[d] == ':') {
memcpy(server, irc_server, d);
@@ -2763,7 +2764,7 @@ void read_channels_config(void) {
ShowWarning("channels.conf : irc channel enabled but irc_channel_network wasn't found, disabling irc channel...\n");
}
if( config_setting_lookup_string(settings, "irc_channel_channel", &irc_channel) )
- safestrncpy(hChSys.irc_channel, irc_channel, 20);
+ safestrncpy(hChSys.irc_channel, irc_channel, 50);
else {
hChSys.irc = false;
ShowWarning("channels.conf : irc channel enabled but irc_channel_channel wasn't found, disabling irc channel...\n");
@@ -2772,7 +2773,7 @@ void read_channels_config(void) {
if( strcmpi(irc_nick,"Hercules_chSysBot") == 0 ) {
sprintf(hChSys.irc_nick, "Hercules_chSysBot%d",rand()%777);
} else
- safestrncpy(hChSys.irc_nick, irc_nick, 30);
+ safestrncpy(hChSys.irc_nick, irc_nick, 40);
} else {
hChSys.irc = false;
ShowWarning("channels.conf : irc channel enabled but irc_channel_nick wasn't found, disabling irc channel...\n");
@@ -2950,7 +2951,7 @@ int clif_hpmeter_sub(struct block_list *bl, va_list ap) {
*------------------------------------------*/
int clif_hpmeter(struct map_session_data *sd) {
nullpo_ret(sd);
- map_foreachinarea(clif->hpmeter_sub, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd);
+ iMap->foreachinarea(clif->hpmeter_sub, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd);
return 0;
}
@@ -2980,9 +2981,9 @@ void clif_updatestatus(struct map_session_data *sd,int type)
switch(type){
// 00b0
case SP_WEIGHT:
- pc_updateweightstatus(sd);
+ pc->updateweightstatus(sd);
WFIFOHEAD(fd,14);
- WFIFOW(fd,0)=0xb0; //Need to re-set as pc_updateweightstatus can alter the buffer. [Skotlex]
+ WFIFOW(fd,0)=0xb0; //Need to re-set as pc->updateweightstatus can alter the buffer. [Skotlex]
WFIFOW(fd,2)=type;
WFIFOL(fd,4)=sd->weight;
break;
@@ -3092,11 +3093,11 @@ void clif_updatestatus(struct map_session_data *sd,int type)
break;
case SP_NEXTBASEEXP:
WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=pc_nextbaseexp(sd);
+ WFIFOL(fd,4)=pc->nextbaseexp(sd);
break;
case SP_NEXTJOBEXP:
WFIFOW(fd,0)=0xb1;
- WFIFOL(fd,4)=pc_nextjobexp(sd);
+ WFIFOL(fd,4)=pc->nextjobexp(sd);
break;
/**
@@ -3109,7 +3110,7 @@ void clif_updatestatus(struct map_session_data *sd,int type)
case SP_UDEX:
case SP_ULUK:
WFIFOW(fd,0)=0xbe;
- WFIFOB(fd,4)=pc_need_status_point(sd,type-SP_USTR+SP_STR,1);
+ WFIFOB(fd,4)=pc->need_status_point(sd,type-SP_USTR+SP_STR,1);
len=5;
break;
@@ -3406,17 +3407,17 @@ void clif_initialstatus(struct map_session_data *sd) {
WBUFW(buf,0)=0xbd;
WBUFW(buf,2)=min(sd->status.status_point, INT16_MAX);
WBUFB(buf,4)=min(sd->status.str, UINT8_MAX);
- WBUFB(buf,5)=pc_need_status_point(sd,SP_STR,1);
+ WBUFB(buf,5)=pc->need_status_point(sd,SP_STR,1);
WBUFB(buf,6)=min(sd->status.agi, UINT8_MAX);
- WBUFB(buf,7)=pc_need_status_point(sd,SP_AGI,1);
+ WBUFB(buf,7)=pc->need_status_point(sd,SP_AGI,1);
WBUFB(buf,8)=min(sd->status.vit, UINT8_MAX);
- WBUFB(buf,9)=pc_need_status_point(sd,SP_VIT,1);
+ WBUFB(buf,9)=pc->need_status_point(sd,SP_VIT,1);
WBUFB(buf,10)=min(sd->status.int_, UINT8_MAX);
- WBUFB(buf,11)=pc_need_status_point(sd,SP_INT,1);
+ WBUFB(buf,11)=pc->need_status_point(sd,SP_INT,1);
WBUFB(buf,12)=min(sd->status.dex, UINT8_MAX);
- WBUFB(buf,13)=pc_need_status_point(sd,SP_DEX,1);
+ WBUFB(buf,13)=pc->need_status_point(sd,SP_DEX,1);
WBUFB(buf,14)=min(sd->status.luk, UINT8_MAX);
- WBUFB(buf,15)=pc_need_status_point(sd,SP_LUK,1);
+ WBUFB(buf,15)=pc->need_status_point(sd,SP_LUK,1);
WBUFW(buf,16) = pc_leftside_atk(sd);
WBUFW(buf,18) = pc_rightside_atk(sd);
@@ -3461,7 +3462,9 @@ void clif_arrowequip(struct map_session_data *sd,int val)
nullpo_retv(sd);
pc_stop_attack(sd); // [Valaris]
-
+#if PACKETVER >= 20121128
+ clif->status_change(&sd->bl, SI_CLIENT_ONLY_EQUIP_ARROW, 1, INVALID_TIMER, 0, 0, 0);
+#endif
fd=sd->fd;
WFIFOHEAD(fd, packet_len(0x013c));
WFIFOW(fd,0)=0x013c;
@@ -3508,7 +3511,7 @@ void clif_arrow_create_list(struct map_session_data *sd)
for (i = 0, c = 0; i < MAX_SKILL_ARROW_DB; i++) {
if (skill_arrow_db[i].nameid > 0 &&
- (j = pc_search_inventory(sd, skill_arrow_db[i].nameid)) >= 0 &&
+ (j = pc->search_inventory(sd, skill_arrow_db[i].nameid)) >= 0 &&
!sd->status.inventory[j].equip && sd->status.inventory[j].identify)
{
if ((j = itemdb_viewid(skill_arrow_db[i].nameid)) > 0)
@@ -3639,16 +3642,17 @@ void clif_changeoption(struct block_list* bl)
struct map_session_data* sd;
nullpo_retv(bl);
- sc = status_get_sc(bl);
- if (!sc) return; //How can an option change if there's no sc?
+
+ if ( !(sc = status_get_sc(bl)) && bl->type != BL_NPC ) return; //How can an option change if there's no sc?
+
sd = BL_CAST(BL_PC, bl);
#if PACKETVER >= 7
WBUFW(buf,0) = 0x229;
WBUFL(buf,2) = bl->id;
- WBUFW(buf,6) = sc->opt1;
- WBUFW(buf,8) = sc->opt2;
- WBUFL(buf,10) = sc->option;
+ WBUFW(buf,6) = (sc) ? sc->opt1 : 0;
+ WBUFW(buf,8) = (sc) ? sc->opt2 : 0;
+ WBUFL(buf,10) = (sc) ? sc->option : bl->type == BL_NPC ? ((TBL_NPC*)bl)->option : 0;
WBUFB(buf,14) = (sd)? sd->status.karma : 0;
if(disguised(bl)) {
clif->send(buf,packet_len(0x229),bl,AREA_WOS);
@@ -3662,9 +3666,9 @@ void clif_changeoption(struct block_list* bl)
#else
WBUFW(buf,0) = 0x119;
WBUFL(buf,2) = bl->id;
- WBUFW(buf,6) = sc->opt1;
- WBUFW(buf,8) = sc->opt2;
- WBUFW(buf,10) = sc->option;
+ WBUFW(buf,6) = (sc) ? sc->opt1 : 0;
+ WBUFW(buf,8) = (sc) ? sc->opt2 : 0;
+ WBUFL(buf,10) = (sc) ? sc->option : bl->type == BL_NPC ? ((TBL_NPC*)bl)->option : 0;
WBUFB(buf,12) = (sd)? sd->status.karma : 0;
if(disguised(bl)) {
clif->send(buf,packet_len(0x119),bl,AREA_WOS);
@@ -3681,19 +3685,17 @@ void clif_changeoption(struct block_list* bl)
/// Displays status change effects on NPCs/monsters (ZC_NPC_SHOWEFST_UPDATE).
/// 028a <id>.L <effect state>.L <level>.L <showEFST>.L
-void clif_changeoption2(struct block_list* bl)
-{
+void clif_changeoption2(struct block_list* bl) {
unsigned char buf[20];
struct status_change *sc;
- sc = status_get_sc(bl);
- if (!sc) return; //How can an option change if there's no sc?
+ if ( !(sc = status_get_sc(bl)) && bl->type != BL_NPC ) return; //How can an option change if there's no sc?
WBUFW(buf,0) = 0x28a;
WBUFL(buf,2) = bl->id;
- WBUFL(buf,6) = sc->option;
+ WBUFL(buf,6) = (sc) ? sc->option : bl->type == BL_NPC ? ((TBL_NPC*)bl)->option : 0;
WBUFL(buf,10) = clif_setlevel(bl);
- WBUFL(buf,14) = sc->opt3;
+ WBUFL(buf,14) = (sc) ? sc->opt3 : 0;
if(disguised(bl)) {
clif->send(buf,packet_len(0x28a),bl,AREA_WOS);
WBUFL(buf,2) = -bl->id;
@@ -3749,7 +3751,7 @@ void clif_useitemack(struct map_session_data *sd,int index,int amount,bool ok)
}
void clif_hercules_chsys_send(struct hChSysCh *channel, struct map_session_data *sd, char *msg) {
- if( channel->msg_delay != 0 && DIFF_TICK(sd->hchsysch_tick + ( channel->msg_delay * 1000 ), gettick()) > 0 && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) {
+ if( channel->msg_delay != 0 && DIFF_TICK(sd->hchsysch_tick + ( channel->msg_delay * 1000 ), iTimer->gettick()) > 0 && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) {
clif->colormes(sd->fd,COLOR_RED,msg_txt(1455));
return;
} else {
@@ -3759,7 +3761,7 @@ void clif_hercules_chsys_send(struct hChSysCh *channel, struct map_session_data
if( channel->type == hChSys_IRC )
ircbot->relay(sd->status.name,msg);
if( channel->msg_delay != 0 )
- sd->hchsysch_tick = gettick();
+ sd->hchsysch_tick = iTimer->gettick();
}
}
@@ -4012,7 +4014,7 @@ void clif_traderequest(struct map_session_data* sd, const char* name)
safestrncpy((char*)WFIFOP(fd,2), name, NAME_LENGTH);
WFIFOSET(fd,packet_len(0xe5));
#else
- struct map_session_data* tsd = map_id2sd(sd->trade_partner);
+ struct map_session_data* tsd = iMap->id2sd(sd->trade_partner);
if( !tsd ) return;
WFIFOHEAD(fd,packet_len(0x1f4));
@@ -4038,7 +4040,7 @@ void clif_traderequest(struct map_session_data* sd, const char* name)
void clif_tradestart(struct map_session_data* sd, uint8 type)
{
int fd = sd->fd;
- struct map_session_data* tsd = map_id2sd(sd->trade_partner);
+ struct map_session_data* tsd = iMap->id2sd(sd->trade_partner);
if( PACKETVER < 6 || !tsd ) {
WFIFOHEAD(fd,packet_len(0xe7));
WFIFOW(fd,0) = 0xe7;
@@ -4300,7 +4302,7 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds
if( dstsd->chatID ) {
struct chat_data *cd = NULL;
- if( (cd = (struct chat_data*)map_id2bl(dstsd->chatID)) && cd->usersd[0]==dstsd)
+ if( (cd = (struct chat_data*)iMap->id2bl(dstsd->chatID)) && cd->usersd[0]==dstsd)
clif->dispchat(cd,sd->fd);
} else if( dstsd->state.vending )
clif->showvendingboard(&dstsd->bl,dstsd->message,sd->fd);
@@ -4310,8 +4312,8 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds
if(dstsd->spiritball > 0)
clif->spiritball_single(sd->fd, dstsd);
for(i = 1; i < 5; i++){
- if( dstsd->talisman[i] > 0 )
- clif->talisman_single(sd->fd, dstsd, i);
+ if( dstsd->charm[i] > 0 )
+ clif->charm_single(sd->fd, dstsd, i);
}
for( i = 0; i < dstsd->sc_display_count; i++ ) {
clif->sc_load(&sd->bl,dstsd->bl.id,SELF,StatusIconChangeTable[dstsd->sc_display[i]->type],dstsd->sc_display[i]->val1,dstsd->sc_display[i]->val2,dstsd->sc_display[i]->val3);
@@ -4329,7 +4331,7 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds
ARR_FIND( 0, 5, i, dstsd->devotion[i] > 0 );
if( i < 5 ) clif->devotion(&dstsd->bl, sd);
// display link (dstsd - crusader) to sd
- if( dstsd->sc.data[SC_DEVOTION] && (d_bl = map_id2bl(dstsd->sc.data[SC_DEVOTION]->val1)) != NULL )
+ if( dstsd->sc.data[SC_DEVOTION] && (d_bl = iMap->id2bl(dstsd->sc.data[SC_DEVOTION]->val1)) != NULL )
clif->devotion(d_bl, sd);
}
@@ -4344,7 +4346,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) {
/**
* Hide NPC from maya purple card.
**/
- if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE))
+ if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->option&OPTION_INVISIBLE))
return;
if ( ( ud = unit_bl2ud(bl) ) && ud->walktimer != INVALID_TIMER )
@@ -4377,7 +4379,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) {
{
TBL_NPC* nd = (TBL_NPC*)bl;
if( nd->chat_id )
- clif->dispchat((struct chat_data*)map_id2bl(nd->chat_id),sd->fd);
+ clif->dispchat((struct chat_data*)iMap->id2bl(nd->chat_id),sd->fd);
if( nd->size == SZ_BIG )
clif->specialeffect_single(bl,423,sd->fd);
else if( nd->size == SZ_MEDIUM )
@@ -4472,9 +4474,9 @@ int clif_damage(struct block_list* src, struct block_list* dst, unsigned int tic
type = clif_calc_delay(type,div,damage+damage2,ddelay);
sc = status_get_sc(dst);
if(sc && sc->count) {
- if(sc->data[SC_HALLUCINATION]) {
- if(damage) damage = damage*(sc->data[SC_HALLUCINATION]->val2) + rnd()%100;
- if(damage2) damage2 = damage2*(sc->data[SC_HALLUCINATION]->val2) + rnd()%100;
+ if(sc->data[SC_ILLUSION]) {
+ if(damage) damage = damage*(sc->data[SC_ILLUSION]->val2) + rnd()%100;
+ if(damage2) damage2 = damage2*(sc->data[SC_ILLUSION]->val2) + rnd()%100;
}
}
@@ -4601,16 +4603,13 @@ void clif_changemapcell(int fd, int16 m, int x, int y, int type, enum send_targe
WBUFW(buf,2) = x;
WBUFW(buf,4) = y;
WBUFW(buf,6) = type;
- mapindex_getmapname_ext(map[m].name,(char*)WBUFP(buf,8));
+ mapindex_getmapname_ext(map[m].cName ? map[m].cName : map[m].name,(char*)WBUFP(buf,8));
- if( fd )
- {
+ if( fd ) {
WFIFOHEAD(fd,packet_len(0x192));
memcpy(WFIFOP(fd,0), buf, packet_len(0x192));
WFIFOSET(fd,packet_len(0x192));
- }
- else
- {
+ } else {
struct block_list dummy_bl;
dummy_bl.type = BL_NUL;
dummy_bl.x = x;
@@ -4647,12 +4646,21 @@ void clif_getareachar_item(struct map_session_data* sd,struct flooritem_data* fi
/// Notifies the client of a skill unit.
/// 011f <id>.L <creator id>.L <x>.W <y>.W <unit id>.B <visible>.B (ZC_SKILL_ENTRY)
/// 01c9 <id>.L <creator id>.L <x>.W <y>.W <unit id>.B <visible>.B <has msg>.B <msg>.80B (ZC_SKILL_ENTRY2)
+/// 08c7 <lenght>.W <id> L <creator id>.L <x>.W <y>.W <unit id>.B <range>.W <visible>.B (ZC_SKILL_ENTRY3)
+/// 099f <lenght>.W <id> L <creator id>.L <x>.W <y>.W <unit id>.L <range>.W <visible>.B (ZC_SKILL_ENTRY4)
void clif_getareachar_skillunit(struct map_session_data *sd, struct skill_unit *unit) {
- int fd = sd->fd;
+ int fd = sd->fd, header = 0x11f, pos=0;
if( unit->group->state.guildaura )
return;
+#if PACKETVER >= 20130320
+ if(unit->group->unit_id > UCHAR_MAX){
+ header = 0x99f;
+ pos = 2;
+ }
+#endif
+
#if PACKETVER >= 3
if(unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris]
WFIFOHEAD(fd,packet_len(0x1c9));
@@ -4669,20 +4677,26 @@ void clif_getareachar_skillunit(struct map_session_data *sd, struct skill_unit *
return;
}
#endif
- WFIFOHEAD(fd,packet_len(0x11f));
- WFIFOW(fd, 0)=0x11f;
- WFIFOL(fd, 2)=unit->bl.id;
- WFIFOL(fd, 6)=unit->group->src_id;
- WFIFOW(fd,10)=unit->bl.x;
- WFIFOW(fd,12)=unit->bl.y;
+ WFIFOHEAD(fd,packet_len(header));
+ WFIFOW(fd, 0)=header;
+ if(pos > 0)
+ WFIFOL(fd, pos)=packet_len(header);
+ WFIFOL(fd, 2 + pos)=unit->bl.id;
+ WFIFOL(fd, 6 + pos)=unit->group->src_id;
+ WFIFOW(fd,10 + pos)=unit->bl.x;
+ WFIFOW(fd,12 + pos)=unit->bl.y;
if (battle_config.traps_setting&1 && skill->get_inf2(unit->group->skill_id)&INF2_TRAP)
WFIFOB(fd,14)=UNT_DUMMYSKILL; //Use invisible unit id for traps.
else if (skill->get_unit_flag(unit->group->skill_id) & UF_RANGEDSINGLEUNIT && !(unit->val2 & UF_RANGEDSINGLEUNIT))
WFIFOB(fd,14)=UNT_DUMMYSKILL; //Use invisible unit id for traps.
- else
+ else if(pos > 0){
+ WFIFOL(fd,16)=unit->group->unit_id;
+ WFIFOW(fd,20)=unit->range;
+ pos += 5;
+ }else
WFIFOB(fd,14)=unit->group->unit_id;
- WFIFOB(fd,15)=1; // ignored by client (always gets set to 1)
- WFIFOSET(fd,packet_len(0x11f));
+ WFIFOB(fd,15 + pos)=1; // ignored by client (always gets set to 1)
+ WFIFOSET(fd,packet_len(header));
if(unit->group->skill_id == WZ_ICEWALL)
clif->changemapcell(fd,unit->bl.m,unit->bl.x,unit->bl.y,5,SELF);
@@ -4783,7 +4797,7 @@ int clif_outsight(struct block_list *bl,va_list ap)
clif->clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd);
if(sd->chatID){
struct chat_data *cd;
- cd=(struct chat_data*)map_id2bl(sd->chatID);
+ cd=(struct chat_data*)iMap->id2bl(sd->chatID);
if(cd->usersd[0]==sd)
clif->dispchat(cd,tsd->fd);
}
@@ -4799,7 +4813,7 @@ int clif_outsight(struct block_list *bl,va_list ap)
clif->clearchar_skillunit((struct skill_unit *)bl,tsd->fd);
break;
case BL_NPC:
- if( !(((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE) )
+ if( !(((TBL_NPC*)bl)->option&OPTION_INVISIBLE) )
clif->clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd);
break;
default:
@@ -4810,7 +4824,7 @@ int clif_outsight(struct block_list *bl,va_list ap)
}
if (sd && sd->fd) { //sd is watching tbl go out of view.
if (((vd=status_get_viewdata(tbl)) && vd->class_ != INVISIBLE_CLASS) &&
- !(tbl->type == BL_NPC && (((TBL_NPC*)tbl)->sc.option&OPTION_INVISIBLE)))
+ !(tbl->type == BL_NPC && (((TBL_NPC*)tbl)->option&OPTION_INVISIBLE)))
clif->clearunit_single(tbl->id,CLR_OUTSIGHT,sd->fd);
}
return 0;
@@ -5138,8 +5152,8 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int
type = clif_calc_delay(type,div,damage,ddelay);
sc = status_get_sc(dst);
if(sc && sc->count) {
- if(sc->data[SC_HALLUCINATION] && damage)
- damage = damage*(sc->data[SC_HALLUCINATION]->val2) + rnd()%100;
+ if(sc->data[SC_ILLUSION] && damage)
+ damage = damage*(sc->data[SC_ILLUSION]->val2) + rnd()%100;
}
#if PACKETVER < 3
@@ -5227,8 +5241,8 @@ int clif_skill_damage2(struct block_list *src,struct block_list *dst,unsigned in
sc = status_get_sc(dst);
if(sc && sc->count) {
- if(sc->data[SC_HALLUCINATION] && damage)
- damage = damage*(sc->data[SC_HALLUCINATION]->val2) + rnd()%100;
+ if(sc->data[SC_ILLUSION] && damage)
+ damage = damage*(sc->data[SC_ILLUSION]->val2) + rnd()%100;
}
WBUFW(buf,0)=0x115;
@@ -5334,12 +5348,20 @@ void clif_skill_poseffect(struct block_list *src,uint16 skill_id,int val,int x,i
void clif_skill_setunit(struct skill_unit *unit)
{
unsigned char buf[128];
+ int header = 0x11f, pos = 0;
nullpo_retv(unit);
if( unit->group->state.guildaura )
return;
+#if PACKETVER >= 20130320
+ if(unit->group->unit_id > UCHAR_MAX){
+ header = 0x99f;
+ pos = 2;
+ }
+#endif
+
#if PACKETVER >= 3
if(unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris]
WBUFW(buf, 0)=0x1c9;
@@ -5355,19 +5377,25 @@ void clif_skill_setunit(struct skill_unit *unit)
return;
}
#endif
- WBUFW(buf, 0)=0x11f;
- WBUFL(buf, 2)=unit->bl.id;
- WBUFL(buf, 6)=unit->group->src_id;
- WBUFW(buf,10)=unit->bl.x;
- WBUFW(buf,12)=unit->bl.y;
+ WBUFW(buf, 0)=header;
+ if(pos > 0)
+ WBUFW(buf, pos)=packet_len(header);
+ WBUFL(buf, 2 + pos)=unit->bl.id;
+ WBUFL(buf, 6 + pos)=unit->group->src_id;
+ WBUFW(buf,10 + pos)=unit->bl.x;
+ WBUFW(buf,12 + pos)=unit->bl.y;
if (unit->group->state.song_dance&0x1 && unit->val2&UF_ENSEMBLE)
WBUFB(buf,14)=unit->val2&UF_SONG?UNT_DISSONANCE:UNT_UGLYDANCE;
else if (skill->get_unit_flag(unit->group->skill_id) & UF_RANGEDSINGLEUNIT && !(unit->val2 & UF_RANGEDSINGLEUNIT))
WBUFB(buf, 14) = UNT_DUMMYSKILL; // Only display the unit at center.
- else
+ else if(pos > 0){
+ WBUFL(buf,16)=unit->group->unit_id;
+ WBUFW(buf,20)=unit->range;
+ pos += 5;
+ }else
WBUFB(buf,14)=unit->group->unit_id;
- WBUFB(buf,15)=1; // ignored by client (always gets set to 1)
- clif->send(buf,packet_len(0x11f),&unit->bl,AREA);
+ WBUFB(buf,15 + pos)=1; // ignored by client (always gets set to 1)
+ clif->send(buf,packet_len(header),&unit->bl,AREA);
}
@@ -5392,9 +5420,10 @@ void clif_skill_warppoint(struct map_session_data* sd, uint16 skill_id, uint16 s
WFIFOSET(fd,packet_len(0x11c));
sd->menuskill_id = skill_id;
- if (skill_id == AL_WARP)
+ if (skill_id == AL_WARP){
sd->menuskill_val = (sd->ud.skillx<<16)|sd->ud.skilly; //Store warp position here.
- else
+ sd->state.workinprogress = 3;
+ }else
sd->menuskill_val = skill_lv;
}
@@ -5427,10 +5456,11 @@ void clif_skill_memomessage(struct map_session_data* sd, int type)
/// type:
/// 0 = "Unable to Teleport in this area" in color 0xFFFF00 (cyan)
/// 1 = "Saved point cannot be memorized." in color 0x0000FF (red)
+/// 2 = "This skill cannot be used within this area." in color 0xFFFF00 (cyan)
///
/// @param sd Who receives the message
/// @param type What message
-void clif_skill_teleportmessage(struct map_session_data *sd, int type)
+void clif_skill_mapinfomessage(struct map_session_data *sd, int type)
{
int fd;
@@ -5625,6 +5655,9 @@ void clif_status_change(struct block_list *bl,int type,int flag,int tick,int val
if (!(status_type2relevant_bl_types(type)&bl->type)) // only send status changes that actually matter to the client
return;
+ if ( tick < 0 )
+ tick = 9999;
+
sd = BL_CAST(BL_PC, bl);
p.PacketType = status_changeType;
@@ -5931,12 +5964,13 @@ void clif_wis_message(int fd, const char* nick, const char* mes, int mes_len)
safestrncpy((char*)WFIFOP(fd,28), mes, mes_len);
WFIFOSET(fd,WFIFOW(fd,2));
#else
+ struct map_session_data *ssd = iMap->nick2sd(nick);
+
WFIFOHEAD(fd, mes_len + NAME_LENGTH + 8);
WFIFOW(fd,0) = 0x97;
WFIFOW(fd,2) = mes_len + NAME_LENGTH + 8;
safestrncpy((char*)WFIFOP(fd,4), nick, NAME_LENGTH);
- WFIFOL(fd,28) = 0; // isAdmin; if nonzero, also displays text above char
- // TODO: WFIFOL(fd,28) = pc_get_group_level(ssd);
+ WFIFOL(fd,28) = (ssd && pc->get_group_level(ssd) == 99) ? 1 : 0; // isAdmin; if nonzero, also displays text above char
safestrncpy((char*)WFIFOP(fd,32), mes, mes_len);
WFIFOSET(fd,WFIFOW(fd,2));
#endif
@@ -6065,6 +6099,7 @@ void clif_item_identify_list(struct map_session_data *sd)
WFIFOSET(fd,WFIFOW(fd,2));
sd->menuskill_id = MC_IDENTIFY;
sd->menuskill_val = c;
+ sd->state.workinprogress = 3;
}
}
@@ -6167,25 +6202,20 @@ void clif_item_refine_list(struct map_session_data *sd)
int fd;
uint16 skill_lv;
int wlv;
- int refine_item[5];
nullpo_retv(sd);
- skill_lv = pc_checkskill(sd,WS_WEAPONREFINE);
+ skill_lv = pc->checkskill(sd,WS_WEAPONREFINE);
fd=sd->fd;
-
- refine_item[0] = -1;
- refine_item[1] = pc_search_inventory(sd,1010);
- refine_item[2] = pc_search_inventory(sd,1011);
- refine_item[3] = refine_item[4] = pc_search_inventory(sd,984);
-
+
WFIFOHEAD(fd, MAX_INVENTORY * 13 + 4);
WFIFOW(fd,0)=0x221;
for(i=c=0;i<MAX_INVENTORY;i++){
- if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].refine < skill_lv &&
- sd->status.inventory[i].identify && (wlv=itemdb_wlv(sd->status.inventory[i].nameid)) >=1 &&
- refine_item[wlv]!=-1 && !(sd->status.inventory[i].equip&EQP_ARMS)){
+ if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify
+ && (wlv=itemdb_wlv(sd->status.inventory[i].nameid)) >=1
+ && !sd->inventory_data[i]->flag.no_refine
+ && !(sd->status.inventory[i].equip&EQP_ARMS)){
WFIFOW(fd,c*13+ 4)=i+2;
WFIFOW(fd,c*13+ 6)=sd->status.inventory[i].nameid;
WFIFOB(fd,c*13+ 8)=sd->status.inventory[i].refine;
@@ -6370,7 +6400,7 @@ void clif_vendinglist(struct map_session_data* sd, unsigned int id, struct s_ven
nullpo_retv(sd);
nullpo_retv(vending);
- nullpo_retv(vsd=map_id2sd(id));
+ nullpo_retv(vsd=iMap->id2sd(id));
fd = sd->fd;
count = vsd->vend_num;
@@ -6386,7 +6416,7 @@ void clif_vendinglist(struct map_session_data* sd, unsigned int id, struct s_ven
for( i = 0; i < count; i++ )
{
int index = vending[i].index;
- struct item_data* data = itemdb_search(vsd->status.cart[index].nameid);
+ struct item_data* data = itemdb->search(vsd->status.cart[index].nameid);
WFIFOL(fd,offset+ 0+i*22) = vending[i].value;
WFIFOW(fd,offset+ 4+i*22) = vending[i].amount;
WFIFOW(fd,offset+ 6+i*22) = vending[i].index + 2;
@@ -6445,7 +6475,7 @@ void clif_openvending(struct map_session_data* sd, int id, struct s_vending* ven
WFIFOL(fd,4) = id;
for( i = 0; i < count; i++ ) {
int index = vending[i].index;
- struct item_data* data = itemdb_search(sd->status.cart[index].nameid);
+ struct item_data* data = itemdb->search(sd->status.cart[index].nameid);
WFIFOL(fd, 8+i*22) = vending[i].value;
WFIFOW(fd,12+i*22) = vending[i].index + 2;
WFIFOW(fd,14+i*22) = vending[i].amount;
@@ -6529,7 +6559,7 @@ void clif_party_member_info(struct party_data *p, struct map_session_data *sd)
WBUFB(buf,14) = (p->party.member[i].online)?0:1;
memcpy(WBUFP(buf,15), p->party.name, NAME_LENGTH);
memcpy(WBUFP(buf,39), sd->status.name, NAME_LENGTH);
- mapindex_getmapname_ext(map[sd->bl.m].name, (char*)WBUFP(buf,63));
+ mapindex_getmapname_ext(map[sd->bl.m].cName ? map[sd->bl.m].cName : map[sd->bl.m].name, (char*)WBUFP(buf,63));
WBUFB(buf,79) = (p->party.item&1)?1:0;
WBUFB(buf,80) = (p->party.item&2)?1:0;
clif->send(buf,packet_len(0x1e9),&sd->bl,PARTY);
@@ -6614,7 +6644,7 @@ void clif_party_invite(struct map_session_data *sd,struct map_session_data *tsd)
fd=tsd->fd;
- if( (p=party_search(sd->status.party_id))==NULL )
+ if( (p=party->search(sd->status.party_id))==NULL )
return;
WFIFOHEAD(fd,packet_len(cmd));
@@ -7090,31 +7120,31 @@ void clif_autospell(struct map_session_data *sd,uint16 skill_lv)
WFIFOHEAD(fd,packet_len(0x1cd));
WFIFOW(fd, 0)=0x1cd;
- if(skill_lv>0 && pc_checkskill(sd,MG_NAPALMBEAT)>0)
+ if(skill_lv>0 && pc->checkskill(sd,MG_NAPALMBEAT)>0)
WFIFOL(fd,2)= MG_NAPALMBEAT;
else
WFIFOL(fd,2)= 0x00000000;
- if(skill_lv>1 && pc_checkskill(sd,MG_COLDBOLT)>0)
+ if(skill_lv>1 && pc->checkskill(sd,MG_COLDBOLT)>0)
WFIFOL(fd,6)= MG_COLDBOLT;
else
WFIFOL(fd,6)= 0x00000000;
- if(skill_lv>1 && pc_checkskill(sd,MG_FIREBOLT)>0)
+ if(skill_lv>1 && pc->checkskill(sd,MG_FIREBOLT)>0)
WFIFOL(fd,10)= MG_FIREBOLT;
else
WFIFOL(fd,10)= 0x00000000;
- if(skill_lv>1 && pc_checkskill(sd,MG_LIGHTNINGBOLT)>0)
+ if(skill_lv>1 && pc->checkskill(sd,MG_LIGHTNINGBOLT)>0)
WFIFOL(fd,14)= MG_LIGHTNINGBOLT;
else
WFIFOL(fd,14)= 0x00000000;
- if(skill_lv>4 && pc_checkskill(sd,MG_SOULSTRIKE)>0)
+ if(skill_lv>4 && pc->checkskill(sd,MG_SOULSTRIKE)>0)
WFIFOL(fd,18)= MG_SOULSTRIKE;
else
WFIFOL(fd,18)= 0x00000000;
- if(skill_lv>7 && pc_checkskill(sd,MG_FIREBALL)>0)
+ if(skill_lv>7 && pc->checkskill(sd,MG_FIREBALL)>0)
WFIFOL(fd,22)= MG_FIREBALL;
else
WFIFOL(fd,22)= 0x00000000;
- if(skill_lv>9 && pc_checkskill(sd,MG_FROSTDIVER)>0)
+ if(skill_lv>9 && pc->checkskill(sd,MG_FROSTDIVER)>0)
WFIFOL(fd,26)= MG_FROSTDIVER;
else
WFIFOL(fd,26)= 0x00000000;
@@ -7153,7 +7183,7 @@ void clif_devotion(struct block_list *src, struct map_session_data *tsd)
for( i = 0; i < 5; i++ )
WBUFL(buf,6+4*i) = sd->devotion[i];
- WBUFW(buf,26) = skill->get_range2(src, CR_DEVOTION, pc_checkskill(sd, CR_DEVOTION));
+ WBUFW(buf,26) = skill->get_range2(src, CR_DEVOTION, pc->checkskill(sd, CR_DEVOTION));
}
if( tsd )
@@ -8087,7 +8117,7 @@ void clif_callpartner(struct map_session_data *sd)
if( sd->status.partner_id )
{
const char *p;
- if( ( p = map_charid2nick(sd->status.partner_id) ) != NULL )
+ if( ( p = iMap->charid2nick(sd->status.partner_id) ) != NULL )
{
memcpy(WBUFP(buf,2), p, NAME_LENGTH);
}
@@ -8210,7 +8240,7 @@ void clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd)
if( fd > 0 )
clif->authfail_fd(fd, 15);
else
- map_quit(tsd);
+ iMap->quit(tsd);
if( sd )
clif->GM_kickack(sd,tsd->status.account_id);
@@ -8485,7 +8515,7 @@ void clif_refresh(struct map_session_data *sd)
int i;
nullpo_retv(sd);
- clif->changemap(sd,sd->mapindex,sd->bl.x,sd->bl.y);
+ clif->changemap(sd,sd->bl.m,sd->bl.x,sd->bl.y);
clif->inventorylist(sd);
if(pc_iscarton(sd)) {
clif->cartlist(sd);
@@ -8502,8 +8532,8 @@ void clif_refresh(struct map_session_data *sd)
if (sd->spiritball)
clif->spiritball_single(sd->fd, sd);
for(i = 1; i < 5; i++){
- if( sd->talisman[i] > 0 )
- clif->talisman_single(sd->fd, sd, i);
+ if( sd->charm[i] > 0 )
+ clif->charm_single(sd->fd, sd, i);
}
if (sd->vd.cloth_color)
clif->refreshlook(&sd->bl,sd->bl.id,LOOK_CLOTHES_COLOR,sd->vd.cloth_color,SELF);
@@ -8515,7 +8545,7 @@ void clif_refresh(struct map_session_data *sd)
}
if( sd->ed )
clif->elemental_info(sd);
- map_foreachinrange(clif->getareachar,&sd->bl,AREA_SIZE,BL_ALL,sd);
+ iMap->foreachinrange(clif->getareachar,&sd->bl,AREA_SIZE,BL_ALL,sd);
clif->weather_check(sd);
if( sd->chatID )
chat_leavechat(sd,0);
@@ -8531,12 +8561,12 @@ void clif_refresh(struct map_session_data *sd)
// unlike vending, resuming buyingstore crashes the client.
buyingstore->close(sd);
- mail_clear(sd);
+ mail->clear(sd);
if( disguised(&sd->bl) ) {/* refresh-da */
short disguise = sd->disguise;
- pc_disguise(sd, -1);
- pc_disguise(sd, disguise);
+ pc->disguise(sd, -1);
+ pc->disguise(sd, disguise);
}
}
@@ -8575,7 +8605,7 @@ void clif_charnameack (int fd, struct block_list *bl)
memcpy(WBUFP(buf,6), ssd->status.name, NAME_LENGTH);
if( ssd->status.party_id ) {
- p = party_search(ssd->status.party_id);
+ p = party->search(ssd->status.party_id);
}
if( ssd->status.guild_id ) {
if( ( g = ssd->guild ) != NULL ) {
@@ -8699,10 +8729,10 @@ void clif_charnameupdate (struct map_session_data *ssd)
if (!battle_config.display_party_name) {
if (ssd->status.party_id > 0 && ssd->status.guild_id > 0 && (g = ssd->guild) != NULL)
- p = party_search(ssd->status.party_id);
+ p = party->search(ssd->status.party_id);
}else{
if (ssd->status.party_id > 0)
- p = party_search(ssd->status.party_id);
+ p = party->search(ssd->status.party_id);
}
if( ssd->status.guild_id > 0 && (g = ssd->guild) != NULL )
@@ -8888,7 +8918,7 @@ void clif_feel_info(struct map_session_data* sd, unsigned char feel_level, unsig
void clif_hate_info(struct map_session_data *sd, unsigned char hate_level,int class_, unsigned char type)
{
if( pcdb_checkid(class_) ) {
- clif->starskill(sd, job_name(class_), class_, hate_level, type ? 10 : 11);
+ clif->starskill(sd, pc->job_name(class_), class_, hate_level, type ? 10 : 11);
} else if( mobdb_checkid(class_) ) {
clif->starskill(sd, mob_db(class_)->jname, class_, hate_level, type ? 10 : 11);
} else {
@@ -8939,7 +8969,7 @@ void clif_equiptickack(struct map_session_data* sd, int flag)
/// open equip window:
/// 0 = disabled
/// 1 = enabled
-void clif_equipcheckbox(struct map_session_data* sd)
+void clif_equpcheckbox(struct map_session_data* sd)
{
int fd;
nullpo_retv(sd);
@@ -9003,7 +9033,7 @@ void clif_viewequip_ack(struct map_session_data* sd, struct map_session_data* ts
// Inventory position
WBUFW(buf, n*s+43) = i + 2;
// Add refine, identify flag, element, etc.
- clif->item_sub(WBUFP(buf,0), n*s+45, &tsd->status.inventory[i], tsd->inventory_data[i], pc_equippoint(tsd, i));
+ clif->item_sub(WBUFP(buf,0), n*s+45, &tsd->status.inventory[i], tsd->inventory_data[i], pc->equippoint(tsd, i));
// Add cards
clif->addcards(WBUFP(buf, n*s+55), &tsd->status.inventory[i]);
// Expiration date stuff, if all of those are set to 0 then the client doesn't show anything related (6 bytes)
@@ -9252,7 +9282,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data* sd) {
}
//Check for double login.
- bl = map_id2bl(account_id);
+ bl = iMap->id2bl(account_id);
if(bl && bl->type != BL_PC) {
ShowError("clif_parse_WantToConnection: a non-player object already has id %d, please increase the starting account number\n", account_id);
WFIFOHEAD(fd,packet_len(0x6a));
@@ -9260,6 +9290,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data* sd) {
WFIFOB(fd,2) = 3; // Rejected by server
WFIFOSET(fd,packet_len(0x6a));
set_eof(fd);
+
return;
}
@@ -9273,9 +9304,11 @@ void clif_parse_WantToConnection(int fd, struct map_session_data* sd) {
CREATE(sd, TBL_PC, 1);
sd->fd = fd;
+ sd->cryptKey = (( clif->cryptKey[0] * clif->cryptKey[1] ) + clif->cryptKey[2]) & 0xFFFFFFFF;
+
session[fd]->session_data = sd;
- pc_setnewpc(sd, account_id, char_id, login_id1, client_tick, sex, fd);
+ pc->setnewpc(sd, account_id, char_id, login_id1, client_tick, sex, fd);
#if PACKETVER < 20070521
WFIFOHEAD(fd,4);
@@ -9321,18 +9354,19 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
return;
if (!sd->state.active) { //Character loading is not complete yet!
- //Let pc_reg_received reinvoke this when ready.
+ //Let pc->reg_received reinvoke this when ready.
sd->state.connect_new = 0;
return;
}
if (sd->state.rewarp) { //Rewarp player.
sd->state.rewarp = 0;
- clif->changemap(sd, sd->mapindex, sd->bl.x, sd->bl.y);
+ clif->changemap(sd, sd->bl.m, sd->bl.x, sd->bl.y);
return;
}
sd->state.warping = 0;
+ sd->state.dialog = 0;/* reset when warping, client dialog will go missing */
// look
#if PACKETVER < 4
@@ -9345,8 +9379,8 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
if(sd->vd.cloth_color)
clif->refreshlook(&sd->bl,sd->bl.id,LOOK_CLOTHES_COLOR,sd->vd.cloth_color,SELF);
// item
- clif->inventorylist(sd); // inventory list first, otherwise deleted items in pc_checkitem show up as 'unknown item'
- pc_checkitem(sd);
+ clif->inventorylist(sd); // inventory list first, otherwise deleted items in pc->checkitem show up as 'unknown item'
+ pc->checkitem(sd);
// cart
if(pc_iscarton(sd)) {
@@ -9364,30 +9398,30 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
guild->send_memberinfoshort(sd,1);
if(battle_config.pc_invincible_time > 0) {
- pc_setinvincibletimer(sd,battle_config.pc_invincible_time);
+ pc->setinvincibletimer(sd,battle_config.pc_invincible_time);
}
if( map[sd->bl.m].users++ == 0 && battle_config.dynamic_mobs )
- map_spawnmobs(sd->bl.m);
+ iMap->spawnmobs(sd->bl.m);
if( !(sd->sc.option&OPTION_INVISIBLE) ) { // increment the number of pvp players on the map
map[sd->bl.m].users_pvp++;
}
- if( map[sd->bl.m].instance_id ) {
- instance[map[sd->bl.m].instance_id].users++;
- instance_check_idle(map[sd->bl.m].instance_id);
+ if( map[sd->bl.m].instance_id >= 0 ) {
+ instances[map[sd->bl.m].instance_id].users++;
+ instance->check_idle(map[sd->bl.m].instance_id);
}
sd->state.debug_remove_map = 0; // temporary state to track double remove_map's [FlavioJS]
// reset the callshop flag if the player changes map
sd->state.callshop = 0;
- map_addblock(&sd->bl);
+ iMap->addblock(&sd->bl);
clif->spawn(&sd->bl);
// Party
// (needs to go after clif_spawn() to show hp bars correctly)
if(sd->status.party_id) {
- party_send_movemap(sd);
+ party->send_movemap(sd);
clif->party_hp(sd); // Show hp after displacement [LuzZza]
}
@@ -9396,7 +9430,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
if(map[sd->bl.m].flag.pvp && !(sd->sc.option&OPTION_INVISIBLE)) {
if(!battle_config.pk_mode) { // remove pvp stuff for pk_mode [Valaris]
if (!map[sd->bl.m].flag.pvp_nocalcrank)
- sd->pvp_timer = add_timer(gettick()+200, pc_calc_pvprank_timer, sd->bl.id, 0);
+ sd->pvp_timer = iTimer->add_timer(iTimer->gettick()+200, pc->calc_pvprank_timer, sd->bl.id, 0);
sd->pvp_rank = 0;
sd->pvp_lastusers = 0;
sd->pvp_point = 5;
@@ -9416,7 +9450,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
clif->map_property(sd, MAPPROPERTY_AGITZONE);
// info about nearby objects
// must use foreachinarea (CIRCULAR_AREA interferes with foreachinrange)
- map_foreachinarea(clif->getareachar, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_ALL, sd);
+ iMap->foreachinarea(clif->getareachar, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_ALL, sd);
// pet
if( sd->pd ) {
@@ -9424,7 +9458,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
clif->message(sd->fd, msg_txt(666));
pet_menu(sd, 3); //Option 3 is return to egg.
} else {
- map_addblock(&sd->pd->bl);
+ iMap->addblock(&sd->pd->bl);
clif->spawn(&sd->pd->bl);
clif->send_petdata(sd,sd->pd,0,0);
clif->send_petstatus(sd);
@@ -9434,7 +9468,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
//homunculus [blackhole89]
if( homun_alive(sd->hd) ) {
- map_addblock(&sd->hd->bl);
+ iMap->addblock(&sd->hd->bl);
clif->spawn(&sd->hd->bl);
clif->send_homdata(sd,SP_ACK,0);
clif->hominfo(sd,sd->hd,1);
@@ -9443,11 +9477,11 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
if( battle_config.hom_setting&0x8 )
status_calc_bl(&sd->hd->bl, SCB_SPEED); //Homunc mimic their master's speed on each map change
if( !(battle_config.hom_setting&0x2) )
- skill->unit_move(&sd->hd->bl,gettick(),1); // apply land skills immediately
+ skill->unit_move(&sd->hd->bl,iTimer->gettick(),1); // apply land skills immediately
}
if( sd->md ) {
- map_addblock(&sd->md->bl);
+ iMap->addblock(&sd->md->bl);
clif->spawn(&sd->md->bl);
clif->mercenary_info(sd);
clif->mercenary_skillblock(sd);
@@ -9455,7 +9489,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
}
if( sd->ed ) {
- map_addblock(&sd->ed->bl);
+ iMap->addblock(&sd->ed->bl);
clif->spawn(&sd->ed->bl);
clif->elemental_info(sd);
clif->elemental_updatestatus(sd,SP_HP);
@@ -9487,7 +9521,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
sc_start(&sd->bl,SC_NOCHAT,100,0,0);
//Auron reported that This skill only triggers when you logon on the map o.O [Skotlex]
- if ((lv = pc_checkskill(sd,SG_KNOWLEDGE)) > 0) {
+ if ((lv = pc->checkskill(sd,SG_KNOWLEDGE)) > 0) {
if(sd->bl.m == sd->feel_map[0].m
|| sd->bl.m == sd->feel_map[1].m
|| sd->bl.m == sd->feel_map[2].m)
@@ -9500,13 +9534,13 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
if(homun_alive(sd->hd))
homun->init_timers(sd->hd);
- if (night_flag && map[sd->bl.m].flag.nightenabled) {
+ if (iMap->night_flag && map[sd->bl.m].flag.nightenabled) {
sd->state.night = 1;
- clif->status_change(&sd->bl, SI_NIGHT, 1, 0, 0, 0, 0);
+ clif->status_change(&sd->bl, SI_SKE, 1, 0, 0, 0, 0);
}
// Notify everyone that this char logged in [Skotlex].
- map_foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 1);
+ iMap->map_foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 1);
//Login Event
npc_script_event(sd, NPCE_LOGIN);
@@ -9531,20 +9565,20 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
if( sd->state.changemap ) {// restore information that gets lost on map-change
#if PACKETVER >= 20070918
clif->partyinvitationstate(sd);
- clif->equipcheckbox(sd);
+ clif->equpcheckbox(sd);
#endif
if( (battle_config.bg_flee_penalty != 100 || battle_config.gvg_flee_penalty != 100) &&
(map_flag_gvg(sd->state.pmap) || map_flag_gvg(sd->bl.m) || map[sd->state.pmap].flag.battleground || map[sd->bl.m].flag.battleground) )
status_calc_bl(&sd->bl, SCB_FLEE); //Refresh flee penalty
- if( night_flag && map[sd->bl.m].flag.nightenabled ) { //Display night.
+ if( iMap->night_flag && map[sd->bl.m].flag.nightenabled ) { //Display night.
if( !sd->state.night ) {
sd->state.night = 1;
- clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_NIGHT);
+ clif->status_change(&sd->bl, SI_SKE, 1, 0, 0, 0, 0);
}
} else if( sd->state.night ) { //Clear night display.
sd->state.night = 0;
- clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_NIGHT);
+ clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_SKE);
}
if( map[sd->bl.m].flag.battleground ) {
@@ -9559,7 +9593,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
clif->broadcast(&sd->bl, output, strlen(output) + 1, 0x10, SELF);
}
- map_iwall_get(sd); // Updates Walls Info on this Map to Client
+ iMap->iwall_get(sd); // Updates Walls Info on this Map to Client
status_calc_pc(sd, false);/* some conditions are map-dependent so we must recalculate */
sd->state.changemap = false;
@@ -9568,7 +9602,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
}
}
- mail_clear(sd);
+ mail->clear(sd);
clif->maptypeproperty2(&sd->bl,SELF);
@@ -9588,8 +9622,8 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
if(map[sd->bl.m].flag.loadevent) // Lance
npc_script_event(sd, NPCE_LOADMAP);
- if (pc_checkskill(sd, SG_DEVIL) && !pc_nextjobexp(sd)) //blindness [Komurka]
- clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_DEVIL);
+ if (pc->checkskill(sd, SG_DEVIL) && !pc->nextjobexp(sd)) //blindness [Komurka]
+ clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_DEVIL1);
if (sd->sc.opt2) //Client loses these on warp.
clif->changeoption(&sd->bl);
@@ -9597,7 +9631,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
clif->weather_check(sd);
// For automatic triggering of NPCs after map loading (so you don't need to walk 1 step first)
- if (map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNPC))
+ if (iMap->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNPC))
npc_touch_areanpc(sd,sd->bl.m,sd->bl.x,sd->bl.y);
else
sd->areanpc_id = 0;
@@ -9616,7 +9650,8 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
// Trigger skill effects if you appear standing on them
if(!battle_config.pc_invincible_time)
- skill->unit_move(&sd->bl,gettick(),1);
+ skill->unit_move(&sd->bl,iTimer->gettick(),1);
+
}
@@ -9640,7 +9675,7 @@ void clif_parse_TickSend(int fd, struct map_session_data *sd)
{
sd->client_tick = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
- clif->notify_time(sd, gettick());
+ clif->notify_time(sd, iTimer->gettick());
}
@@ -9720,10 +9755,10 @@ void clif_parse_progressbar(int fd, struct map_session_data * sd)
{
int npc_id = sd->progressbar.npc_id;
- if( gettick() < sd->progressbar.timeout && sd->st )
+ if( iTimer->gettick() < sd->progressbar.timeout && sd->st )
sd->st->state = END;
- sd->progressbar.npc_id = sd->progressbar.timeout = 0;
+ sd->state.workinprogress = sd->progressbar.npc_id = sd->progressbar.timeout = 0;
npc_scriptcont(sd, npc_id, false);
}
@@ -9743,15 +9778,15 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd)
if (sd->sc.opt1 && ( sd->sc.opt1 == OPT1_STONEWAIT || sd->sc.opt1 == OPT1_BURNING ))
; //You CAN walk on this OPT1 value.
- else if( sd->progressbar.npc_id )
- clif->progressbar_abort(sd);
+ /*else if( sd->progressbar.npc_id )
+ clif->progressbar_abort(sd);*/
else if (pc_cant_act(sd))
return;
if(sd->sc.data[SC_RUN] || sd->sc.data[SC_WUGDASH])
return;
- pc_delinvincibletimer(sd);
+ pc->delinvincibletimer(sd);
RFIFOPOS(fd, packet_db[RFIFOW(fd,0)].pos[0], &x, &y, NULL);
@@ -9787,9 +9822,10 @@ void clif_parse_QuitGame(int fd, struct map_session_data *sd)
{
/* Rovert's prevent logout option fixed [Valaris] */
if( !sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK] && !sd->sc.data[SC_CLOAKINGEXCEED] &&
- (!battle_config.prevent_logout || DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout) )
+ (!battle_config.prevent_logout || DIFF_TICK(iTimer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) )
{
set_eof(fd);
+
clif->disconnect_ack(sd, 0);
} else {
clif->disconnect_ack(sd, 1);
@@ -9810,7 +9846,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd)
if( id < 0 && -id == sd->bl.id ) // for disguises [Valaris]
id = sd->bl.id;
- bl = map_id2bl(id);
+ bl = iMap->id2bl(id);
if( bl == NULL )
return; // Lagged clients could request names of already gone mobs/players. [Skotlex]
@@ -9822,13 +9858,13 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd)
sc = status_get_sc(bl);
if (sc && sc->option&OPTION_INVISIBLE && !disguised(bl) &&
bl->type != BL_NPC && //Skip hidden NPCs which can be seen using Maya Purple
- pc_get_group_level(sd) < battle_config.hack_info_GM_level
+ pc->get_group_level(sd) < battle_config.hack_info_GM_level
) {
char gm_msg[256];
sprintf(gm_msg, "Hack on NameRequest: character '%s' (account: %d) requested the name of an invisible target (id: %d).\n", sd->status.name, sd->status.account_id, id);
ShowWarning(gm_msg);
// information is sent to all online GMs
- intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, gm_msg);
+ intif_wis_message_to_gm(iMap->wisp_server_name, battle_config.hack_info_GM_level, gm_msg);
return;
}
*/
@@ -9837,10 +9873,10 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd)
}
int clif_undisguise_timer(int tid, unsigned int tick, int id, intptr_t data) {
struct map_session_data * sd;
- if( (sd = map_id2sd(id)) ) {
+ if( (sd = iMap->id2sd(id)) ) {
sd->fontcolor_tid = INVALID_TIMER;
if( sd->fontcolor && sd->disguise == sd->status.class_ )
- pc_disguise(sd,-1);
+ pc->disguise(sd,-1);
}
return 0;
}
@@ -9865,13 +9901,13 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
if( atcommand->parse(fd, sd, message, 1) )
return;
- if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
+ if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || sd->sc.data[SC_DEEP_SLEEP] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
return;
if( battle_config.min_chat_delay ) { //[Skotlex]
- if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0)
+ if (DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0)
return;
- sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
+ sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay;
}
if( sd->gcbind ) {
@@ -9882,14 +9918,16 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
unsigned char mylen = 1;
if( sd->disguise == -1 ) {
- sd->fontcolor_tid = add_timer(gettick()+5000, clif->undisguise_timer, sd->bl.id, 0);
- pc_disguise(sd,sd->status.class_);
+ sd->fontcolor_tid = iTimer->add_timer(iTimer->gettick()+5000, clif->undisguise_timer, sd->bl.id, 0);
+ pc->disguise(sd,sd->status.class_);
if( pc_isdead(sd) )
clif_clearunit_single(-sd->bl.id, CLR_DEAD, sd->fd);
+ if( unit_is_walking(&sd->bl) )
+ clif->move(&sd->ud);
} else if ( sd->disguise == sd->status.class_ && sd->fontcolor_tid != INVALID_TIMER ) {
const struct TimerData *timer;
- if( (timer = get_timer(sd->fontcolor_tid)) ) {
- settick_timer(sd->fontcolor_tid, timer->tick+5000);
+ if( (timer = iTimer->get_timer(sd->fontcolor_tid)) ) {
+ iTimer->settick_timer(sd->fontcolor_tid, timer->tick+5000);
}
}
@@ -9939,7 +9977,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
WFIFOSET(fd, WFIFOW(fd,2));
#ifdef PCRE_SUPPORT
// trigger listening npcs
- map_foreachinrange(npc_chat_sub, &sd->bl, AREA_SIZE, BL_NPC, text, textlen, &sd->bl);
+ iMap->foreachinrange(npc_chat_sub, &sd->bl, AREA_SIZE, BL_NPC, text, textlen, &sd->bl);
#endif
// Chat logging type 'O' / Global Chat
@@ -10020,7 +10058,7 @@ void clif_parse_Emotion(int fd, struct map_session_data *sd)
{
int emoticon = RFIFOB(fd,packet_db[RFIFOW(fd,0)].pos[0]);
- if (battle_config.basic_skill_check == 0 || pc_checkskill(sd, NV_BASIC) >= 2) {
+ if (battle_config.basic_skill_check == 0 || pc->checkskill(sd, NV_BASIC) >= 2) {
if (emoticon == E_MUTE) {// prevent use of the mute emote [Valaris]
clif->skill_fail(sd, 1, USESKILL_FAIL_LEVEL, 1);
return;
@@ -10060,7 +10098,7 @@ void clif_user_count(struct map_session_data* sd, int count) {
/// 00c1
void clif_parse_HowManyConnections(int fd, struct map_session_data *sd)
{
- clif->user_count(sd, map_getusers());
+ clif->user_count(sd, iMap->getusers());
}
@@ -10099,19 +10137,19 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type,
if( sd->sc.data[SC_BASILICA] || sd->sc.data[SC__SHADOWFORM] )
return;
- if (!battle_config.sdelay_attack_enable && pc_checkskill(sd, SA_FREECAST) <= 0) {
+ if (!battle_config.sdelay_attack_enable && pc->checkskill(sd, SA_FREECAST) <= 0) {
if (DIFF_TICK(tick, sd->ud.canact_tick) < 0) {
clif->skill_fail(sd, 1, USESKILL_FAIL_SKILLINTERVAL, 0);
return;
}
}
- pc_delinvincibletimer(sd);
+ pc->delinvincibletimer(sd);
sd->idletime = last_tick;
unit_attack(&sd->bl, target_id, action_type != 0);
break;
case 0x02: // sitdown
- if (battle_config.basic_skill_check && pc_checkskill(sd, NV_BASIC) < 3) {
+ if (battle_config.basic_skill_check && pc->checkskill(sd, NV_BASIC) < 3) {
clif->skill_fail(sd, 1, USESKILL_FAIL_LEVEL, 2);
break;
}
@@ -10141,7 +10179,7 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type,
clif->standing(&sd->bl);
return;
}
- pc_setstand(sd);
+ pc->setstand(sd);
skill->sit(sd,0);
clif->standing(&sd->bl);
break;
@@ -10276,7 +10314,7 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd)
clif->pActionRequest_sub(sd,
RFIFOB(fd,packet_db[RFIFOW(fd,0)].pos[1]),
RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]),
- gettick()
+ iTimer->gettick()
);
}
@@ -10289,12 +10327,12 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd)
void clif_parse_Restart(int fd, struct map_session_data *sd) {
switch(RFIFOB(fd,2)) {
case 0x00:
- pc_respawn(sd,CLR_RESPAWN);
+ pc->respawn(sd,CLR_RESPAWN);
break;
case 0x01:
/* Rovert's Prevent logout option - Fixed [Valaris] */
if( !sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK] && !sd->sc.data[SC_CLOAKINGEXCEED] &&
- (!battle_config.prevent_logout || DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout) )
+ (!battle_config.prevent_logout || DIFF_TICK(iTimer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) )
{ //Send to char-server for character selection.
chrif_charselectreq(sd, session[fd]->client_addr);
} else {
@@ -10322,14 +10360,14 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
if ( atcommand->parse(fd, sd, message, 1) )
return;
- if (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT))
+ if (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || sd->sc.data[SC_DEEP_SLEEP] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT))
return;
if (battle_config.min_chat_delay) { //[Skotlex]
- if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0) {
+ if (DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0) {
return;
}
- sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
+ sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay;
}
// Chat logging type 'W' / Whisper
@@ -10418,7 +10456,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
}
// searching destination character
- dstsd = map_nick2sd(target);
+ dstsd = iMap->nick2sd(target);
if (dstsd == NULL || strcmp(dstsd->status.name, target) != 0) {
// player is not on this map-server
@@ -10432,7 +10470,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
// if player ignores everyone
if (dstsd->state.ignoreAll) {
- if (dstsd->sc.option & OPTION_INVISIBLE && pc_get_group_level(sd) < pc_get_group_level(dstsd))
+ if (dstsd->sc.option & OPTION_INVISIBLE && pc->get_group_level(sd) < pc->get_group_level(dstsd))
clif->wis_end(fd, 1); // 1: target character is not loged in
else
clif->wis_end(fd, 3); // 3: everyone ignored by target
@@ -10443,7 +10481,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
if( dstsd->state.autotrade == 1 ) {
char output[256];
sprintf(output, "%s is in autotrade mode and cannot receive whispered messages.", dstsd->status.name);
- clif->wis_message(fd, wisp_server_name, output, strlen(output) + 1);
+ clif->wis_message(fd, iMap->wisp_server_name, output, strlen(output) + 1);
return;
}
@@ -10489,7 +10527,7 @@ void clif_parse_TakeItem(int fd, struct map_session_data *sd)
map_object_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
- fitem = (struct flooritem_data*)map_id2bl(map_object_id);
+ fitem = (struct flooritem_data*)iMap->id2bl(map_object_id);
do {
if (pc_isdead(sd)) {
@@ -10513,7 +10551,7 @@ void clif_parse_TakeItem(int fd, struct map_session_data *sd)
if (pc_cant_act(sd))
break;
- if (!pc_takeitem(sd, fitem))
+ if (!pc->takeitem(sd, fitem))
break;
return;
@@ -10536,7 +10574,7 @@ void clif_parse_DropItem(int fd, struct map_session_data *sd)
if (pc_isdead(sd))
break;
- if ( pc_cant_act2(sd) )
+ if ( pc_cant_act2(sd) || sd->state.vending )
break;
if (sd->sc.count && (
@@ -10546,7 +10584,7 @@ void clif_parse_DropItem(int fd, struct map_session_data *sd)
))
break;
- if (!pc_dropitem(sd, item_index, item_amount))
+ if (!pc->dropitem(sd, item_index, item_amount))
break;
return;
@@ -10579,7 +10617,7 @@ void clif_parse_UseItem(int fd, struct map_session_data *sd)
if(n <0 || n >= MAX_INVENTORY)
return;
- if (!pc_useitem(sd,n))
+ if (!pc->useitem(sd,n))
clif->useitemack(sd,n,0,false); //Send an empty ack packet or the client gets stuck.
}
@@ -10603,7 +10641,7 @@ void clif_parse_EquipItem(int fd,struct map_session_data *sd)
return;
} else if ( sd->state.storage_flag || sd->sc.opt1 )
; //You can equip/unequip stuff while storage is open/under status changes
- else if ( pc_cant_act2(sd) )
+ else if ( pc_cant_act2(sd) || sd->state.prerefining )
return;
if(!sd->status.inventory[index].identify) {
@@ -10621,9 +10659,9 @@ void clif_parse_EquipItem(int fd,struct map_session_data *sd)
//Client doesn't send the position for ammo.
if(sd->inventory_data[index]->type == IT_AMMO)
- pc_equipitem(sd,index,EQP_AMMO);
+ pc->equipitem(sd,index,EQP_AMMO);
else
- pc_equipitem(sd,index,RFIFOW(fd,4));
+ pc->equipitem(sd,index,RFIFOW(fd,4));
}
void clif_hercules_chsys_delete(struct hChSysCh *channel) {
@@ -10731,12 +10769,12 @@ void clif_parse_UnequipItem(int fd,struct map_session_data *sd)
return;
} else if ( sd->state.storage_flag || sd->sc.opt1 )
; //You can equip/unequip stuff while storage is open/under status changes
- else if ( pc_cant_act2(sd) )
+ else if ( pc_cant_act2(sd) || sd->state.prerefining )
return;
index = RFIFOW(fd,2)-2;
- pc_unequipitem(sd,index,1);
+ pc->unequipitem(sd,index,1);
}
@@ -10748,22 +10786,31 @@ void clif_parse_NpcClicked(int fd,struct map_session_data *sd)
{
struct block_list *bl;
- if(pc_isdead(sd)) {
+ if( pc_isdead(sd) ) {
clif_clearunit_area(&sd->bl,CLR_DEAD);
return;
}
-
- if ( pc_cant_act2(sd) )
+ if( sd->npc_id || sd->state.workinprogress&2 ){
+#ifdef RENEWAL
+ clif->msg(sd, 0x783); // TODO look for the client date that has this message.
+#endif
return;
-
- bl = map_id2bl(RFIFOL(fd,2));
- if (!bl) return;
+ }
+ if ( pc_cant_act2(sd) || !(bl = iMap->id2bl(RFIFOL(fd,2))) || sd->state.vending )
+ return;
+
switch (bl->type) {
case BL_MOB:
case BL_PC:
- clif->pActionRequest_sub(sd, 0x07, bl->id, gettick());
+ clif->pActionRequest_sub(sd, 0x07, bl->id, iTimer->gettick());
break;
case BL_NPC:
+ if( sd->ud.skill_id < RK_ENCHANTBLADE && sd->ud.skilltimer != INVALID_TIMER ) {// TODO: should only work with none 3rd job skills
+#ifdef RENEWAL
+ clif->msg(sd, 0x783);
+#endif
+ break;
+ }
if( bl->m != -1 )// the user can't click floating npcs directly (hack attempt)
npc_click(sd,(TBL_NPC*)bl);
break;
@@ -10873,7 +10920,7 @@ void clif_parse_CreateChatRoom(int fd, struct map_session_data* sd)
if (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOROOM)
return;
- if(battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 4) {
+ if(battle_config.basic_skill_check && pc->checkskill(sd,NV_BASIC) < 4) {
clif->skill_fail(sd,1,USESKILL_FAIL_LEVEL,3);
return;
}
@@ -10980,7 +11027,7 @@ void clif_parse_TradeRequest(int fd,struct map_session_data *sd)
{
struct map_session_data *t_sd;
- t_sd = map_id2sd(RFIFOL(fd,2));
+ t_sd = iMap->id2sd(RFIFOL(fd,2));
if(!sd->chatID && pc_cant_act(sd))
return; //You can trade while in a chatroom.
@@ -10991,12 +11038,12 @@ void clif_parse_TradeRequest(int fd,struct map_session_data *sd)
return;
}
- if( battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 1) {
+ if( battle_config.basic_skill_check && pc->checkskill(sd,NV_BASIC) < 1) {
clif->skill_fail(sd,1,USESKILL_FAIL_LEVEL,0);
return;
}
- trade_traderequest(sd,t_sd);
+ trade->request(sd,t_sd);
}
@@ -11007,7 +11054,7 @@ void clif_parse_TradeRequest(int fd,struct map_session_data *sd)
/// 4 = rejected
void clif_parse_TradeAck(int fd,struct map_session_data *sd)
{
- trade_tradeack(sd,RFIFOB(fd,2));
+ trade->ack(sd,RFIFOB(fd,2));
}
@@ -11019,9 +11066,9 @@ void clif_parse_TradeAddItem(int fd,struct map_session_data *sd)
int amount = RFIFOL(fd,4);
if( index == 0 )
- trade_tradeaddzeny(sd, amount);
+ trade->addzeny(sd, amount);
else
- trade_tradeadditem(sd, index, (short)amount);
+ trade->additem(sd, index, (short)amount);
}
@@ -11029,7 +11076,7 @@ void clif_parse_TradeAddItem(int fd,struct map_session_data *sd)
/// 00eb
void clif_parse_TradeOk(int fd,struct map_session_data *sd)
{
- trade_tradeok(sd);
+ trade->ok(sd);
}
@@ -11037,7 +11084,7 @@ void clif_parse_TradeOk(int fd,struct map_session_data *sd)
/// 00ed
void clif_parse_TradeCancel(int fd,struct map_session_data *sd)
{
- trade_tradecancel(sd);
+ trade->cancel(sd);
}
@@ -11045,7 +11092,7 @@ void clif_parse_TradeCancel(int fd,struct map_session_data *sd)
/// 00ef
void clif_parse_TradeCommit(int fd,struct map_session_data *sd)
{
- trade_tradecommit(sd);
+ trade->commit(sd);
}
@@ -11065,7 +11112,7 @@ void clif_parse_PutItemToCart(int fd,struct map_session_data *sd)
return;
if (!pc_iscarton(sd))
return;
- pc_putitemtocart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4));
+ pc->putitemtocart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4));
}
@@ -11075,7 +11122,7 @@ void clif_parse_GetItemFromCart(int fd,struct map_session_data *sd)
{
if (!pc_iscarton(sd))
return;
- pc_getitemfromcart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4));
+ pc->getitemfromcart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4));
}
@@ -11087,11 +11134,11 @@ void clif_parse_RemoveOption(int fd,struct map_session_data *sd)
* Attempts to remove these options when this function is called (will remove all available)
**/
#ifdef NEW_CARTS
- pc_setoption(sd,sd->sc.option&~(OPTION_RIDING|OPTION_FALCON|OPTION_DRAGON|OPTION_MADOGEAR));
+ pc->setoption(sd,sd->sc.option&~(OPTION_RIDING|OPTION_FALCON|OPTION_DRAGON|OPTION_MADOGEAR));
if( sd->sc.data[SC_PUSH_CART] )
- pc_setcart(sd,0);
+ pc->setcart(sd,0);
#else
- pc_setoption(sd,sd->sc.option&~(OPTION_CART|OPTION_RIDING|OPTION_FALCON|OPTION_DRAGON|OPTION_MADOGEAR));
+ pc->setoption(sd,sd->sc.option&~(OPTION_CART|OPTION_RIDING|OPTION_FALCON|OPTION_DRAGON|OPTION_MADOGEAR));
#endif
}
@@ -11102,7 +11149,7 @@ void clif_parse_ChangeCart(int fd,struct map_session_data *sd)
{// TODO: State tracking?
int type;
- if( sd && pc_checkskill(sd, MC_CHANGECART) < 1 )
+ if( sd && pc->checkskill(sd, MC_CHANGECART) < 1 )
return;
type = (int)RFIFOW(fd,2);
@@ -11123,7 +11170,7 @@ void clif_parse_ChangeCart(int fd,struct map_session_data *sd)
(type == 2 && sd->status.base_level > 40) ||
(type == 1))
#endif
- pc_setcart(sd,type);
+ pc->setcart(sd,type);
}
@@ -11136,7 +11183,7 @@ void clif_parse_ChangeCart(int fd,struct map_session_data *sd)
/// the like
void clif_parse_StatusUp(int fd,struct map_session_data *sd)
{
- pc_statusup(sd,RFIFOW(fd,2));
+ pc->statusup(sd,RFIFOW(fd,2));
}
@@ -11144,7 +11191,7 @@ void clif_parse_StatusUp(int fd,struct map_session_data *sd)
/// 0112 <skill id>.W
void clif_parse_SkillUp(int fd,struct map_session_data *sd)
{
- pc_skillup(sd,RFIFOW(fd,2));
+ pc->skillup(sd,RFIFOW(fd,2));
}
void clif_parse_UseSkillToId_homun(struct homun_data *hd, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, int target_id)
@@ -11244,7 +11291,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
{
uint16 skill_id, skill_lv;
int tmp, target_id;
- unsigned int tick = gettick();
+ unsigned int tick = iTimer->gettick();
skill_lv = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[0]);
skill_id = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[1]);
@@ -11269,7 +11316,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
// Whether skill fails or not is irrelevant, the char ain't idle. [Skotlex]
sd->idletime = last_tick;
- if( sd->npc_id ){
+ if( sd->npc_id || sd->state.workinprogress&1 ){
#ifdef RENEWAL
clif->msg(sd, 0x783); // TODO look for the client date that has this message.
#endif
@@ -11315,7 +11362,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
if( skill_lv != sd->skillitemlv )
skill_lv = sd->skillitemlv;
if( !(tmp&INF_SELF_SKILL) )
- pc_delinvincibletimer(sd); // Target skills thru items cancel invincibility. [Inkfish]
+ pc->delinvincibletimer(sd); // Target skills thru items cancel invincibility. [Inkfish]
unit_skilluse_id(&sd->bl, target_id, skill_id, skill_lv);
return;
}
@@ -11328,12 +11375,12 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
else
skill_lv = 0;
} else {
- tmp = pc_checkskill(sd, skill_id);
+ tmp = pc->checkskill(sd, skill_id);
if( skill_lv > tmp )
skill_lv = tmp;
}
- pc_delinvincibletimer(sd);
+ pc->delinvincibletimer(sd);
if( skill_lv )
unit_skilluse_id(&sd->bl, target_id, skill_id, skill_lv);
@@ -11344,7 +11391,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
*------------------------------------------*/
void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 skill_lv, uint16 skill_id, short x, short y, int skillmoreinfo)
{
- unsigned int tick = gettick();
+ unsigned int tick = iTimer->gettick();
if( !(skill->get_inf(skill_id)&INF_GROUND_SKILL) )
return; //Using a target skill on the ground? WRONG.
@@ -11396,7 +11443,7 @@ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 ski
return; //Can't use skills while a menu is open.
}
- pc_delinvincibletimer(sd);
+ pc->delinvincibletimer(sd);
if( sd->skillitem == skill_id ) {
if( skill_lv != sd->skillitemlv )
@@ -11405,7 +11452,7 @@ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 ski
} else {
int lv;
sd->skillitem = sd->skillitemlv = 0;
- if( (lv = pc_checkskill(sd, skill_id)) > 0 ) {
+ if( (lv = pc->checkskill(sd, skill_id)) > 0 ) {
if( skill_lv > lv )
skill_lv = lv;
unit_skilluse_pos(&sd->bl, x, y, skill_id,skill_lv);
@@ -11472,7 +11519,7 @@ void clif_parse_UseSkillMap(int fd, struct map_session_data* sd)
return;
}
- pc_delinvincibletimer(sd);
+ pc->delinvincibletimer(sd);
skill->castend_map(sd,skill_id,map_name);
}
@@ -11482,7 +11529,7 @@ void clif_parse_UseSkillMap(int fd, struct map_session_data* sd)
void clif_parse_RequestMemo(int fd,struct map_session_data *sd)
{
if (!pc_isdead(sd))
- pc_memo(sd,-1);
+ pc->memo(sd,-1);
}
@@ -11562,6 +11609,8 @@ void clif_parse_WeaponRefine(int fd, struct map_session_data *sd)
{
int idx;
+ sd->state.prerefining = 0;
+
if (sd->menuskill_id != WS_WEAPONREFINE) //Packet exploit?
return;
if (pc_istrading(sd)) {
@@ -11592,7 +11641,7 @@ void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd)
#ifdef SECURE_NPCTIMEOUT
if( sd->npc_idle_timer != INVALID_TIMER ) {
#endif
- TBL_NPC* nd = map_id2nd(npc_id);
+ TBL_NPC* nd = iMap->id2nd(npc_id);
ShowWarning("Invalid menu selection on npc %d:'%s' - got %d, valid range is [%d..%d] (player AID:%d, CID:%d, name:'%s')!\n", npc_id, (nd)?nd->name:"invalid npc id", select, 1, sd->npc_menu, sd->bl.id, sd->status.char_id, sd->status.name);
clif->GM_kick(NULL,sd);
#ifdef SECURE_NPCTIMEOUT
@@ -11663,6 +11712,8 @@ void clif_parse_ItemIdentify(int fd,struct map_session_data *sd)
if (sd->menuskill_id != MC_IDENTIFY)
return;
if( idx == -1 ) {// cancel pressed
+ sd->state.workinprogress = 0;
+ clif->item_identified(sd,idx-2,1);
clif_menuskill_clear(sd);
return;
}
@@ -11730,7 +11781,7 @@ void clif_parse_InsertCard(int fd,struct map_session_data *sd)
{
if (sd->state.trading != 0)
return;
- pc_insert_card(sd,RFIFOW(fd,2)-2,RFIFOW(fd,4)-2);
+ pc->insert_card(sd,RFIFOW(fd,2)-2,RFIFOW(fd,4)-2);
}
@@ -11743,7 +11794,7 @@ void clif_parse_SolveCharName(int fd, struct map_session_data *sd)
int charid;
charid = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
- map_reqnickdb(sd, charid);
+ iMap->reqnickdb(sd, charid);
}
@@ -11799,10 +11850,9 @@ void clif_parse_MoveToKafra(int fd, struct map_session_data *sd)
return;
if (sd->state.storage_flag == 1)
- storage_storageadd(sd, item_index, item_amount);
- else
- if (sd->state.storage_flag == 2)
- storage_guild_storageadd(sd, item_index, item_amount);
+ storage->add(sd, item_index, item_amount);
+ else if (sd->state.storage_flag == 2)
+ gstorage->add(sd, item_index, item_amount);
}
@@ -11818,9 +11868,9 @@ void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd)
item_amount = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[1]);
if (sd->state.storage_flag == 1)
- storage_storageget(sd, item_index, item_amount);
+ storage->get(sd, item_index, item_amount);
else if(sd->state.storage_flag == 2)
- storage_guild_storageget(sd, item_index, item_amount);
+ gstorage->get(sd, item_index, item_amount);
}
@@ -11834,10 +11884,9 @@ void clif_parse_MoveToKafraFromCart(int fd, struct map_session_data *sd)
return;
if (sd->state.storage_flag == 1)
- storage_storageaddfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4));
- else
- if (sd->state.storage_flag == 2)
- storage_guild_storageaddfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4));
+ storage->addfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4));
+ else if (sd->state.storage_flag == 2)
+ gstorage->addfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4));
}
@@ -11851,10 +11900,9 @@ void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd)
return;
if (sd->state.storage_flag == 1)
- storage_storagegettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4));
- else
- if (sd->state.storage_flag == 2)
- storage_guild_storagegettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4));
+ storage->gettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4));
+ else if (sd->state.storage_flag == 2)
+ gstorage->gettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4));
}
@@ -11863,9 +11911,9 @@ void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd)
void clif_parse_CloseKafra(int fd, struct map_session_data *sd)
{
if( sd->state.storage_flag == 1 )
- storage_storageclose(sd);
+ storage->close(sd);
else if( sd->state.storage_flag == 2 )
- storage_guild_storageclose(sd);
+ gstorage->close(sd);
}
@@ -11934,12 +11982,12 @@ void clif_parse_CreateParty(int fd, struct map_session_data *sd)
clif->message(fd, msg_txt(227));
return;
}
- if( battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 7 ) {
+ if( battle_config.basic_skill_check && pc->checkskill(sd,NV_BASIC) < 7 ) {
clif->skill_fail(sd,1,USESKILL_FAIL_LEVEL,4);
return;
}
- party_create(sd,name,0,0);
+ party->create(sd,name,0,0);
}
void clif_parse_CreateParty2(int fd, struct map_session_data *sd)
@@ -11953,12 +12001,12 @@ void clif_parse_CreateParty2(int fd, struct map_session_data *sd)
clif->message(fd, msg_txt(227));
return;
}
- if( battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 7 ) {
+ if( battle_config.basic_skill_check && pc->checkskill(sd,NV_BASIC) < 7 ) {
clif->skill_fail(sd,1,USESKILL_FAIL_LEVEL,4);
return;
}
- party_create(sd,name,item1,item2);
+ party->create(sd,name,item1,item2);
}
@@ -11974,14 +12022,14 @@ void clif_parse_PartyInvite(int fd, struct map_session_data *sd)
return;
}
- t_sd = map_id2sd(RFIFOL(fd,2));
+ t_sd = iMap->id2sd(RFIFOL(fd,2));
if(t_sd && t_sd->state.noask) {// @noask [LuzZza]
clif->noask_sub(sd, t_sd, 1);
return;
}
- party_invite(sd, t_sd);
+ party->invite(sd, t_sd);
}
void clif_parse_PartyInvite2(int fd, struct map_session_data *sd)
@@ -11995,14 +12043,14 @@ void clif_parse_PartyInvite2(int fd, struct map_session_data *sd)
return;
}
- t_sd = map_nick2sd(name);
+ t_sd = iMap->nick2sd(name);
if(t_sd && t_sd->state.noask) { // @noask [LuzZza]
clif->noask_sub(sd, t_sd, 1);
return;
}
- party_invite(sd, t_sd);
+ party->invite(sd, t_sd);
}
@@ -12014,12 +12062,12 @@ void clif_parse_PartyInvite2(int fd, struct map_session_data *sd)
/// 1 = accept
void clif_parse_ReplyPartyInvite(int fd,struct map_session_data *sd)
{
- party_reply_invite(sd,RFIFOL(fd,2),RFIFOL(fd,6));
+ party->reply_invite(sd,RFIFOL(fd,2),RFIFOL(fd,6));
}
void clif_parse_ReplyPartyInvite2(int fd,struct map_session_data *sd)
{
- party_reply_invite(sd,RFIFOL(fd,2),RFIFOB(fd,6));
+ party->reply_invite(sd,RFIFOL(fd,2),RFIFOB(fd,6));
}
@@ -12031,7 +12079,7 @@ void clif_parse_LeaveParty(int fd, struct map_session_data *sd)
clif->message(fd, msg_txt(227));
return;
}
- party_leave(sd);
+ party->leave(sd);
}
@@ -12043,7 +12091,7 @@ void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd)
clif->message(fd, msg_txt(227));
return;
}
- party_removemember(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6));
+ party->removemember(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6));
}
@@ -12058,7 +12106,7 @@ void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd)
if( !sd->status.party_id )
return;
- p = party_search(sd->status.party_id);
+ p = party->search(sd->status.party_id);
if( p == NULL )
return;
@@ -12071,9 +12119,9 @@ void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd)
#if PACKETVER < 20090603
//Client can't change the item-field
- party_changeoption(sd, RFIFOL(fd,2), p->party.item);
+ party->changeoption(sd, RFIFOL(fd,2), p->party.item);
#else
- party_changeoption(sd, RFIFOL(fd,2), ((RFIFOB(fd,6)?1:0)|(RFIFOB(fd,7)?2:0)));
+ party->changeoption(sd, RFIFOL(fd,2), ((RFIFOB(fd,6)?1:0)|(RFIFOB(fd,7)?2:0)));
#endif
}
@@ -12095,17 +12143,17 @@ void clif_parse_PartyMessage(int fd, struct map_session_data* sd)
if( atcommand->parse(fd, sd, message, 1) )
return;
- if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
+ if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || sd->sc.data[SC_DEEP_SLEEP] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
return;
if( battle_config.min_chat_delay )
{ //[Skotlex]
- if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0)
+ if (DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0)
return;
- sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
+ sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay;
}
- party_send_message(sd, text, textlen);
+ party->send_message(sd, text, textlen);
}
@@ -12113,10 +12161,10 @@ void clif_parse_PartyMessage(int fd, struct map_session_data* sd)
/// 07da <account id>.L
void clif_parse_PartyChangeLeader(int fd, struct map_session_data* sd)
{
- party_changeleader(sd, map_id2sd(RFIFOL(fd,2)));
+ party->changeleader(sd, iMap->id2sd(RFIFOL(fd,2)));
}
-
+#ifndef PARTY_RECRUIT
/// Party Booking in KRO [Spiria]
///
@@ -12132,7 +12180,7 @@ void clif_parse_PartyBookingRegisterReq(int fd, struct map_session_data* sd)
for(i=0; i<PARTY_BOOKING_JOBS; i++)
job[i] = RFIFOB(fd,6+i*2);
- party_booking_register(sd, level, mapid, job);
+ party->booking_register(sd, level, mapid, job);
}
@@ -12163,7 +12211,7 @@ void clif_parse_PartyBookingSearchReq(int fd, struct map_session_data* sd)
unsigned long lastindex = RFIFOL(fd,8);
short resultcount = RFIFOW(fd,12);
- party_booking_search(sd, level, mapid, job, lastindex, resultcount);
+ party->booking_search(sd, level, mapid, job, lastindex, resultcount);
}
@@ -12186,7 +12234,7 @@ void clif_PartyBookingSearchAck(int fd, struct party_booking_ad_info** results,
pb_ad = results[i];
WFIFOL(fd,i*size+5) = pb_ad->index;
memcpy(WFIFOP(fd,i*size+9),pb_ad->charname,NAME_LENGTH);
- WFIFOL(fd,i*size+33) = pb_ad->starttime; // FIXME: This is expire time
+ WFIFOL(fd,i*size+33) = pb_ad->expiretime;
WFIFOW(fd,i*size+37) = pb_ad->p_detail.level;
WFIFOW(fd,i*size+39) = pb_ad->p_detail.mapid;
for(j=0; j<PARTY_BOOKING_JOBS; j++)
@@ -12200,7 +12248,7 @@ void clif_PartyBookingSearchAck(int fd, struct party_booking_ad_info** results,
/// 0806
void clif_parse_PartyBookingDeleteReq(int fd, struct map_session_data* sd)
{
- if(party_booking_delete(sd))
+ if(party->booking_delete(sd))
clif->PartyBookingDeleteAck(sd, 0);
}
@@ -12233,7 +12281,7 @@ void clif_parse_PartyBookingUpdateReq(int fd, struct map_session_data* sd)
for(i=0; i<PARTY_BOOKING_JOBS; i++)
job[i] = RFIFOW(fd,2+i*2);
- party_booking_update(sd, job);
+ party->booking_update(sd, job);
}
@@ -12249,7 +12297,7 @@ void clif_PartyBookingInsertNotify(struct map_session_data* sd, struct party_boo
WBUFW(buf,0) = 0x809;
WBUFL(buf,2) = pb_ad->index;
memcpy(WBUFP(buf,6),pb_ad->charname,NAME_LENGTH);
- WBUFL(buf,30) = pb_ad->starttime; // FIXME: This is expire time
+ WBUFL(buf,30) = pb_ad->expiretime;
WBUFW(buf,34) = pb_ad->p_detail.level;
WBUFW(buf,36) = pb_ad->p_detail.mapid;
for(i=0; i<PARTY_BOOKING_JOBS; i++)
@@ -12288,6 +12336,310 @@ void clif_PartyBookingDeleteNotify(struct map_session_data* sd, int index)
clif->send(buf, packet_len(0x80b), &sd->bl, ALL_CLIENT); // Now UPDATE all client.
}
+#else
+/// Modified version of Party Booking System for 2012-04-10 or 2012-04-18 (RagexeRE).
+/// Code written by mkbu95, Spiria, Yommy and Ind
+
+/// Request to register a party booking advertisment (CZ_PARTY_RECRUIT_REQ_REGISTER).
+/// 08e5 <level>.W <notice>.37B
+void clif_parse_PartyBookingRegisterReq(int fd, struct map_session_data* sd)
+{
+ short level = RFIFOW(fd,2);
+ const char *notice = (const char*)RFIFOP(fd, 4);
+
+ party->booking_register(sd, level, notice);
+}
+
+/// Party booking search results (ZC_PARTY_RECRUIT_ACK_SEARCH).
+/// 08e8 <packet len>.W <more results>.B { <index>.L <char name>.24B <expire time>.L <level>.W <notice>.37B }*
+/// more results:
+/// 0 = no
+/// 1 = yes
+void clif_PartyBookingSearchAck(int fd, struct party_booking_ad_info** results, int count, bool more_result)
+{
+ int i;
+ int size = sizeof(struct party_booking_ad_info);
+ struct party_booking_ad_info *pb_ad;
+
+ WFIFOHEAD(fd, (size * count) + 5);
+ WFIFOW(fd, 0) = 0x8e8;
+ WFIFOW(fd, 2) = (size * count) + 5;
+ WFIFOB(fd, 4) = more_result;
+
+ for (i = 0; i < count; ++i) {
+ pb_ad = results[i];
+
+ WFIFOL(fd, (i * size) + 5) = pb_ad->index;
+ WFIFOL(fd, (i * size) + 9) = pb_ad->expiretime;
+ memcpy(WFIFOP(fd, (i * size) + 13), pb_ad->charname, NAME_LENGTH);
+ WFIFOW(fd, (i * size) + 13 + NAME_LENGTH) = pb_ad->p_detail.level;
+ memcpy(WFIFOP(fd, (i * size) + 13 + NAME_LENGTH + 2), pb_ad->p_detail.notice, PB_NOTICE_LENGTH);
+ }
+
+ WFIFOSET(fd,WFIFOW(fd,2));
+}
+
+/// Result of request to register a party booking advertisment (ZC_PARTY_RECRUIT_ACK_REGISTER).
+/// 08e6 <result>.W
+/// result:
+/// 0 = success
+/// 1 = failure
+/// 2 = already registered
+void clif_PartyBookingRegisterAck(struct map_session_data *sd, int flag)
+{
+ int fd = sd->fd;
+
+ WFIFOHEAD(fd, packet_len(0x8e6));
+ WFIFOW(fd, 0) = 0x8e6;
+ WFIFOW(fd, 2) = flag;
+ WFIFOSET(fd, packet_len(0x8e6));
+}
+
+/// Request to search for party booking advertisments (CZ_PARTY_RECRUIT_REQ_SEARCH).
+/// 08e7 <level>.W <map id>.W <last index>.L <result count>.W
+void clif_parse_PartyBookingSearchReq(int fd, struct map_session_data* sd)
+{
+ short level = RFIFOW(fd, 2);
+ short mapid = RFIFOW(fd, 4);
+ unsigned long lastindex = RFIFOL(fd, 6);
+ short resultcount = RFIFOW(fd, 10);
+
+ party->booking_search(sd, level, mapid, lastindex, resultcount);
+}
+
+/// Request to delete own party booking advertisment (CZ_PARTY_RECRUIT_REQ_DELETE).
+/// 08e9
+void clif_parse_PartyBookingDeleteReq(int fd, struct map_session_data* sd)
+{
+ if(party->booking_delete(sd))
+ clif->PartyBookingDeleteAck(sd, 0);
+}
+
+/// Result of request to delete own party booking advertisment (ZC_PARTY_RECRUIT_ACK_DELETE).
+/// 08ea <result>.W
+/// result:
+/// 0 = success
+/// 1 = success (auto-removed expired ad)
+/// 2 = failure
+/// 3 = nothing registered
+void clif_PartyBookingDeleteAck(struct map_session_data* sd, int flag)
+{
+ int fd = sd->fd;
+
+ WFIFOHEAD(fd, packet_len(0x8ea));
+ WFIFOW(fd, 0) = 0x8ea;
+ WFIFOW(fd, 2) = flag;
+ WFIFOSET(fd, packet_len(0x8ea));
+}
+
+/// Request to update party booking advertisment (CZ_PARTY_RECRUIT_REQ_UPDATE).
+/// 08eb <notice>.37B
+void clif_parse_PartyBookingUpdateReq(int fd, struct map_session_data *sd)
+{
+ const char *notice;
+
+ notice = (const char*)RFIFOP(fd, 2);
+
+ party->booking_update(sd, notice);
+}
+
+/// Notification about new party booking advertisment (ZC_PARTY_RECRUIT_NOTIFY_INSERT).
+/// 08ec <index>.L <expire time>.L <char name>.24B <level>.W <notice>.37B
+void clif_PartyBookingInsertNotify(struct map_session_data* sd, struct party_booking_ad_info* pb_ad)
+{
+ unsigned char buf[2+6+6+24+4+37+1];
+
+ if (pb_ad == NULL)
+ return;
+
+ WBUFW(buf, 0) = 0x8ec;
+ WBUFL(buf, 2) = pb_ad->index;
+ WBUFL(buf, 6) = pb_ad->expiretime;
+ memcpy(WBUFP(buf, 10), pb_ad->charname, NAME_LENGTH);
+ WBUFW(buf,34) = pb_ad->p_detail.level;
+ memcpy(WBUFP(buf, 36), pb_ad->p_detail.notice, PB_NOTICE_LENGTH);
+ clif->send(buf, packet_len(0x8ec), &sd->bl, ALL_CLIENT);
+}
+
+/// Notification about updated party booking advertisment (ZC_PARTY_RECRUIT_NOTIFY_UPDATE).
+/// 08ed <index>.L <notice>.37B
+void clif_PartyBookingUpdateNotify(struct map_session_data *sd, struct party_booking_ad_info* pb_ad)
+{
+ unsigned char buf[2+6+37+1];
+
+ WBUFW(buf, 0) = 0x8ed;
+ WBUFL(buf, 2) = pb_ad->index;
+ memcpy(WBUFP(buf, 6), pb_ad->p_detail.notice, PB_NOTICE_LENGTH);
+
+ clif->send(buf, packet_len(0x8ed), &sd->bl, ALL_CLIENT);
+}
+
+/// Notification about deleted party booking advertisment (ZC_PARTY_RECRUIT_NOTIFY_DELETE).
+/// 08ee <index>.L
+void clif_PartyBookingDeleteNotify(struct map_session_data* sd, int index)
+{
+ unsigned char buf[2+6+1];
+
+ WBUFW(buf, 0) = 0x8ee;
+ WBUFL(buf, 2) = index;
+
+ clif->send(buf, packet_len(0x8ee), &sd->bl, ALL_CLIENT);
+}
+
+/// Request to add to filtering list (PARTY_RECRUIT_ADD_FILTERLINGLIST).
+/// 08ef <index>.L
+void clif_parse_PartyBookingAddFilteringList(int fd, struct map_session_data *sd)
+{
+ int index = RFIFOL(fd, 2);
+
+ clif->PartyBookingAddFilteringList(index, sd);
+}
+
+/// Request to remove from filtering list (PARTY_RECRUIT_SUB_FILTERLINGLIST).
+/// 08f0 <GID>.L
+void clif_parse_PartyBookingSubFilteringList(int fd, struct map_session_data *sd)
+{
+ int gid = RFIFOL(fd, 2);
+
+ clif->PartyBookingSubFilteringList(gid, sd);
+}
+
+/// Request to recruit volunteer (PARTY_RECRUIT_REQ_VOLUNTEER).
+/// 08f1 <index>.L
+void clif_parse_PartyBookingReqVolunteer(int fd, struct map_session_data *sd)
+{
+ int index = RFIFOL(fd, 2);
+
+ clif->PartyBookingVolunteerInfo(index, sd);
+}
+
+/// Request volunteer information (PARTY_RECRUIT_VOLUNTEER_INFO).
+/// 08f2 <AID>.L <job>.L <level>.W <char name>.24B
+void clif_PartyBookingVolunteerInfo(int index, struct map_session_data *sd)
+{
+ unsigned char buf[2+4+4+2+24+1];
+
+ WBUFW(buf, 0) = 0x8f2;
+ WBUFL(buf, 2) = sd->status.account_id;
+ WBUFL(buf, 6) = sd->status.class_;
+ WBUFW(buf, 10) = sd->status.base_level;
+ memcpy(WBUFP(buf, 12), sd->status.name, NAME_LENGTH);
+
+ clif->send(buf, packet_len(0x8f2), &sd->bl, ALL_CLIENT);
+}
+
+#if 0 //Disabled for now. Needs more info.
+/// 08f3 <packet type>.W <cost>.L
+void clif_PartyBookingPersonalSetting(int fd, struct map_session_data *sd)
+{
+}
+
+/// 08f4 <target GID>.L
+void clif_parse_PartyBookingShowEquipment(int fd, struct map_session_data *sd)
+{
+}
+
+/// 08f5 <packet len>.W
+void clif_parse_PartyBookingReqRecall(int fd, struct map_session_data *sd)
+{
+}
+
+/// 08f6 <money>.L <map name>.16B
+void clif_PartyBookingRecallCost(int fd, struct map_session_data *sd)
+{
+}
+
+/// 08f7 <result>.B
+void clif_parse_PartyBookingAckRecall(int fd, struct map_session_data *sd)
+{
+}
+
+/// 08f8 <caller AID>.L <reason>.B
+/// <reason>:
+/// REASON_PROHIBITION = 0x0
+/// REASON_MASTER_IN_PROHIBITION_MAP = 0x1
+/// REASON_REFUSE = 0x2
+/// REASON_NOT_PARTY_MEMBER = 0x3
+/// REASON_ETC = 0x4
+void clif_PartyBookingFailedRecall(int fd, struct map_session_data *sd)
+{
+}
+#endif //if 0
+
+/// 08f9 <refuse AID>.L
+void clif_parse_PartyBookingRefuseVolunteer(int fd, struct map_session_data *sd)
+{
+ unsigned long aid = RFIFOL(fd, 2);
+
+ clif->PartyBookingRefuseVolunteer(aid, sd);
+}
+
+/// 08fa <index>.L
+void clif_PartyBookingRefuseVolunteer(unsigned long aid, struct map_session_data *sd)
+{
+ unsigned char buf[2+6];
+
+ WBUFW(buf, 0) = 0x8fa;
+ WBUFL(buf, 2) = aid;
+
+ clif->send(buf, packet_len(0x8fa), &sd->bl, ALL_CLIENT);
+}
+
+/// 08fb <index>.L
+void clif_parse_PartyBookingCancelVolunteer(int fd, struct map_session_data *sd)
+{
+ int index = RFIFOL(fd, 2);
+
+ clif->PartyBookingCancelVolunteer(index, sd);
+}
+
+/// 0909 <index>.L
+void clif_PartyBookingCancelVolunteer(int index, struct map_session_data *sd)
+{
+ unsigned char buf[2+6+1];
+
+ WBUFW(buf, 0) = 0x909;
+ WBUFL(buf, 2) = index;
+
+ clif->send(buf, packet_len(0x909), &sd->bl, ALL_CLIENT);
+}
+
+/// 090b <gid>.L <char name>.24B
+void clif_PartyBookingAddFilteringList(int index, struct map_session_data *sd)
+{
+ unsigned char buf[2+6+24+1];
+
+ WBUFW(buf, 0) = 0x90b;
+ WBUFL(buf, 2) = sd->bl.id;
+ memcpy(WBUFP(buf, 6), sd->status.name, NAME_LENGTH);
+
+ clif->send(buf, packet_len(0x90b), &sd->bl, ALL_CLIENT);
+}
+
+/// 090c <gid>.L <char name>.24B
+void clif_PartyBookingSubFilteringList(int gid, struct map_session_data *sd)
+{
+ unsigned char buf[2+6+24+1];
+
+ WBUFW(buf, 0) = 0x90c;
+ WBUFL(buf, 2) = gid;
+ memcpy(WBUFP(buf, 6), sd->status.name, NAME_LENGTH);
+
+ clif->send(buf, packet_len(0x90c), &sd->bl, ALL_CLIENT);
+}
+
+#if 0
+/// 091c <aid>.L
+void clif_PartyBookingCancelVolunteerToPM(struct map_session_data *sd)
+{
+}
+
+/// 0971 <pm_aid>.L
+void clif_PartyBookingRefuseVolunteerToPM(struct map_session_data *sd)
+{
+}
+#endif //if 0
+#endif
/// Request to close own vending (CZ_REQ_CLOSESTORE).
/// 012e
@@ -12353,7 +12705,7 @@ void clif_parse_OpenVending(int fd, struct map_session_data* sd)
const uint8* data = (uint8*)RFIFOP(fd,85);
if( !flag )
- sd->state.prevend = 0;
+ sd->state.prevend = sd->state.workinprogress = 0;
if( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOROOM )
return;
@@ -12361,7 +12713,7 @@ void clif_parse_OpenVending(int fd, struct map_session_data* sd)
clif->message (sd->fd, msg_txt(276)); // "You can't open a shop on this map"
return;
}
- if( map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOVENDING) ) {
+ if( iMap->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOVENDING) ) {
clif->message (sd->fd, msg_txt(204)); // "You can't open a shop on this cell."
return;
}
@@ -12559,7 +12911,7 @@ clif_sub_guild_invite(int fd, struct map_session_data *sd, struct map_session_da
/// 0168 <account id>.L <inviter account id>.L <inviter char id>.L
void clif_parse_GuildInvite(int fd,struct map_session_data *sd)
{
- struct map_session_data *t_sd = map_id2sd(RFIFOL(fd,2));
+ struct map_session_data *t_sd = iMap->id2sd(RFIFOL(fd,2));
if (clif_sub_guild_invite(fd, sd, t_sd))
return;
@@ -12569,7 +12921,7 @@ void clif_parse_GuildInvite(int fd,struct map_session_data *sd)
/// 0916 <char name>.24B
void clif_parse_GuildInvite2(int fd, struct map_session_data *sd)
{
- struct map_session_data *t_sd = map_nick2sd((char *)RFIFOP(fd, 2));
+ struct map_session_data *t_sd = iMap->nick2sd((char *)RFIFOP(fd, 2));
if (clif_sub_guild_invite(fd, sd, t_sd))
return;
@@ -12632,14 +12984,14 @@ void clif_parse_GuildMessage(int fd, struct map_session_data* sd)
if( atcommand->parse(fd, sd, message, 1) )
return;
- if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
+ if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || sd->sc.data[SC_DEEP_SLEEP] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
return;
if( battle_config.min_chat_delay )
{ //[Skotlex]
- if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0)
+ if (DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0)
return;
- sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
+ sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay;
}
if( sd->bg_id )
@@ -12663,7 +13015,7 @@ void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd)
return;
}
- t_sd = map_id2sd(RFIFOL(fd,2));
+ t_sd = iMap->id2sd(RFIFOL(fd,2));
// @noask [LuzZza]
if(t_sd && t_sd->state.noask) {
@@ -12718,7 +13070,7 @@ void clif_parse_GuildOpposition(int fd, struct map_session_data *sd)
return;
}
- t_sd = map_id2sd(RFIFOL(fd,2));
+ t_sd = iMap->id2sd(RFIFOL(fd,2));
// @noask [LuzZza]
if(t_sd && t_sd->state.noask) {
@@ -12833,7 +13185,7 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd)
int tid;
tid = RFIFOL(fd,2);
- target = map_id2bl(tid);
+ target = iMap->id2bl(tid);
if (!target) {
clif->GM_kickack(sd, 0);
return;
@@ -12854,7 +13206,7 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd)
case BL_MOB:
{
char command[100];
- if( !pc_can_use_command(sd, "@killmonster")) {
+ if( !pc->can_use_command(sd, "@killmonster")) {
clif->GM_kickack(sd, 0);
return;
}
@@ -12917,7 +13269,7 @@ void clif_parse_GMRemove2(int fd, struct map_session_data* sd)
struct map_session_data* pl_sd;
account_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
- if( (pl_sd = map_id2sd(account_id)) != NULL ) {
+ if( (pl_sd = iMap->id2sd(account_id)) != NULL ) {
char command[NAME_LENGTH+8];
sprintf(command, "%cjumpto %s", atcommand->at_symbol, pl_sd->status.name);
atcommand->parse(fd, sd, command, 1);
@@ -12954,7 +13306,7 @@ void clif_parse_GMRecall2(int fd, struct map_session_data* sd)
struct map_session_data* pl_sd;
account_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
- if( (pl_sd = map_id2sd(account_id)) != NULL ) {
+ if( (pl_sd = iMap->id2sd(account_id)) != NULL ) {
char command[NAME_LENGTH+8];
sprintf(command, "%crecall %s", atcommand->at_symbol, pl_sd->status.name);
atcommand->parse(fd, sd, command, 1);
@@ -12983,7 +13335,7 @@ void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd)
// FIXME: Stackables have a quantity of 20.
// FIXME: Equips are supposed to be unidentified.
- if( itemdb_searchname(monster_item_name) ) {
+ if( itemdb->search_name(monster_item_name) ) {
snprintf(command, sizeof(command)-1, "%citem %s", atcommand->at_symbol, monster_item_name);
atcommand->parse(fd, sd, command, 1);
return;
@@ -13025,10 +13377,10 @@ void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd)
//If type is 2 and the ids don't match, this is a crafted hacked packet!
//Disabled because clients keep self-muting when you give players public @ commands... [Skotlex]
- if (type == 2 /* && (pc_get_group_level(sd) > 0 || sd->bl.id != id)*/)
+ if (type == 2 /* && (pc->get_group_level(sd) > 0 || sd->bl.id != id)*/)
return;
- dstsd = map_id2sd(id);
+ dstsd = iMap->id2sd(id);
if( dstsd == NULL )
return;
@@ -13092,7 +13444,7 @@ void clif_parse_GMChangeMapType(int fd, struct map_session_data *sd)
y = RFIFOW(fd,4);
type = RFIFOW(fd,6);
- map_setgatcell(sd->bl.m,x,y,type);
+ iMap->setgatcell(sd->bl.m,x,y,type);
clif->changemapcell(0,sd->bl.m,x,y,type,ALL_SAMEMAP);
//FIXME: once players leave the map, the client 'forgets' this information.
}
@@ -13115,7 +13467,7 @@ void clif_parse_PMIgnore(int fd, struct map_session_data* sd)
type = RFIFOB(fd,26);
if( type == 0 ) { // Add name to ignore list (block)
- if (strcmp(wisp_server_name, nick) == 0) {
+ if (strcmp(iMap->wisp_server_name, nick) == 0) {
clif->wisexin(sd, type, 1); // fail
return;
}
@@ -13242,8 +13594,8 @@ void clif_parse_NoviceDoriDori(int fd, struct map_session_data *sd)
void clif_parse_NoviceExplosionSpirits(int fd, struct map_session_data *sd)
{
if( ( sd->class_&MAPID_UPPERMASK ) == MAPID_SUPER_NOVICE ) {
- unsigned int next = pc_nextbaseexp(sd);
- if( next == 0 ) next = pc_thisbaseexp(sd);
+ unsigned int next = pc->nextbaseexp(sd);
+ if( next == 0 ) next = pc->thisbaseexp(sd);
if( next ) {
int percent = (int)( ( (float)sd->status.base_exp/(float)next )*1000. );
@@ -13316,7 +13668,7 @@ void clif_friendslist_send(struct map_session_data *sd)
}
for (n = 0; n < i; n++) { //Sending the online players
- if (map_charid2sd(sd->status.friends[n].char_id))
+ if (iMap->charid2sd(sd->status.friends[n].char_id))
clif->friendslist_toggle(sd, sd->status.friends[n].account_id, sd->status.friends[n].char_id, 1);
}
}
@@ -13368,7 +13720,7 @@ void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd)
struct map_session_data *f_sd;
int i;
- f_sd = map_nick2sd((char*)RFIFOP(fd,2));
+ f_sd = iMap->nick2sd((char*)RFIFOP(fd,2));
// ensure that the request player's friend list is not full
ARR_FIND(0, MAX_FRIENDS, i, sd->status.friends[i].char_id == 0);
@@ -13433,7 +13785,7 @@ void clif_parse_FriendsListReply(int fd, struct map_session_data *sd)
return;
}
- f_sd = map_id2sd(account_id); //The account id is the same as the bl.id of players.
+ f_sd = iMap->id2sd(account_id); //The account id is the same as the bl.id of players.
if (f_sd == NULL)
return;
@@ -13498,7 +13850,7 @@ void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd)
}
//remove from friend's list first
- if( (f_sd = map_id2sd(account_id)) && f_sd->status.char_id == char_id) {
+ if( (f_sd = iMap->id2sd(account_id)) && f_sd->status.char_id == char_id) {
for (i = 0; i < MAX_FRIENDS &&
(f_sd->status.friends[i].char_id != sd->status.char_id || f_sd->status.friends[i].account_id != sd->status.account_id); i++);
@@ -13579,7 +13931,7 @@ void clif_blacksmith(struct map_session_data* sd)
for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) {
if (smith_fame_list[i].id > 0) {
if (strcmp(smith_fame_list[i].name, "-") == 0 &&
- (name = map_charid2nick(smith_fame_list[i].id)) != NULL)
+ (name = iMap->charid2nick(smith_fame_list[i].id)) != NULL)
{
strncpy((char *)(WFIFOP(fd, 2 + 24 * i)), name, NAME_LENGTH);
} else
@@ -13631,7 +13983,7 @@ void clif_alchemist(struct map_session_data* sd) {
for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) {
if (chemist_fame_list[i].id > 0) {
if (strcmp(chemist_fame_list[i].name, "-") == 0 &&
- (name = map_charid2nick(chemist_fame_list[i].id)) != NULL)
+ (name = iMap->charid2nick(chemist_fame_list[i].id)) != NULL)
{
memcpy(WFIFOP(fd, 2 + 24 * i), name, NAME_LENGTH);
} else
@@ -13683,7 +14035,7 @@ void clif_taekwon(struct map_session_data* sd) {
for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) {
if (taekwon_fame_list[i].id > 0) {
if (strcmp(taekwon_fame_list[i].name, "-") == 0 &&
- (name = map_charid2nick(taekwon_fame_list[i].id)) != NULL)
+ (name = iMap->charid2nick(taekwon_fame_list[i].id)) != NULL)
{
memcpy(WFIFOP(fd, 2 + 24 * i), name, NAME_LENGTH);
} else
@@ -13883,7 +14235,7 @@ void clif_parse_HomMenu(int fd, struct map_session_data *sd) { //[orn]
/// 0292
void clif_parse_AutoRevive(int fd, struct map_session_data *sd)
{
- int item_position = pc_search_inventory(sd, ITEMID_TOKEN_OF_SIEGFRIED);
+ int item_position = pc->search_inventory(sd, ITEMID_TOKEN_OF_SIEGFRIED);
if (item_position < 0)
return;
@@ -13895,7 +14247,7 @@ void clif_parse_AutoRevive(int fd, struct map_session_data *sd)
return;
clif->skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
- pc_delitem(sd, item_position, 1, 0, 1, LOG_TYPE_CONSUME);
+ pc->delitem(sd, item_position, 1, 0, 1, LOG_TYPE_CONSUME);
}
@@ -13910,17 +14262,17 @@ void clif_check(int fd, struct map_session_data* pl_sd) {
WFIFOHEAD(fd,packet_len(0x214));
WFIFOW(fd, 0) = 0x214;
WFIFOB(fd, 2) = min(pl_sd->status.str, UINT8_MAX);
- WFIFOB(fd, 3) = pc_need_status_point(pl_sd, SP_STR, 1);
+ WFIFOB(fd, 3) = pc->need_status_point(pl_sd, SP_STR, 1);
WFIFOB(fd, 4) = min(pl_sd->status.agi, UINT8_MAX);
- WFIFOB(fd, 5) = pc_need_status_point(pl_sd, SP_AGI, 1);
+ WFIFOB(fd, 5) = pc->need_status_point(pl_sd, SP_AGI, 1);
WFIFOB(fd, 6) = min(pl_sd->status.vit, UINT8_MAX);
- WFIFOB(fd, 7) = pc_need_status_point(pl_sd, SP_VIT, 1);
+ WFIFOB(fd, 7) = pc->need_status_point(pl_sd, SP_VIT, 1);
WFIFOB(fd, 8) = min(pl_sd->status.int_, UINT8_MAX);
- WFIFOB(fd, 9) = pc_need_status_point(pl_sd, SP_INT, 1);
+ WFIFOB(fd, 9) = pc->need_status_point(pl_sd, SP_INT, 1);
WFIFOB(fd,10) = min(pl_sd->status.dex, UINT8_MAX);
- WFIFOB(fd,11) = pc_need_status_point(pl_sd, SP_DEX, 1);
+ WFIFOB(fd,11) = pc->need_status_point(pl_sd, SP_DEX, 1);
WFIFOB(fd,12) = min(pl_sd->status.luk, UINT8_MAX);
- WFIFOB(fd,13) = pc_need_status_point(pl_sd, SP_LUK, 1);
+ WFIFOB(fd,13) = pc->need_status_point(pl_sd, SP_LUK, 1);
WFIFOW(fd,14) = pl_sd->battle_status.batk+pl_sd->battle_status.rhw.atk+pl_sd->battle_status.lhw.atk;
WFIFOW(fd,16) = pl_sd->battle_status.rhw.atk2+pl_sd->battle_status.lhw.atk2;
WFIFOW(fd,18) = pl_sd->battle_status.matk_max;
@@ -13952,7 +14304,7 @@ void clif_parse_Check(int fd, struct map_session_data *sd)
safestrncpy(charname, (const char*)RFIFOP(fd,packet_db[RFIFOW(fd,0)].pos[0]), sizeof(charname));
- if( ( pl_sd = map_nick2sd(charname) ) == NULL || pc_get_group_level(sd) < pc_get_group_level(pl_sd) ) {
+ if( ( pl_sd = iMap->nick2sd(charname) ) == NULL || pc->get_group_level(sd) < pc->get_group_level(pl_sd) ) {
return;
}
@@ -14118,8 +14470,8 @@ void clif_parse_Mail_refreshinbox(int fd, struct map_session_data *sd)
else
clif->mail_refreshinbox(sd);
- mail_removeitem(sd, 0);
- mail_removezeny(sd, 0);
+ mail->removeitem(sd, 0);
+ mail->removezeny(sd, 0);
}
@@ -14158,7 +14510,7 @@ void clif_Mail_read(struct map_session_data *sd, int mail_id)
WFIFOL(fd,72) = 0;
WFIFOL(fd,76) = msg->zeny;
- if( item->nameid && (data = itemdb_exists(item->nameid)) != NULL ) {
+ if( item->nameid && (data = itemdb->exists(item->nameid)) != NULL ) {
WFIFOL(fd,80) = item->amount;
WFIFOW(fd,84) = (data->view_id)?data->view_id:item->nameid;
WFIFOW(fd,86) = data->type;
@@ -14193,7 +14545,7 @@ void clif_parse_Mail_read(int fd, struct map_session_data *sd)
if( mail_id <= 0 )
return;
- if( mail_invalid_operation(sd) )
+ if( mail->invalid_operation(sd) )
return;
clif->mail_read(sd, RFIFOL(fd,2));
@@ -14212,7 +14564,7 @@ void clif_parse_Mail_getattach(int fd, struct map_session_data *sd)
return;
if( mail_id <= 0 )
return;
- if( mail_invalid_operation(sd) )
+ if( mail->invalid_operation(sd) )
return;
ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id);
@@ -14231,12 +14583,12 @@ void clif_parse_Mail_getattach(int fd, struct map_session_data *sd)
struct item_data *data;
unsigned int weight;
- if ((data = itemdb_exists(sd->mail.inbox.msg[i].item.nameid)) == NULL)
+ if ((data = itemdb->exists(sd->mail.inbox.msg[i].item.nameid)) == NULL)
return;
- switch( pc_checkadditem(sd, data->nameid, sd->mail.inbox.msg[i].item.amount) ) {
+ switch( pc->checkadditem(sd, data->nameid, sd->mail.inbox.msg[i].item.amount) ) {
case ADDITEM_NEW:
- fail = ( pc_inventoryblank(sd) == 0 );
+ fail = ( pc->inventoryblank(sd) == 0 );
break;
case ADDITEM_OVERAMOUNT:
fail = true;
@@ -14273,7 +14625,7 @@ void clif_parse_Mail_delete(int fd, struct map_session_data *sd)
return;
if( mail_id <= 0 )
return;
- if( mail_invalid_operation(sd) )
+ if( mail->invalid_operation(sd) )
return;
ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id);
@@ -14299,7 +14651,7 @@ void clif_parse_Mail_return(int fd, struct map_session_data *sd)
if( mail_id <= 0 )
return;
- if( mail_invalid_operation(sd) )
+ if( mail->invalid_operation(sd) )
return;
ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id);
@@ -14323,7 +14675,7 @@ void clif_parse_Mail_setattach(int fd, struct map_session_data *sd)
if (idx < 0 || amount < 0)
return;
- flag = mail_setitem(sd, idx, amount);
+ flag = mail->setitem(sd, idx, amount);
clif->mail_setattachment(fd,idx,flag);
}
@@ -14339,9 +14691,9 @@ void clif_parse_Mail_winopen(int fd, struct map_session_data *sd)
int flag = RFIFOW(fd,2);
if (flag == 0 || flag == 1)
- mail_removeitem(sd, 0);
+ mail->removeitem(sd, 0);
if (flag == 0 || flag == 2)
- mail_removezeny(sd, 0);
+ mail->removezeny(sd, 0);
}
@@ -14362,7 +14714,7 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd)
return;
}
- if( DIFF_TICK(sd->cansendmail_tick, gettick()) > 0 ) {
+ if( DIFF_TICK(sd->cansendmail_tick, iTimer->gettick()) > 0 ) {
clif->message(sd->fd,msg_txt(675)); //"Cannot send mails too fast!!."
clif->mail_send(fd, true); // fail
return;
@@ -14373,10 +14725,10 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd)
if (body_len > MAIL_BODY_LENGTH)
body_len = MAIL_BODY_LENGTH;
- if( !mail_setattachment(sd, &msg) ) { // Invalid Append condition
+ if( !mail->setattachment(sd, &msg) ) { // Invalid Append condition
clif->mail_send(sd->fd, true); // fail
- mail_removeitem(sd,0);
- mail_removezeny(sd,0);
+ mail->removeitem(sd,0);
+ mail->removezeny(sd,0);
return;
}
@@ -14398,9 +14750,9 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd)
msg.timestamp = time(NULL);
if( !intif_Mail_send(sd->status.account_id, &msg) )
- mail_deliveryfail(sd, &msg);
+ mail->deliveryfail(sd, &msg);
- sd->cansendmail_tick = gettick() + 1000; // 1 Second flood Protection
+ sd->cansendmail_tick = iTimer->gettick() + 1000; // 1 Second flood Protection
}
@@ -14449,7 +14801,7 @@ void clif_Auction_results(struct map_session_data *sd, short count, short pages,
WFIFOL(fd,k) = auction.auction_id;
safestrncpy((char*)WFIFOP(fd,4+k), auction.seller_name, NAME_LENGTH);
- if( (item = itemdb_exists(auction.item.nameid)) != NULL && item->view_id > 0 )
+ if( (item = itemdb->exists(auction.item.nameid)) != NULL && item->view_id > 0 )
WFIFOW(fd,28+k) = item->view_id;
else
WFIFOW(fd,28+k) = auction.item.nameid;
@@ -14522,15 +14874,15 @@ void clif_parse_Auction_setitem(int fd, struct map_session_data *sd)
return;
}
- if( (item = itemdb_exists(sd->status.inventory[idx].nameid)) != NULL && !(item->type == IT_ARMOR || item->type == IT_PETARMOR || item->type == IT_WEAPON || item->type == IT_CARD || item->type == IT_ETC) )
+ if( (item = itemdb->exists(sd->status.inventory[idx].nameid)) != NULL && !(item->type == IT_ARMOR || item->type == IT_PETARMOR || item->type == IT_WEAPON || item->type == IT_CARD || item->type == IT_ETC) )
{ // Consumable or pets are not allowed
clif->auction_setitem(sd->fd, idx, true);
return;
}
- if( !pc_can_give_items(sd) || sd->status.inventory[idx].expire_time ||
+ if( !pc->can_give_items(sd) || sd->status.inventory[idx].expire_time ||
!sd->status.inventory[idx].identify ||
- !itemdb_canauction(&sd->status.inventory[idx],pc_get_group_level(sd)) ) { // Quest Item or something else
+ !itemdb_canauction(&sd->status.inventory[idx],pc->get_group_level(sd)) ) { // Quest Item or something else
clif->auction_setitem(sd->fd, idx, true);
return;
}
@@ -14629,7 +14981,7 @@ void clif_parse_Auction_register(int fd, struct map_session_data *sd)
return;
}
- if( (item = itemdb_exists(sd->status.inventory[sd->auction.index].nameid)) == NULL )
+ if( (item = itemdb->exists(sd->status.inventory[sd->auction.index].nameid)) == NULL )
{ // Just in case
clif->auction_message(fd, 2); // The auction has been canceled
return;
@@ -14647,10 +14999,10 @@ void clif_parse_Auction_register(int fd, struct map_session_data *sd)
{
int zeny = auction.hours*battle_config.auction_feeperhour;
- pc_delitem(sd, sd->auction.index, sd->auction.amount, 1, 6, LOG_TYPE_AUCTION);
+ pc->delitem(sd, sd->auction.index, sd->auction.amount, 1, 6, LOG_TYPE_AUCTION);
sd->auction.amount = 0;
- pc_payzeny(sd, zeny, LOG_TYPE_AUCTION, NULL);
+ pc->payzeny(sd, zeny, LOG_TYPE_AUCTION, NULL);
}
}
@@ -14682,7 +15034,7 @@ void clif_parse_Auction_bid(int fd, struct map_session_data *sd)
unsigned int auction_id = RFIFOL(fd,2);
int bid = RFIFOL(fd,6);
- if( !pc_can_give_items(sd) ) { //They aren't supposed to give zeny [Inkfish]
+ if( !pc->can_give_items(sd) ) { //They aren't supposed to give zeny [Inkfish]
clif->message(sd->fd, msg_txt(246));
return;
}
@@ -14694,7 +15046,7 @@ void clif_parse_Auction_bid(int fd, struct map_session_data *sd)
else if ( CheckForCharServer() ) // char server is down (bugreport:1138)
clif->auction_message(fd, 0); // You have failed to bid into the auction
else {
- pc_payzeny(sd, bid, LOG_TYPE_AUCTION, NULL);
+ pc->payzeny(sd, bid, LOG_TYPE_AUCTION, NULL);
intif_Auction_bid(sd->status.char_id, sd->status.name, auction_id, bid);
}
}
@@ -14765,7 +15117,7 @@ void clif_cashshop_show(struct map_session_data *sd, struct npc_data *nd)
#endif
for( i = 0; i < nd->u.shop.count; i++ ) {
- struct item_data* id = itemdb_search(nd->u.shop.shop_item[i].nameid);
+ struct item_data* id = itemdb->search(nd->u.shop.shop_item[i].nameid);
WFIFOL(fd,offset+0+i*11) = nd->u.shop.shop_item[i].value;
WFIFOL(fd,offset+4+i*11) = nd->u.shop.shop_item[i].value; // Discount Price
WFIFOB(fd,offset+8+i*11) = itemtype(id->type);
@@ -14879,9 +15231,9 @@ void clif_Adopt_request(struct map_session_data *sd, struct map_session_data *sr
/// 01f9 <account id>.L
void clif_parse_Adopt_request(int fd, struct map_session_data *sd)
{
- struct map_session_data *tsd = map_id2sd(RFIFOL(fd,2)), *p_sd = map_charid2sd(sd->status.partner_id);
+ struct map_session_data *tsd = iMap->id2sd(RFIFOL(fd,2)), *p_sd = iMap->charid2sd(sd->status.partner_id);
- if( pc_can_Adopt(sd, p_sd, tsd) ) {
+ if( pc->can_Adopt(sd, p_sd, tsd) ) {
tsd->adopt_invite = sd->status.account_id;
clif->adopt_request(tsd, sd, p_sd->status.account_id);
}
@@ -14898,8 +15250,8 @@ void clif_parse_Adopt_reply(int fd, struct map_session_data *sd)
int p1_id = RFIFOL(fd,2);
int p2_id = RFIFOL(fd,6);
int result = RFIFOL(fd,10);
- struct map_session_data* p1_sd = map_id2sd(p1_id);
- struct map_session_data* p2_sd = map_id2sd(p2_id);
+ struct map_session_data* p1_sd = iMap->id2sd(p1_id);
+ struct map_session_data* p2_sd = iMap->id2sd(p2_id);
int pid = sd->adopt_invite;
sd->adopt_invite = 0;
@@ -14913,7 +15265,7 @@ void clif_parse_Adopt_reply(int fd, struct map_session_data *sd)
if( result == 0 )
return; // Rejected
- pc_adoption(p1_sd, p2_sd, sd);
+ pc->adoption(p1_sd, p2_sd, sd);
}
@@ -14939,11 +15291,11 @@ void clif_bossmapinfo(int fd, struct mob_data *md, short flag)
} else
WFIFOB(fd,2) = 2; // First Time
} else if (md->spawn_timer != INVALID_TIMER) { // Boss is Dead
- const struct TimerData * timer_data = get_timer(md->spawn_timer);
+ const struct TimerData * timer_data = iTimer->get_timer(md->spawn_timer);
unsigned int seconds;
int hours, minutes;
- seconds = DIFF_TICK(timer_data->tick, gettick()) / 1000 + 60;
+ seconds = DIFF_TICK(timer_data->tick, iTimer->gettick()) / 1000 + 60;
hours = seconds / (60 * 60);
seconds = seconds - (60 * 60 * hours);
minutes = seconds / 60;
@@ -14964,7 +15316,7 @@ void clif_bossmapinfo(int fd, struct mob_data *md, short flag)
void clif_parse_ViewPlayerEquip(int fd, struct map_session_data* sd)
{
int charid = RFIFOL(fd, 2);
- struct map_session_data* tsd = map_id2sd(charid);
+ struct map_session_data* tsd = iMap->id2sd(charid);
if (!tsd)
return;
@@ -15485,13 +15837,13 @@ void clif_parse_BattleChat(int fd, struct map_session_data* sd)
if( atcommand->parse(fd, sd, message, 1) )
return;
- if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
+ if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] || sd->sc.data[SC_DEEP_SLEEP] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
return;
if( battle_config.min_chat_delay ) {
- if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
+ if( DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0 )
return;
- sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
+ sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay;
}
bg_send_message(sd, text, textlen);
@@ -15573,48 +15925,61 @@ void clif_font(struct map_session_data *sd)
/*==========================================
* Instancing Window
*------------------------------------------*/
-int clif_instance(int instance_id, int type, int flag)
-{
- struct map_session_data *sd;
- struct party_data *p;
+int clif_instance(int instance_id, int type, int flag) {
+ struct map_session_data *sd = NULL;
unsigned char buf[255];
+ enum send_target target = PARTY;
+
+ switch( instances[instance_id].owner_type ) {
+ case IOT_NONE:
+ return 0;
+ case IOT_GUILD:
+ target = GUILD;
+ sd = guild->getavailablesd(guild->search(instances[instance_id].owner_id));
+ break;
+ case IOT_PARTY:
+ /* default is already PARTY */
+ sd = party->getavailablesd(party->search(instances[instance_id].owner_id));
+ break;
+ case IOT_CHAR:
+ target = SELF;
+ sd = iMap->id2sd(instances[instance_id].owner_id);
+ break;
+ }
- if( (p = party_search(instance[instance_id].party_id)) == NULL || (sd = party_getavailablesd(p)) == NULL )
+ if( !sd )
return 0;
-
+
switch( type ) {
case 1:
// S 0x2cb <Instance name>.61B <Standby Position>.W
// Required to start the instancing information window on Client
// This window re-appear each "refresh" of client automatically until type 4 is send to client.
WBUFW(buf,0) = 0x02CB;
- memcpy(WBUFP(buf,2),instance[instance_id].name,INSTANCE_NAME_LENGTH);
+ memcpy(WBUFP(buf,2),instances[instance_id].name,INSTANCE_NAME_LENGTH);
WBUFW(buf,63) = flag;
- clif->send(buf,packet_len(0x02CB),&sd->bl,PARTY);
+ clif->send(buf,packet_len(0x02CB),&sd->bl,target);
break;
case 2:
// S 0x2cc <Standby Position>.W
// To announce Instancing queue creation if no maps available
WBUFW(buf,0) = 0x02CC;
WBUFW(buf,2) = flag;
- clif->send(buf,packet_len(0x02CC),&sd->bl,PARTY);
+ clif->send(buf,packet_len(0x02CC),&sd->bl,target);
break;
case 3:
case 4:
// S 0x2cd <Instance Name>.61B <Instance Remaining Time>.L <Instance Noplayers close time>.L
WBUFW(buf,0) = 0x02CD;
- memcpy(WBUFP(buf,2),instance[instance_id].name,61);
- if( type == 3 )
- {
- WBUFL(buf,63) = (uint32)instance[instance_id].progress_timeout;
+ memcpy(WBUFP(buf,2),instances[instance_id].name,61);
+ if( type == 3 ) {
+ WBUFL(buf,63) = instances[instance_id].progress_timeout;
WBUFL(buf,67) = 0;
- }
- else
- {
+ } else {
WBUFL(buf,63) = 0;
- WBUFL(buf,67) = (uint32)instance[instance_id].idle_timeout;
+ WBUFL(buf,67) = instances[instance_id].idle_timeout;
}
- clif->send(buf,packet_len(0x02CD),&sd->bl,PARTY);
+ clif->send(buf,packet_len(0x02CD),&sd->bl,target);
break;
case 5:
// S 0x2ce <Message ID>.L
@@ -15626,7 +15991,7 @@ int clif_instance(int instance_id, int type, int flag)
WBUFW(buf,0) = 0x02CE;
WBUFL(buf,2) = flag;
//WBUFL(buf,6) = EnterLimitDate;
- clif->send(buf,packet_len(0x02CE),&sd->bl,PARTY);
+ clif->send(buf,packet_len(0x02CE),&sd->bl,target);
break;
}
return 0;
@@ -15634,24 +15999,24 @@ int clif_instance(int instance_id, int type, int flag)
void clif_instance_join(int fd, int instance_id)
{
- if( instance[instance_id].idle_timer != INVALID_TIMER ) {
+ if( instances[instance_id].idle_timer != INVALID_TIMER ) {
WFIFOHEAD(fd,packet_len(0x02CD));
WFIFOW(fd,0) = 0x02CD;
- memcpy(WFIFOP(fd,2),instance[instance_id].name,61);
+ memcpy(WFIFOP(fd,2),instances[instance_id].name,61);
WFIFOL(fd,63) = 0;
- WFIFOL(fd,67) = (uint32)instance[instance_id].idle_timeout;
+ WFIFOL(fd,67) = instances[instance_id].idle_timeout;
WFIFOSET(fd,packet_len(0x02CD));
- } else if( instance[instance_id].progress_timer != INVALID_TIMER ) {
+ } else if( instances[instance_id].progress_timer != INVALID_TIMER ) {
WFIFOHEAD(fd,packet_len(0x02CD));
WFIFOW(fd,0) = 0x02CD;
- memcpy(WFIFOP(fd,2),instance[instance_id].name,61);
- WFIFOL(fd,63) = (uint32)instance[instance_id].progress_timeout;;
+ memcpy(WFIFOP(fd,2),instances[instance_id].name,61);
+ WFIFOL(fd,63) = instances[instance_id].progress_timeout;
WFIFOL(fd,67) = 0;
WFIFOSET(fd,packet_len(0x02CD));
} else {
WFIFOHEAD(fd,packet_len(0x02CB));
WFIFOW(fd,0) = 0x02CB;
- memcpy(WFIFOP(fd,2),instance[instance_id].name,61);
+ memcpy(WFIFOP(fd,2),instances[instance_id].name,61);
WFIFOW(fd,63) = 0;
WFIFOSET(fd,packet_len(0x02CB));
}
@@ -15672,7 +16037,7 @@ void clif_party_show_picker(struct map_session_data * sd, struct item * item_dat
{
#if PACKETVER >= 20071002
unsigned char buf[22];
- struct item_data* id = itemdb_search(item_data->nameid);
+ struct item_data* id = itemdb->search(item_data->nameid);
WBUFW(buf,0) = 0x2b8;
WBUFL(buf,2) = sd->status.account_id;
@@ -16417,7 +16782,7 @@ int clif_spellbook_list(struct map_session_data *sd)
if( itemdb_is_spellbook(sd->status.inventory[i].nameid) )
{
WFIFOW(fd, c * 2 + 4) = sd->status.inventory[i].nameid;
- c ++;
+ c++;
}
}
@@ -16608,7 +16973,7 @@ void clif_parse_SkillSelectMenu(int fd, struct map_session_data *sd) {
/*==========================================
* Kagerou/Oboro amulet spirit
*------------------------------------------*/
-void clif_talisman(struct map_session_data *sd,short type)
+void clif_charm(struct map_session_data *sd,short type)
{
unsigned char buf[10];
@@ -16617,7 +16982,7 @@ void clif_talisman(struct map_session_data *sd,short type)
WBUFW(buf,0)=0x08cf;
WBUFL(buf,2)=sd->bl.id;
WBUFW(buf,6)=type;
- WBUFW(buf,8)=sd->talisman[type];
+ WBUFW(buf,8)=sd->charm[type];
clif->send(buf,packet_len(0x08cf),&sd->bl,AREA);
}
/// Move Item from or to Personal Tab (CZ_WHATSOEVER) [FE]
@@ -16694,12 +17059,12 @@ void clif_cashshop_db(void) {
}
if( name[0] == 'I' && name[1] == 'D' && strlen(name) <= 7 ) {
- if( !( data = itemdb_exists(atoi(name+2))) ) {
+ if( !( data = itemdb->exists(atoi(name+2))) ) {
ShowWarning("cashshop_db: unknown item id '%s' in category '%s'\n", name+2, entry_name);
continue;
}
} else {
- if( !( data = itemdb_searchname(name) ) ) {
+ if( !( data = itemdb->search_name(name) ) ) {
ShowWarning("cashshop_db: unknown item name '%s' in category '%s'\n", name, entry_name);
continue;
}
@@ -16759,7 +17124,6 @@ void clif_monster_hp_bar( struct mob_data* md, struct map_session_data *sd ) {
void __attribute__ ((unused)) clif_parse_dull(int fd,struct map_session_data *sd) {
return;
}
-
void clif_parse_CashShopOpen(int fd, struct map_session_data *sd) {
WFIFOHEAD(fd, 10);
WFIFOW(fd, 0) = 0x845;
@@ -16813,7 +17177,7 @@ void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) {
result = CSBR_SHORTTAGE_CASH;
} else if( (sd->cashPoints+kafra_pay) < (clif->cs.data[tab][j]->price * qty) ) {
result = CSBR_SHORTTAGE_CASH;
- } else if ( !( data = itemdb_exists(clif->cs.data[tab][j]->id) ) ) {
+ } else if ( !( data = itemdb->exists(clif->cs.data[tab][j]->id) ) ) {
result = CSBR_UNKONWN_ITEM;
} else {
struct item item_tmp;
@@ -16824,14 +17188,14 @@ void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) {
if (!itemdb_isstackable2(data))
get_count = 1;
- pc_paycash(sd, clif->cs.data[tab][j]->price * qty, kafra_pay);// [Ryuuzaki]
+ pc->paycash(sd, clif->cs.data[tab][j]->price * qty, kafra_pay);// [Ryuuzaki]
for (k = 0; k < qty; k += get_count) {
if (!pet_create_egg(sd, data->nameid)) {
memset(&item_tmp, 0, sizeof(item_tmp));
item_tmp.nameid = data->nameid;
item_tmp.identify = 1;
- switch (pc_additem(sd, &item_tmp, get_count, LOG_TYPE_NPC)) {
+ switch (pc->additem(sd, &item_tmp, get_count, LOG_TYPE_NPC)) {
case 0:
result = CSBR_SUCCESS;
break;
@@ -16853,7 +17217,7 @@ void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) {
}
if( result != CSBR_SUCCESS )
- pc_getcash(sd, clif->cs.data[tab][j]->price * get_count,0);
+ pc->getcash(sd, clif->cs.data[tab][j]->price * get_count,0);
}
}
}
@@ -16949,6 +17313,196 @@ void clif_status_change_end(struct block_list *bl, int tid, enum send_target tar
clif->send(&p,sizeof(p), bl, target);
}
+void clif_bgqueue_ack(struct map_session_data *sd, enum BATTLEGROUNDS_QUEUE_ACK response, unsigned char arena_id) {
+
+ switch (response) {
+ case BGQA_FAIL_COOLDOWN:
+ case BGQA_FAIL_DESERTER:
+ case BGQA_FAIL_TEAM_COUNT:
+ break;
+ default: {
+ struct packet_bgqueue_ack p;
+
+ p.PacketType = bgqueue_ackType;
+ p.type = response;
+ safestrncpy(p.bg_name, bg->arena[arena_id]->name, sizeof(p.bg_name));
+
+ clif->send(&p,sizeof(p), &sd->bl, SELF);
+ }
+ break;
+ }
+}
+
+
+void clif_bgqueue_notice_delete(struct map_session_data *sd, enum BATTLEGROUNDS_QUEUE_NOTICE_DELETED response, unsigned char arena_id) {
+ struct packet_bgqueue_notice_delete p;
+
+ p.PacketType = bgqueue_notice_deleteType;
+ p.type = response;
+ safestrncpy(p.bg_name, bg->arena[arena_id]->name, sizeof(p.bg_name));
+
+ clif->send(&p,sizeof(p), &sd->bl, SELF);
+}
+
+void clif_parse_bgqueue_register(int fd, struct map_session_data *sd) {
+ struct packet_bgqueue_register *p = P2PTR(fd, bgqueue_registerType);
+ struct bg_arena *arena = NULL;
+
+ if( !bg->queue_on ) return; /* temp, until feature is complete */
+
+ if( !(arena = bg->name2arena(p->bg_name)) ) {
+ clif->bgqueue_ack(sd,BGQA_FAIL_BGNAME_INVALID,0);
+ return;
+ }
+
+ switch( (enum bg_queue_types)p->type ) {
+ case BGQT_INDIVIDUAL:
+ case BGQT_PARTY:
+ case BGQT_GUILD:
+ break;
+ default:
+ clif->bgqueue_ack(sd,BGQA_FAIL_TYPE_INVALID, arena->id);
+ return;
+ }
+
+ bg->queue_add(sd, arena, (enum bg_queue_types)p->type);
+}
+
+void clif_bgqueue_update_info(struct map_session_data *sd, unsigned char arena_id, int position) {
+ struct packet_bgqueue_update_info p;
+
+ p.PacketType = bgqueue_updateinfoType;
+ safestrncpy(p.bg_name, bg->arena[arena_id]->name, sizeof(p.bg_name));
+ p.position = position;
+
+ sd->bg_queue.client_has_bg_data = true; // Client creates bg data when this packet arrives
+
+ clif->send(&p,sizeof(p), &sd->bl, SELF);
+}
+
+void clif_parse_bgqueue_checkstate(int fd, struct map_session_data *sd) {
+ //struct packet_bgqueue_checkstate *p = P2PTR(fd, bgqueue_checkstateType); /* TODO: bgqueue_notice_delete should use this p->bg_name */
+ if( !bg->queue_on ) return; /* temp, until feature is complete */
+ if ( sd->bg_queue.arena && sd->bg_queue.type ) {
+ sd->bg_queue.client_has_bg_data = true;
+ clif->bgqueue_update_info(sd,sd->bg_queue.arena->id,bg->id2pos(sd->bg_queue.arena->queue_id,sd->status.account_id));
+ } else
+ clif->bgqueue_notice_delete(sd, BGQND_FAIL_NOT_QUEUING,0);/* TODO: wrong response, should respond with p->bg_name not id 0 */
+}
+
+void clif_parse_bgqueue_revoke_req(int fd, struct map_session_data *sd) {
+ //struct packet_bgqueue_revoke_req *p = P2PTR(fd, bgqueue_revokereqType);
+ return;
+ //bg->queue_leave(sd, p->bg_name);
+}
+
+void clif_parse_bgqueue_battlebegin_ack(int fd, struct map_session_data *sd) {
+ struct packet_bgqueue_battlebegin_ack *p = P2PTR(fd, bgqueue_checkstateType);
+ struct bg_arena *arena;
+ if( !bg->queue_on ) return; /* temp, until feature is complete */
+ if( ( arena = bg->name2arena(p->bg_name) ) ) {
+ bg->queue_ready_ack(arena,sd, ( p->result == 1 ) ? true : false);
+ } else {
+ clif->bgqueue_ack(sd,BGQA_FAIL_BGNAME_INVALID, 0);
+ }
+ //if ( p->result == 1 )
+ // bg->queue_pc_ready(sd);
+ //else
+ // bg->queue_leave(sd, p->bg_name);
+}
+
+void clif_bgqueue_joined(struct map_session_data *sd, int pos) {
+ struct packet_bgqueue_notify_entry p;
+
+ p.PacketType = bgqueue_notify_entryType;
+ safestrncpy(p.name,sd->status.name,sizeof(p.name));
+ p.position = pos;
+
+ clif->send(&p,sizeof(p), &sd->bl, BG_QUEUE);
+}
+
+void clif_bgqueue_pcleft(struct map_session_data *sd) {
+ /* no idea */
+ return;
+}
+
+// Sends BG ready req to all with same bg arena/type as sd
+void clif_bgqueue_battlebegins(struct map_session_data *sd, unsigned char arena_id, enum send_target target) {
+ struct packet_bgqueue_battlebegins p;
+
+ p.PacketType = bgqueue_battlebegins;
+ safestrncpy(p.bg_name, bg->arena[arena_id]->name, sizeof(p.bg_name));
+ safestrncpy(p.game_name, bg->arena[arena_id]->name, sizeof(p.game_name));
+
+ clif->send(&p,sizeof(p), &sd->bl, target);
+}
+
+void clif_scriptclear(struct map_session_data *sd, int npcid) {
+ struct packet_script_clear p;
+
+ p.PacketType = script_clearType;
+ p.NpcID = npcid;
+
+ clif->send(&p,sizeof(p), &sd->bl, SELF);
+}
+/* Made Possible Thanks to Yommy! */
+void clif_package_item_announce(struct map_session_data *sd, unsigned short nameid, unsigned short containerid) {
+ struct packet_package_item_announce p;
+
+ p.PacketType = package_item_announceType;
+ p.PacketLength = 11+NAME_LENGTH;
+ p.type = 0x0;
+ p.ItemID = nameid;
+ p.len = NAME_LENGTH;
+ safestrncpy(p.Name, sd->status.name, sizeof(p.Name));
+ p.unknown = 0x2; // some strange byte, IDA shows.. BYTE3(BoxItemIDLength) = 2;
+ p.BoxItemID = containerid;
+
+ clif->send(&p,sizeof(p), &sd->bl, ALL_CLIENT);
+}
+/* */
+unsigned short clif_decrypt_cmd( int cmd, struct map_session_data *sd ) {
+ if( sd ) {
+ sd->cryptKey = (( sd->cryptKey * clif->cryptKey[1] ) + clif->cryptKey[2]) & 0xFFFFFFFF;
+ return (cmd ^ ((sd->cryptKey >> 16) & 0x7FFF));
+ }
+ return (cmd ^ (((( clif->cryptKey[0] * clif->cryptKey[1] ) + clif->cryptKey[2]) >> 16) & 0x7FFF));
+}
+unsigned short clif_parse_cmd_normal ( int fd, struct map_session_data *sd ) {
+ unsigned short cmd = RFIFOW(fd,0);
+ // filter out invalid / unsupported packets
+ if (cmd > MAX_PACKET_DB || packet_db[cmd].len == 0)
+ return 0;
+
+ return cmd;
+}
+unsigned short clif_parse_cmd_optional ( int fd, struct map_session_data *sd ) {
+ unsigned short cmd = RFIFOW(fd,0);
+
+ // filter out invalid / unsupported packets
+ if (cmd > MAX_PACKET_DB || packet_db[cmd].len == 0) {
+ cmd = clif->decrypt_cmd( cmd, sd );
+ if( cmd > MAX_PACKET_DB || packet_db[cmd].len == 0 )
+ return 0;
+ RFIFOW(fd, 0) = cmd;
+ }
+
+ return cmd;
+}
+unsigned short clif_parse_cmd_decrypt ( int fd, struct map_session_data *sd ) {
+ unsigned short cmd = RFIFOW(fd,0);
+
+ cmd = clif->decrypt_cmd( cmd, sd );
+
+ // filter out invalid / unsupported packets
+ if (cmd > MAX_PACKET_DB || packet_db[cmd].len == 0 )
+ return 0;
+
+ RFIFOW(fd, 0) = cmd;
+
+ return cmd;
+}
+
/*==========================================
* Main client packet processing function
*------------------------------------------*/
@@ -16979,7 +17533,7 @@ int clif_parse(int fd) {
} else {
//Unusual logout (during log on/off/map-changer procedure)
ShowInfo("Player AID:%d/CID:%d logged off.\n", sd->status.account_id, sd->status.char_id);
- map_quit(sd);
+ iMap->quit(sd);
}
} else {
ShowInfo("Closed connection from '"CL_WHITE"%s"CL_RESET"'.\n", ip2str(session[fd]->client_addr, NULL));
@@ -16991,19 +17545,18 @@ int clif_parse(int fd) {
if (RFIFOREST(fd) < 2)
return 0;
- cmd = RFIFOW(fd,0);
- // filter out invalid / unsupported packets
- if (cmd > MAX_PACKET_DB || packet_db[cmd].len == 0) {
- ShowWarning("clif_parse: Received unsupported packet (packet 0x%04x, %d bytes received), disconnecting session #%d.\n", cmd, RFIFOREST(fd), fd);
+ if( !( cmd = clif->parse_cmd(fd,sd) ) ) {
+ ShowWarning("clif_parse: Received unsupported packet (packet 0x%04x, %d bytes received), disconnecting session #%d.\n", RFIFOW(fd,0), RFIFOREST(fd), fd);
#ifdef DUMP_INVALID_PACKET
ShowDump(RFIFOP(fd,0), RFIFOREST(fd));
#endif
set_eof(fd);
return 0;
}
+
// determine real packet length
- packet_len = packet_db[cmd].len;
- if (packet_len == -1) { // variable-length packet
+ if ( ( packet_len = packet_db[cmd].len ) == -1) { // variable-length packet
+
if (RFIFOREST(fd) < 4)
return 0;
@@ -17014,9 +17567,11 @@ int clif_parse(int fd) {
ShowDump(RFIFOP(fd,0), RFIFOREST(fd));
#endif
set_eof(fd);
+
return 0;
}
}
+
if ((int)RFIFOREST(fd) < packet_len)
return 0; // not enough data received to form the packet
@@ -17109,14 +17664,29 @@ void packetdb_loaddb(void) {
memset(packet_db,0,sizeof(packet_db));
#define packet(id, size, ...) packetdb_addpacket(id, size, ##__VA_ARGS__, 0xFFFF)
+ #define packetKeys(a,b,c) { clif->cryptKey[0] = a; clif->cryptKey[1] = b; clif->cryptKey[2] = c; }
#include "packets.h" /* load structure data */
#undef packet
+ #undef packetKeys
}
void clif_bc_ready(void) {
if( battle_config.display_status_timers )
clif->status_change = clif_status_change;
else
clif->status_change = clif_status_change_notick;
+
+ switch( battle_config.packet_obfuscation ) {
+ case 0:
+ clif->parse_cmd = clif_parse_cmd_normal;
+ break;
+ default:
+ case 1:
+ clif->parse_cmd = clif_parse_cmd_optional;
+ break;
+ case 2:
+ clif->parse_cmd = clif_parse_cmd_decrypt;
+ break;
+ }
}
/*==========================================
*
@@ -17124,6 +17694,7 @@ void clif_bc_ready(void) {
int do_init_clif(void) {
const char* colors[COLOR_MAX] = { "0xFF0000", "0x00ff00", "0xffffff" };
int i;
+
/**
* Setup Color Table (saves unnecessary load of strtoul on every call)
**/
@@ -17140,8 +17711,8 @@ int do_init_clif(void) {
exit(EXIT_FAILURE);
}
- add_timer_func_list(clif->clearunit_delayed_sub, "clif_clearunit_delayed_sub");
- add_timer_func_list(clif->delayquit, "clif_delayquit");
+ iTimer->add_timer_func_list(clif->clearunit_delayed_sub, "clif_clearunit_delayed_sub");
+ iTimer->add_timer_func_list(clif->delayquit, "clif_delayquit");
clif->delay_clearunit_ers = ers_new(sizeof(struct block_list),"clif.c::delay_clearunit_ers",ERS_OPT_CLEAR);
@@ -17199,6 +17770,8 @@ void clif_defaults(void) {
clif->send = clif_send;
clif->send_sub = clif_send_sub;
clif->parse = clif_parse;
+ clif->parse_cmd = clif_parse_cmd_optional;
+ clif->decrypt_cmd = clif_decrypt_cmd;
/* auth */
clif->authok = clif_authok;
clif->authrefuse = clif_authrefuse;
@@ -17279,6 +17852,7 @@ void clif_defaults(void) {
clif->scriptinputstr = clif_scriptinputstr;
clif->cutin = clif_cutin;
clif->sendfakenpc = clif_sendfakenpc;
+ clif->scriptclear = clif_scriptclear;
/* client-user-interface-related */
clif->viewpoint = clif_viewpoint;
clif->damage = clif_damage;
@@ -17296,7 +17870,7 @@ void clif_defaults(void) {
clif->skill_fail = clif_skill_fail;
clif->skill_cooldown = clif_skill_cooldown;
clif->skill_memomessage = clif_skill_memomessage;
- clif->skill_teleportmessage = clif_skill_teleportmessage;
+ clif->skill_mapinfomessage = clif_skill_mapinfomessage;
clif->skill_produce_mix_list = clif_skill_produce_mix_list;
clif->cooking_list = clif_cooking_list;
clif->autospell = clif_autospell;
@@ -17337,7 +17911,7 @@ void clif_defaults(void) {
clif->equiptickack = clif_equiptickack;
clif->viewequip_ack = clif_viewequip_ack;
clif->viewequip_fail = clif_viewequip_fail;
- clif->equipcheckbox = clif_equipcheckbox;
+ clif->equpcheckbox = clif_equpcheckbox;
clif->displayexp = clif_displayexp;
clif->font = clif_font;
clif->progressbar = clif_progressbar;
@@ -17397,8 +17971,8 @@ void clif_defaults(void) {
clif->specialeffect_single = clif_specialeffect_single;
clif->specialeffect_value = clif_specialeffect_value;
clif->millenniumshield = clif_millenniumshield;
- clif->talisman = clif_talisman;
- clif->talisman_single = clif_talisman_single;
+ clif->charm = clif_charm;
+ clif->charm_single = clif_charm_single;
clif->snap = clif_snap;
clif->weather_check = clif_weather_check;
/* sound effects client-side */
@@ -17592,6 +18166,14 @@ void clif_defaults(void) {
clif->PartyBookingUpdateNotify = clif_PartyBookingUpdateNotify;
clif->PartyBookingDeleteNotify = clif_PartyBookingDeleteNotify;
clif->PartyBookingInsertNotify = clif_PartyBookingInsertNotify;
+ /* Group Search System Update */
+#ifdef PARTY_RECRUIT
+ clif->PartyBookingVolunteerInfo = clif_PartyBookingVolunteerInfo;
+ clif->PartyBookingRefuseVolunteer = clif_PartyBookingRefuseVolunteer;
+ clif->PartyBookingCancelVolunteer = clif_PartyBookingCancelVolunteer;
+ clif->PartyBookingAddFilteringList = clif_PartyBookingAddFilteringList;
+ clif->PartyBookingSubFilteringList = clif_PartyBookingSubFilteringList;
+#endif
/* buying store-related */
clif->buyingstore_open = clif_buyingstore_open;
clif->buyingstore_open_failed = clif_buyingstore_open_failed;
@@ -17613,13 +18195,7 @@ void clif_defaults(void) {
/* elemental-related */
clif->elemental_info = clif_elemental_info;
clif->elemental_updatestatus = clif_elemental_updatestatus;
- /* misc-handling */
- clif->adopt_reply = clif_Adopt_reply;
- clif->adopt_request = clif_Adopt_request;
- clif->readbook = clif_readbook;
- clif->notify_time = clif_notify_time;
- clif->user_count = clif_user_count;
- clif->noask_sub = clif_noask_sub;
+ /* Hercules Channel System */
clif->chsys_create = clif_hercules_chsys_create;
clif->chsys_msg = clif_hercules_chsys_msg;
clif->chsys_msg2 = clif_hercules_chsys_msg2;
@@ -17632,7 +18208,22 @@ void clif_defaults(void) {
clif->chsys_quitg = clif_hercules_chsys_quitg;
clif->chsys_gjoin = clif_hercules_chsys_gjoin;
clif->chsys_gleave = clif_hercules_chsys_gleave;
+ /* bgqueue */
+ clif->bgqueue_ack = clif_bgqueue_ack;
+ clif->bgqueue_notice_delete = clif_bgqueue_notice_delete;
+ clif->bgqueue_update_info = clif_bgqueue_update_info;
+ clif->bgqueue_joined = clif_bgqueue_joined;
+ clif->bgqueue_pcleft = clif_bgqueue_pcleft;
+ clif->bgqueue_battlebegins = clif_bgqueue_battlebegins;
+ /* misc-handling */
+ clif->adopt_reply = clif_Adopt_reply;
+ clif->adopt_request = clif_Adopt_request;
+ clif->readbook = clif_readbook;
+ clif->notify_time = clif_notify_time;
+ clif->user_count = clif_user_count;
+ clif->noask_sub = clif_noask_sub;
clif->cashshop_load = clif_cashshop_db;
+ clif->package_announce = clif_package_item_announce;
clif->bc_ready = clif_bc_ready;
clif->undisguise_timer = clif_undisguise_timer;
/*------------------------
@@ -17837,9 +18428,22 @@ void clif_defaults(void) {
clif->pCashShopReqTab = clif_parse_CashShopReqTab;
clif->pCashShopSchedule = clif_parse_CashShopSchedule;
clif->pCashShopBuy = clif_parse_CashShopBuy;
+ /* BGQueue */
+ clif->pBGQueueRegister = clif_parse_bgqueue_register;
+ clif->pBGQueueCheckState = clif_parse_bgqueue_checkstate;
+ clif->pBGQueueRevokeReq = clif_parse_bgqueue_revoke_req;
+ clif->pBGQueueBattleBeginAck = clif_parse_bgqueue_battlebegin_ack;
/* */
clif->pPartyTick = clif_parse_PartyTick;
clif->pGuildInvite2 = clif_parse_GuildInvite2;
+ /* Group Search System Update */
+#ifdef PARTY_RECRUIT
+ clif->pPartyBookingAddFilter = clif_parse_PartyBookingAddFilteringList;
+ clif->pPartyBookingSubFilter = clif_parse_PartyBookingSubFilteringList;
+ clif->pPartyBookingReqVolunteer = clif_parse_PartyBookingReqVolunteer;
+ clif->pPartyBookingRefuseVolunteer = clif_parse_PartyBookingRefuseVolunteer;
+ clif->pPartyBookingCancelVolunteer = clif_parse_PartyBookingCancelVolunteer;
+#endif
/* dull */
clif->pDull = clif_parse_dull;
}
diff --git a/src/map/clif.h b/src/map/clif.h
index 3e3db98c1..bea701223 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -8,6 +8,7 @@
#include "../common/cbasetypes.h"
#include "../common/db.h"
#include "../common/mmo.h"
+#include "../common/socket.h"
#include <stdarg.h>
/**
@@ -42,6 +43,7 @@ struct eri;
* Defines
**/
#define packet_len(cmd) packet_db[cmd].len
+#define P2PTR(fd,cmd) RFIFO2PTR(fd,packet_db[cmd].len)
#define clif_menuskill_clear(sd) (sd)->menuskill_id = (sd)->menuskill_val = (sd)->menuskill_val2 = 0;
#define HCHSYS_NAME_LENGTH 20
@@ -86,6 +88,8 @@ typedef enum send_target {
BG_SAMEMAP_WOS,
BG_AREA,
BG_AREA_WOS,
+
+ BG_QUEUE,
} send_target;
typedef enum emotion_type {
@@ -227,7 +231,7 @@ enum map_type { // clif_map_type
MAPTYPE_UNUSED = 29,
};
-enum useskill_fail_cause { // clif_skill_fail
+typedef enum useskill_fail_cause { // clif_skill_fail
USESKILL_FAIL_LEVEL = 0,
USESKILL_FAIL_SP_INSUFFICIENT = 1,
USESKILL_FAIL_HP_INSUFFICIENT = 2,
@@ -268,7 +272,7 @@ enum useskill_fail_cause { // clif_skill_fail
USESKILL_FAIL_CANONBALL = 37,
//XXX_USESKILL_FAIL_II_MADOGEAR_ACCELERATION = 38,
//XXX_USESKILL_FAIL_II_MADOGEAR_HOVERING_BOOSTER = 39,
- USESKILL_FAIL_MADOGEAR_HOVERING = 40,
+ //XXX_USESKILL_FAIL_MADOGEAR_HOVERING = 40,
//XXX_USESKILL_FAIL_II_MADOGEAR_SELFDESTRUCTION_DEVICE = 41,
//XXX_USESKILL_FAIL_II_MADOGEAR_SHAPESHIFTER = 42,
USESKILL_FAIL_GUILLONTINE_POISON = 43,
@@ -312,7 +316,7 @@ enum useskill_fail_cause { // clif_skill_fail
USESKILL_FAIL_STYLE_CHANGE_FIGHTER = 81,
USESKILL_FAIL_STYLE_CHANGE_GRAPPLER = 82,
USESKILL_FAIL_THERE_ARE_NPC_AROUND = 83,
-};
+}useskill_fail_cause;
enum clif_messages {
SKILL_CANT_USE_AREA = 0x536,
@@ -365,6 +369,29 @@ enum CASH_SHOP_BUY_RESULT {
CSBR_UNKNOWN = 0xb,
};
+enum BATTLEGROUNDS_QUEUE_ACK {
+ BGQA_SUCCESS = 1,
+ BGQA_FAIL_QUEUING_FINISHED,
+ BGQA_FAIL_BGNAME_INVALID,
+ BGQA_FAIL_TYPE_INVALID,
+ BGQA_FAIL_PPL_OVERAMOUNT,
+ BGQA_FAIL_LEVEL_INCORRECT,
+ BGQA_DUPLICATE_REQUEST,
+ BGQA_PLEASE_RELOGIN,
+ BGQA_NOT_PARTY_GUILD_LEADER,
+ BGQA_FAIL_CLASS_INVALID,
+ /* not official way to respond (gotta find packet?) */
+ BGQA_FAIL_DESERTER,
+ BGQA_FAIL_COOLDOWN,
+ BGQA_FAIL_TEAM_COUNT,
+};
+
+enum BATTLEGROUNDS_QUEUE_NOTICE_DELETED {
+ BGQND_CLOSEWINDOW = 1,
+ BGQND_FAIL_BGNAME_WRONG = 3,
+ BGQND_FAIL_NOT_QUEUING = 11,
+};
+
/**
* Structures
**/
@@ -385,7 +412,7 @@ struct {
unsigned char local_color, ally_color, irc_color;
bool closing;
bool allow_user_channel_creation;
- char irc_server[40], irc_channel[20], irc_nick[30], irc_nick_pw[30];
+ char irc_server[40], irc_channel[50], irc_nick[40], irc_nick_pw[30];
unsigned short irc_server_port;
} hChSys;
@@ -435,6 +462,8 @@ struct clif_interface {
struct hCSData **data[CASHSHOP_TAB_MAX];
unsigned int item_count[CASHSHOP_TAB_MAX];
} cs;
+ /* */
+ unsigned int cryptKey[3];
/* core */
int (*init) (void);
void (*final) (void);
@@ -445,6 +474,8 @@ struct clif_interface {
int (*send) (const void* buf, int len, struct block_list* bl, enum send_target type);
int (*send_sub) (struct block_list *bl, va_list ap);
int (*parse) (int fd);
+ unsigned short (*parse_cmd) ( int fd, struct map_session_data *sd );
+ unsigned short (*decrypt_cmd) ( int cmd, struct map_session_data *sd );
/* auth */
void (*authok) (struct map_session_data *sd);
void (*authrefuse) (int fd, uint8 error_code);
@@ -470,6 +501,7 @@ struct clif_interface {
void (*item_sub) (unsigned char *buf, int n, struct item *i, struct item_data *id, int equip);
void (*getareachar_item) (struct map_session_data* sd,struct flooritem_data* fitem);
void (*cashshop_load) (void);
+ void (*package_announce) (struct map_session_data *sd, unsigned short nameid, unsigned short containerid);
/* unit-related */
void (*clearunit_single) (int id, clr_type type, int fd);
void (*clearunit_area) (struct block_list* bl, clr_type type);
@@ -499,7 +531,7 @@ struct clif_interface {
/* main unit spawn */
int (*spawn) (struct block_list *bl);
/* map-related */
- void (*changemap) (struct map_session_data *sd, short map, int x, int y);
+ void (*changemap) (struct map_session_data *sd, short m, int x, int y);
void (*changemapcell) (int fd, int16 m, int x, int y, int type, enum send_target target);
void (*map_property) (struct map_session_data* sd, enum map_property property);
void (*pvpset) (struct map_session_data *sd, int pvprank, int pvpnum,int type);
@@ -526,6 +558,7 @@ struct clif_interface {
void (*scriptinputstr) (struct map_session_data *sd, int npcid);
void (*cutin) (struct map_session_data* sd, const char* image, int type);
void (*sendfakenpc) (struct map_session_data *sd, int npcid);
+ void (*scriptclear) (struct map_session_data *sd, int npcid);
/* client-user-interface-related */
void (*viewpoint) (struct map_session_data *sd, int npc_id, int type, int x, int y, int id, int color);
int (*damage) (struct block_list* src, struct block_list* dst, unsigned int tick, int sdelay, int ddelay, int damage, int div, int type, int damage2);
@@ -543,7 +576,7 @@ struct clif_interface {
void (*skill_fail) (struct map_session_data *sd,uint16 skill_id,enum useskill_fail_cause cause,int btype);
void (*skill_cooldown) (struct map_session_data *sd, uint16 skill_id, unsigned int tick);
void (*skill_memomessage) (struct map_session_data* sd, int type);
- void (*skill_teleportmessage) (struct map_session_data *sd, int type);
+ void (*skill_mapinfomessage) (struct map_session_data *sd, int type);
void (*skill_produce_mix_list) (struct map_session_data *sd, int skill_id, int trigger);
void (*cooking_list) (struct map_session_data *sd, int trigger, uint16 skill_id, int qty, int list_type);
void (*autospell) (struct map_session_data *sd,uint16 skill_lv);
@@ -584,7 +617,7 @@ struct clif_interface {
void (*equiptickack) (struct map_session_data* sd, int flag);
void (*viewequip_ack) (struct map_session_data* sd, struct map_session_data* tsd);
void (*viewequip_fail) (struct map_session_data* sd);
- void (*equipcheckbox) (struct map_session_data* sd);
+ void (*equpcheckbox) (struct map_session_data* sd);
void (*displayexp) (struct map_session_data *sd, unsigned int exp, char type, bool quest);
void (*font) (struct map_session_data *sd);
void (*progressbar) (struct map_session_data * sd, unsigned long color, unsigned int second);
@@ -644,8 +677,8 @@ struct clif_interface {
void (*specialeffect_single) (struct block_list* bl, int type, int fd);
void (*specialeffect_value) (struct block_list* bl, int effect_id, int num, send_target target);
void (*millenniumshield) (struct map_session_data *sd, short shields );
- void (*talisman) (struct map_session_data *sd, short type);
- void (*talisman_single) (int fd, struct map_session_data *sd, short type);
+ void (*charm) (struct map_session_data *sd, short type);
+ void (*charm_single) (int fd, struct map_session_data *sd, short type);
void (*snap) ( struct block_list *bl, short x, short y );
void (*weather_check) (struct map_session_data *sd);
/* sound effects client-side */
@@ -839,6 +872,14 @@ struct clif_interface {
void (*PartyBookingUpdateNotify) (struct map_session_data* sd, struct party_booking_ad_info* pb_ad);
void (*PartyBookingDeleteNotify) (struct map_session_data* sd, int index);
void (*PartyBookingInsertNotify) (struct map_session_data* sd, struct party_booking_ad_info* pb_ad);
+ /* Group Search System Update */
+#ifdef PARTY_RECRUIT
+ void (*PartyBookingVolunteerInfo) (int index, struct map_session_data *sd);
+ void (*PartyBookingRefuseVolunteer) (unsigned long aid, struct map_session_data *sd);
+ void (*PartyBookingCancelVolunteer) (int index, struct map_session_data *sd);
+ void (*PartyBookingAddFilteringList) (int index, struct map_session_data *sd);
+ void (*PartyBookingSubFilteringList) (int gid, struct map_session_data *sd);
+#endif
/* buying store-related */
void (*buyingstore_open) (struct map_session_data* sd);
void (*buyingstore_open_failed) (struct map_session_data* sd, unsigned short result, unsigned int weight);
@@ -860,6 +901,13 @@ struct clif_interface {
/* elemental-related */
void (*elemental_info) (struct map_session_data *sd);
void (*elemental_updatestatus) (struct map_session_data *sd, int type);
+ /* bgqueue */
+ void (*bgqueue_ack) (struct map_session_data *sd, enum BATTLEGROUNDS_QUEUE_ACK response, unsigned char arena_id);
+ void (*bgqueue_notice_delete) (struct map_session_data *sd, enum BATTLEGROUNDS_QUEUE_NOTICE_DELETED response, unsigned char arena_id);
+ void (*bgqueue_update_info) (struct map_session_data *sd, unsigned char arena_id, int position);
+ void (*bgqueue_joined) (struct map_session_data *sd, int pos);
+ void (*bgqueue_pcleft) (struct map_session_data *sd);
+ void (*bgqueue_battlebegins) (struct map_session_data *sd, unsigned char arena_id, enum send_target target);
/* misc-handling */
void (*adopt_reply) (struct map_session_data *sd, int type);
void (*adopt_request) (struct map_session_data *sd, struct map_session_data *src, int p_id);
@@ -1078,6 +1126,11 @@ struct clif_interface {
void (*pSkillSelectMenu) (int fd, struct map_session_data *sd);
void (*pMoveItem) (int fd, struct map_session_data *sd);
void (*pDull) (int fd, struct map_session_data *sd);
+ /* BGQueue */
+ void (*pBGQueueRegister) (int fd, struct map_session_data *sd);
+ void (*pBGQueueCheckState) (int fd, struct map_session_data *sd);
+ void (*pBGQueueRevokeReq) (int fd, struct map_session_data *sd);
+ void (*pBGQueueBattleBeginAck) (int fd, struct map_session_data *sd);
/* RagExe Cash Shop [Ind/Hercules] */
void (*pCashShopOpen) (int fd, struct map_session_data *sd);
void (*pCashShopClose) (int fd, struct map_session_data *sd);
@@ -1086,6 +1139,14 @@ struct clif_interface {
void (*pCashShopBuy) (int fd, struct map_session_data *sd);
void (*pPartyTick) (int fd, struct map_session_data *sd);
void (*pGuildInvite2) (int fd, struct map_session_data *sd);
+ /* Group Search System Update */
+#ifdef PARTY_RECRUIT
+ void (*pPartyBookingAddFilter) (int fd, struct map_session_data *sd);
+ void (*pPartyBookingSubFilter) (int fd, struct map_session_data *sd);
+ void (*pPartyBookingReqVolunteer) (int fd, struct map_session_data *sd);
+ void (*pPartyBookingRefuseVolunteer) (int fd, struct map_session_data *sd);
+ void (*pPartyBookingCancelVolunteer) (int fd, struct map_session_data *sd);
+#endif
} clif_s;
struct clif_interface *clif;
diff --git a/src/map/duel.c b/src/map/duel.c
index 7af427304..9a8b6d12b 100644
--- a/src/map/duel.c
+++ b/src/map/duel.c
@@ -75,7 +75,7 @@ void duel_showinfo(const unsigned int did, struct map_session_data* sd)
duel_list[did].members_count + duel_list[did].invites_count);
clif->disp_onlyself(sd, output, strlen(output));
- map_foreachpc(duel_showinfo_sub, sd, &p);
+ iMap->map_foreachpc(duel_showinfo_sub, sd, &p);
}
int duel_create(struct map_session_data* sd, const unsigned int maxpl)
@@ -135,7 +135,7 @@ void duel_leave(const unsigned int did, struct map_session_data* sd)
duel_list[did].members_count--;
if(duel_list[did].members_count == 0) {
- map_foreachpc(duel_leave_sub, did);
+ iMap->map_foreachpc(duel_leave_sub, did);
duel_count--;
}
diff --git a/src/map/elemental.c b/src/map/elemental.c
index dfe1a0c5b..53c85577b 100644
--- a/src/map/elemental.c
+++ b/src/map/elemental.c
@@ -77,27 +77,27 @@ int elemental_create(struct map_session_data *sd, int class_, unsigned int lifet
ele.mode = EL_MODE_PASSIVE; // Initial mode
i = db->status.size+1; // summon level
- //[(Caster’s Max HP/ 3 ) + (Caster’s INT x 10 )+ (Caster’s Job Level x 20 )] x [(Elemental Summon Level + 2) / 3]
+ //[(Caster�s Max HP/ 3 ) + (Caster�s INT x 10 )+ (Caster�s Job Level x 20 )] x [(Elemental Summon Level + 2) / 3]
ele.hp = ele.max_hp = (sd->battle_status.max_hp/3 + sd->battle_status.int_*10 + sd->status.job_level) * ((i + 2) / 3);
- //Caster’s Max SP /4
+ //Caster�s Max SP /4
ele.sp = ele.max_sp = sd->battle_status.max_sp/4;
- //Caster’s [ Max SP / (18 / Elemental Summon Skill Level) 1- 100 ]
+ //Caster�s [ Max SP / (18 / Elemental Summon Skill Level) 1- 100 ]
ele.atk = (sd->battle_status.max_sp / (18 / i) * 1 - 100);
- //Caster’s [ Max SP / (18 / Elemental Summon Skill Level) ]
+ //Caster�s [ Max SP / (18 / Elemental Summon Skill Level) ]
ele.atk2 = sd->battle_status.max_sp / 18;
- //Caster’s HIT + (Caster’s Base Level )
+ //Caster�s HIT + (Caster�s Base Level )
ele.hit = sd->battle_status.hit + sd->status.base_level;
- //[Elemental Summon Skill Level x (Caster’s INT / 2 + Caster’s DEX / 4)]
+ //[Elemental Summon Skill Level x (Caster�s INT / 2 + Caster�s DEX / 4)]
ele.matk = i * (sd->battle_status.int_ / 2 + sd->battle_status.dex / 4);
- //150 + [Caster’s DEX / 10] + [Elemental Summon Skill Level x 3 ]
+ //150 + [Caster�s DEX / 10] + [Elemental Summon Skill Level x 3 ]
ele.amotion = 150 + sd->battle_status.dex / 10 + i * 3;
- //Caster’s DEF + (Caster’s Base Level / (5 – Elemental Summon Skill Level)
+ //Caster�s DEF + (Caster�s Base Level / (5 � Elemental Summon Skill Level)
ele.def = sd->battle_status.def + sd->status.base_level / (5-i);
- //Caster’s MDEF + (Caster’s INT / (5 - Elemental Summon Skill Level)
+ //Caster�s MDEF + (Caster�s INT / (5 - Elemental Summon Skill Level)
ele.mdef = sd->battle_status.mdef + sd->battle_status.int_ / (5-i);
- //Caster’s FLEE + (Caster’s Base Level / (5 – Elemental Summon Skill Level)
+ //Caster�s FLEE + (Caster�s Base Level / (5 � Elemental Summon Skill Level)
ele.flee = sd->status.base_level / (5-i);
- //Caster’s HIT + (Caster’s Base Level )
+ //Caster�s HIT + (Caster�s Base Level )
ele.hit = sd->battle_status.hit + sd->status.base_level;
//per individual bonuses
@@ -126,7 +126,7 @@ int elemental_create(struct map_session_data *sd, int class_, unsigned int lifet
break;
}
- if( (i=pc_checkskill(sd,SO_EL_SYMPATHY)) > 0 ){
+ if( (i=pc->checkskill(sd,SO_EL_SYMPATHY)) > 0 ){
ele.hp = ele.max_hp = ele.max_hp * 5 * i / 100;
ele.sp = ele.max_sp = ele.max_sp * 5 * i / 100;
ele.atk += 25 * i;
@@ -147,8 +147,8 @@ int elemental_get_lifetime(struct elemental_data *ed) {
if( ed == NULL || ed->summon_timer == INVALID_TIMER )
return 0;
- td = get_timer(ed->summon_timer);
- return (td != NULL) ? DIFF_TICK(td->tick, gettick()) : 0;
+ td = iTimer->get_timer(ed->summon_timer);
+ return (td != NULL) ? DIFF_TICK(td->tick, iTimer->gettick()) : 0;
}
int elemental_save(struct elemental_data *ed) {
@@ -173,7 +173,7 @@ static int elemental_summon_end(int tid, unsigned int tick, int id, intptr_t dat
struct map_session_data *sd;
struct elemental_data *ed;
- if( (sd = map_id2sd(id)) == NULL )
+ if( (sd = iMap->id2sd(id)) == NULL )
return 1;
if( (ed = sd->ed) == NULL )
return 1;
@@ -192,13 +192,12 @@ static int elemental_summon_end(int tid, unsigned int tick, int id, intptr_t dat
void elemental_summon_stop(struct elemental_data *ed) {
nullpo_retv(ed);
if( ed->summon_timer != INVALID_TIMER )
- delete_timer(ed->summon_timer, elemental_summon_end);
+ iTimer->delete_timer(ed->summon_timer, elemental_summon_end);
ed->summon_timer = INVALID_TIMER;
}
int elemental_delete(struct elemental_data *ed, int reply) {
struct map_session_data *sd;
-
nullpo_ret(ed);
sd = ed->master;
@@ -218,7 +217,7 @@ int elemental_delete(struct elemental_data *ed, int reply) {
void elemental_summon_init(struct elemental_data *ed) {
if( ed->summon_timer == INVALID_TIMER )
- ed->summon_timer = add_timer(gettick() + ed->elemental.life_time, elemental_summon_end, ed->master->bl.id, 0);
+ ed->summon_timer = iTimer->add_timer(iTimer->gettick() + ed->elemental.life_time, elemental_summon_end, ed->master->bl.id, 0);
ed->regen.state.block = 0;
}
@@ -229,7 +228,7 @@ int elemental_data_received(struct s_elemental *ele, bool flag) {
struct s_elemental_db *db;
int i = elemental_search_index(ele->class_);
- if( (sd = map_charid2sd(ele->char_id)) == NULL )
+ if( (sd = iMap->charid2sd(ele->char_id)) == NULL )
return 0;
if( !flag || i < 0 ) { // Not created - loaded - DB info
@@ -258,9 +257,9 @@ int elemental_data_received(struct s_elemental *ele, bool flag) {
ed->bl.x = ed->ud.to_x;
ed->bl.y = ed->ud.to_y;
- map_addiddb(&ed->bl);
+ iMap->addiddb(&ed->bl);
status_calc_elemental(ed,1);
- ed->last_spdrain_time = ed->last_thinktime = gettick();
+ ed->last_spdrain_time = ed->last_thinktime = iTimer->gettick();
ed->summon_timer = INVALID_TIMER;
elemental_summon_init(ed);
} else {
@@ -271,7 +270,7 @@ int elemental_data_received(struct s_elemental *ele, bool flag) {
sd->status.ele_id = ele->elemental_id;
if( ed->bl.prev == NULL && sd->bl.prev != NULL ) {
- map_addblock(&ed->bl);
+ iMap->addblock(&ed->bl);
clif->spawn(&ed->bl);
clif->elemental_info(sd);
clif->elemental_updatestatus(sd,SP_HP);
@@ -433,9 +432,9 @@ int elemental_action(struct elemental_data *ed, struct block_list *bl, unsigned
ed->ud.skill_lv = skill_lv;
if( skill->get_inf(skill_id) & INF_GROUND_SKILL )
- ed->ud.skilltimer = add_timer( tick+status_get_speed(&ed->bl)*walk_dist, skill->castend_pos, ed->bl.id, 0 );
+ ed->ud.skilltimer = iTimer->add_timer( tick+status_get_speed(&ed->bl)*walk_dist, skill->castend_pos, ed->bl.id, 0 );
else
- ed->ud.skilltimer = add_timer( tick+status_get_speed(&ed->bl)*walk_dist, skill->castend_id, ed->bl.id, 0 );
+ ed->ud.skilltimer = iTimer->add_timer( tick+status_get_speed(&ed->bl)*walk_dist, skill->castend_id, ed->bl.id, 0 );
}
return 1;
@@ -493,11 +492,11 @@ int elemental_change_mode_ack(struct elemental_data *ed, int mode) {
if( ed->ud.skilltimer != INVALID_TIMER )
return 0;
- else if( DIFF_TICK(gettick(), ed->ud.canact_tick) < 0 )
+ else if( DIFF_TICK(iTimer->gettick(), ed->ud.canact_tick) < 0 )
return 0;
ed->target_id = bl->id; // Set new target
- ed->last_thinktime = gettick();
+ ed->last_thinktime = iTimer->gettick();
if( skill->get_inf(skill_id) & INF_GROUND_SKILL )
unit_skilluse_pos(&ed->bl, bl->x, bl->y, skill_id, skill_lv);
@@ -707,16 +706,16 @@ static int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_
return 0; //Already walking to him
if( DIFF_TICK(tick, ed->ud.canmove_tick) < 0 )
return 0; //Can't move yet.
- if( map_search_freecell(&ed->bl, sd->bl.m, &x, &y, MIN_ELEDISTANCE, MIN_ELEDISTANCE, 1)
+ if( iMap->search_freecell(&ed->bl, sd->bl.m, &x, &y, MIN_ELEDISTANCE, MIN_ELEDISTANCE, 1)
&& unit_walktoxy(&ed->bl, x, y, 0) )
return 0;
}
if( mode == EL_MODE_AGGRESSIVE ) {
- target = map_id2bl(ed->ud.target);
+ target = iMap->id2bl(ed->ud.target);
if( !target )
- map_foreachinrange(elemental_ai_sub_timer_activesearch, &ed->bl, view_range, BL_CHAR, ed, &target, status_get_mode(&ed->bl));
+ iMap->foreachinrange(elemental_ai_sub_timer_activesearch, &ed->bl, view_range, BL_CHAR, ed, &target, status_get_mode(&ed->bl));
if( !target ) { //No targets available.
elemental_unlocktarget(ed);
@@ -755,7 +754,7 @@ static int elemental_ai_sub_foreachclient(struct map_session_data *sd, va_list a
}
static int elemental_ai_timer(int tid, unsigned int tick, int id, intptr_t data) {
- map_foreachpc(elemental_ai_sub_foreachclient,tick);
+ iMap->map_foreachpc(elemental_ai_sub_foreachclient,tick);
return 0;
}
@@ -767,7 +766,7 @@ int read_elementaldb(void) {
struct s_elemental_db *db;
struct status_data *status;
- sprintf(line, "%s/%s", db_path, "elemental_db.txt");
+ sprintf(line, "%s/%s", iMap->db_path, "elemental_db.txt");
memset(elemental_db,0,sizeof(elemental_db));
fp = fopen(line, "r");
@@ -858,7 +857,7 @@ int read_elemental_skilldb(void) {
uint16 skill_id, skill_lv;
int skillmode;
- sprintf(line, "%s/%s", db_path, "elemental_skill_db.txt");
+ sprintf(line, "%s/%s", iMap->db_path, "elemental_skill_db.txt");
fp = fopen(line, "r");
if( !fp ) {
ShowError("read_elemental_skilldb : can't read elemental_skill_db.txt\n");
@@ -934,8 +933,8 @@ int do_init_elemental(void) {
read_elementaldb();
read_elemental_skilldb();
- add_timer_func_list(elemental_ai_timer,"elemental_ai_timer");
- add_timer_interval(gettick()+MIN_ELETHINKTIME,elemental_ai_timer,0,0,MIN_ELETHINKTIME);
+ iTimer->add_timer_func_list(elemental_ai_timer,"elemental_ai_timer");
+ iTimer->add_timer_interval(iTimer->gettick()+MIN_ELETHINKTIME,elemental_ai_timer,0,0,MIN_ELETHINKTIME);
return 0;
}
diff --git a/src/map/guild.c b/src/map/guild.c
index b83f05f00..e093fdf92 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -24,6 +24,7 @@
#include "clif.h"
#include "skill.h"
#include "log.h"
+#include "instance.h"
#include <stdio.h>
#include <stdlib.h>
@@ -75,7 +76,7 @@ unsigned short guild_flags_count;
*------------------------------------------*/
static TBL_PC* guild_sd_check(int guild_id, int account_id, int char_id)
{
- TBL_PC* sd = map_id2sd(account_id);
+ TBL_PC* sd = iMap->id2sd(account_id);
if (!(sd && sd->status.char_id == char_id))
return NULL;
@@ -166,7 +167,7 @@ static bool guild_read_castledb(char* str[], int columns, int current)
struct guild_castle *gc;
int mapindex = mapindex_name2id(str[1]);
- if (map_mapindex2mapid(mapindex) < 0) // Map not found or on another map-server
+ if (iMap->mapindex2mapid(mapindex) < 0) // Map not found or on another map-server
return false;
CREATE(gc, struct guild_castle, 1);
@@ -385,7 +386,7 @@ int guild_create(struct map_session_data *sd, const char *name)
clif->guild_created(sd,1);
return 0;
}
- if( battle_config.guild_emperium_check && pc_search_inventory(sd,714) == -1 )
+ if( battle_config.guild_emperium_check && pc->search_inventory(sd,714) == -1 )
{// item required
clif->guild_created(sd,3);
return 0;
@@ -399,7 +400,7 @@ int guild_create(struct map_session_data *sd, const char *name)
//Whether or not to create guild
int guild_created(int account_id,int guild_id) {
- struct map_session_data *sd=map_id2sd(account_id);
+ struct map_session_data *sd=iMap->id2sd(account_id);
if(sd==NULL)
return 0;
@@ -411,7 +412,7 @@ int guild_created(int account_id,int guild_id) {
sd->status.guild_id=guild_id;
clif->guild_created(sd,0);
if(battle_config.guild_emperium_check)
- pc_delitem(sd,pc_search_inventory(sd,ITEMID_EMPERIUM),1,0,0,LOG_TYPE_CONSUME); //emperium consumption
+ pc->delitem(sd,pc->search_inventory(sd,ITEMID_EMPERIUM),1,0,0,LOG_TYPE_CONSUME); //emperium consumption
return 0;
}
@@ -503,6 +504,8 @@ int guild_recv_info(struct guild *sg) {
if((g = (struct guild*)idb_get(guild_db,sg->guild_id))==NULL) {
guild_new = true;
g=(struct guild *)aCalloc(1,sizeof(struct guild));
+ g->instance = NULL;
+ g->instances = 0;
idb_put(guild_db,sg->guild_id,g);
if( hChSys.ally ) {
struct hChSysCh *channel;
@@ -552,7 +555,7 @@ int guild_recv_info(struct guild *sg) {
before=*sg;
//Perform the check on the user because the first load
guild_check_member(sg);
- if ((sd = map_nick2sd(sg->master)) != NULL) {
+ if ((sd = iMap->nick2sd(sg->master)) != NULL) {
//If the guild master is online the first time the guild_info is received,
//that means he was the first to join, so apply guild skill blocking here.
if( battle_config.guild_skill_relog_delay )
@@ -659,7 +662,7 @@ int guild_invite(struct map_session_data *sd, struct map_session_data *tsd) {
if(tsd->status.guild_id>0 ||
tsd->guild_invite>0 ||
- ((agit_flag || agit2_flag) && map[tsd->bl.m].flag.gvg_castle))
+ ((iMap->agit_flag || iMap->agit2_flag) && map[tsd->bl.m].flag.gvg_castle))
{ //Can't invite people inside castles. [Skotlex]
clif->guild_inviteack(sd,0);
return 0;
@@ -693,7 +696,7 @@ int guild_reply_invite(struct map_session_data* sd, int guild_id, int flag)
// look up the person who sent the invite
//NOTE: this can be NULL because the person might have logged off in the meantime
- tsd = map_id2sd(sd->guild_invite_account);
+ tsd = iMap->id2sd(sd->guild_invite_account);
if ( sd->status.guild_id > 0 ) // [Paradox924X]
{ // Already in another guild.
@@ -785,7 +788,7 @@ void guild_member_joined(struct map_session_data *sd)
*----------------------------------------*/
int guild_member_added(int guild_id,int account_id,int char_id,int flag)
{
- struct map_session_data *sd= map_id2sd(account_id),*sd2;
+ struct map_session_data *sd= iMap->id2sd(account_id),*sd2;
struct guild *g;
if( (g=guild->search(guild_id))==NULL )
@@ -799,7 +802,7 @@ int guild_member_added(int guild_id,int account_id,int char_id,int flag)
}
return 0;
}
- sd2 = map_id2sd(sd->guild_invite_account);
+ sd2 = iMap->id2sd(sd->guild_invite_account);
sd->guild_invite = 0;
sd->guild_invite_account = 0;
@@ -844,7 +847,7 @@ int guild_leave(struct map_session_data* sd, int guild_id, int account_id, int c
if(sd->status.account_id!=account_id ||
sd->status.char_id!=char_id || sd->status.guild_id!=guild_id ||
- ((agit_flag || agit2_flag) && map[sd->bl.m].flag.gvg_castle))
+ ((iMap->agit_flag || iMap->agit2_flag) && map[sd->bl.m].flag.gvg_castle))
return 0;
intif_guild_leave(sd->status.guild_id, sd->status.account_id, sd->status.char_id,0,mes);
@@ -874,9 +877,9 @@ int guild_expulsion(struct map_session_data* sd, int guild_id, int account_id, i
return 0; //Expulsion permission
//Can't leave inside guild castles.
- if ((tsd = map_id2sd(account_id)) &&
+ if ((tsd = iMap->id2sd(account_id)) &&
tsd->status.char_id == char_id &&
- ((agit_flag || agit2_flag) && map[tsd->bl.m].flag.gvg_castle))
+ ((iMap->agit_flag || iMap->agit2_flag) && map[tsd->bl.m].flag.gvg_castle))
return 0;
// find the member and perform expulsion
@@ -891,7 +894,7 @@ int guild_member_withdraw(int guild_id, int account_id, int char_id, int flag, c
{
int i;
struct guild* g = guild->search(guild_id);
- struct map_session_data* sd = map_charid2sd(char_id);
+ struct map_session_data* sd = iMap->charid2sd(char_id);
struct map_session_data* online_member_sd;
if(g == NULL)
@@ -918,7 +921,7 @@ int guild_member_withdraw(int guild_id, int account_id, int char_id, int flag, c
if(sd != NULL && sd->status.guild_id == guild_id) {
// do stuff that needs the guild_id first, BEFORE we wipe it
if (sd->state.storage_flag == 2) //Close the guild storage.
- storage_guild_storageclose(sd);
+ gstorage->close(sd);
guild->send_dot_remove(sd);
if( hChSys.ally ) {
clif->chsys_quitg(sd);
@@ -926,7 +929,8 @@ int guild_member_withdraw(int guild_id, int account_id, int char_id, int flag, c
sd->status.guild_id = 0;
sd->guild = NULL;
sd->guild_emblem_id = 0;
-
+ if( g->instances )
+ instance->check_kick(sd);
clif->charnameupdate(sd); //Update display name [Skotlex]
//TODO: send emblem update to self and people around
}
@@ -993,7 +997,7 @@ int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int onlin
if(idx == -1 || c == 0) {
//Treat char_id who doesn't match guild_id (not found as member)
- struct map_session_data *sd = map_id2sd(account_id);
+ struct map_session_data *sd = iMap->id2sd(account_id);
if(sd && sd->status.char_id == char_id) {
sd->status.guild_id=0;
sd->guild_emblem_id=0;
@@ -1202,7 +1206,7 @@ int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data)
// update permanent guardians
for( i = 0; i < ARRAYLENGTH(gc->guardian); ++i )
{
- TBL_MOB* md = (gc->guardian[i].id ? map_id2md(gc->guardian[i].id) : NULL);
+ TBL_MOB* md = (gc->guardian[i].id ? iMap->id2md(gc->guardian[i].id) : NULL);
if( md == NULL || md->guardian_data == NULL )
continue;
md->guardian_data->emblem_id = emblem_id;
@@ -1211,7 +1215,7 @@ int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data)
// update temporary guardians
for( i = 0; i < gc->temp_guardians_max; ++i )
{
- TBL_MOB* md = (gc->temp_guardians[i] ? map_id2md(gc->temp_guardians[i]) : NULL);
+ TBL_MOB* md = (gc->temp_guardians[i] ? iMap->id2md(gc->temp_guardians[i]) : NULL);
if( md == NULL || md->guardian_data == NULL )
continue;
md->guardian_data->emblem_id = emblem_id;
@@ -1329,7 +1333,7 @@ int guild_skillup(TBL_PC* sd, uint16 skill_id)
*---------------------------------------------------*/
int guild_skillupack(int guild_id,uint16 skill_id,int account_id)
{
- struct map_session_data *sd=map_id2sd(account_id);
+ struct map_session_data *sd=iMap->id2sd(account_id);
struct guild *g=guild->search(guild_id);
int i;
if(g==NULL)
@@ -1359,7 +1363,7 @@ int guild_skillupack(int guild_id,uint16 skill_id,int account_id)
void guild_guildaura_refresh(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv) {
struct skill_unit_group* group = NULL;
int type = status_skill2sc(skill_id);
- if( !(battle_config.guild_aura&((agit_flag || agit2_flag)?2:1)) &&
+ if( !(battle_config.guild_aura&((iMap->agit_flag || iMap->agit2_flag)?2:1)) &&
!(battle_config.guild_aura&(map_flag_gvg2(sd->bl.m)?8:4)) )
return;
if( !skill_lv )
@@ -1432,7 +1436,7 @@ int guild_reqalliance(struct map_session_data *sd,struct map_session_data *tsd)
struct guild *g[2];
int i;
- if(agit_flag || agit2_flag) { // Disable alliance creation during woe [Valaris]
+ if(iMap->agit_flag || iMap->agit2_flag) { // Disable alliance creation during woe [Valaris]
clif->message(sd->fd,msg_txt(676)); //"Alliances cannot be made during Guild Wars!"
return 0;
} // end addition [Valaris]
@@ -1490,7 +1494,7 @@ int guild_reply_reqalliance(struct map_session_data *sd,int account_id,int flag)
struct map_session_data *tsd;
nullpo_ret(sd);
- tsd= map_id2sd( account_id );
+ tsd= iMap->id2sd( account_id );
if (!tsd) { //Character left? Cancel alliance.
clif->guild_allianceack(sd,3);
return 0;
@@ -1550,7 +1554,7 @@ int guild_delalliance(struct map_session_data *sd,int guild_id,int flag)
{
nullpo_ret(sd);
- if(agit_flag || agit2_flag) { // Disable alliance breaking during woe [Valaris]
+ if(iMap->agit_flag || iMap->agit2_flag) { // Disable alliance breaking during woe [Valaris]
clif->message(sd->fd,msg_txt(677)); //"Alliances cannot be broken during Guild Wars!"
return 0;
} // end addition [Valaris]
@@ -1588,7 +1592,7 @@ int guild_opposition(struct map_session_data *sd,struct map_session_data *tsd)
clif->guild_oppositionack(sd,2);
return 0;
}
- if(agit_flag || agit2_flag) // Prevent the changing of alliances to oppositions during WoE.
+ if(iMap->agit_flag || iMap->agit2_flag) // Prevent the changing of alliances to oppositions during WoE.
return 0;
//Change alliance to opposition.
intif_guild_alliance( sd->status.guild_id,tsd->status.guild_id,
@@ -1617,8 +1621,8 @@ int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id
guild_id[1] = guild_id2;
guild_name[0] = name1;
guild_name[1] = name2;
- sd[0] = map_id2sd(account_id1);
- sd[1] = map_id2sd(account_id2);
+ sd[0] = iMap->id2sd(account_id1);
+ sd[1] = iMap->id2sd(account_id2);
g[0]=guild->search(guild_id1);
g[1]=guild->search(guild_id2);
@@ -1748,7 +1752,7 @@ int guild_broken(int guild_id,int flag)
for(i=0;i<g->max_member;i++){ // Destroy all relationships
if((sd=g->member[i].sd)!=NULL){
if(sd->state.storage_flag == 2)
- storage_guild_storage_quit(sd,1);
+ gstorage->pc_quit(sd,1);
sd->status.guild_id=0;
sd->guild = NULL;
clif->guild_broken(g->member[i].sd,0);
@@ -1758,7 +1762,7 @@ int guild_broken(int guild_id,int flag)
guild_db->foreach(guild_db,guild_broken_sub,guild_id);
castle_db->foreach(castle_db,castle_guild_broken_sub,guild_id);
- guild_storage_delete(guild_id);
+ gstorage->delete(guild_id);
if( hChSys.ally ) {
if( g->channel != NULL ) {
clif->chsys_delete(( struct hChSysCh * )g->channel);
@@ -1922,7 +1926,7 @@ int guild_castledatasave(int castle_id, int index, int value)
struct mob_data *gd;
gc->guild_id = value;
for (i = 0; i < MAX_GUARDIANS; i++)
- if (gc->guardian[i].visible && (gd = map_id2md(gc->guardian[i].id)) != NULL)
+ if (gc->guardian[i].visible && (gd = iMap->id2md(gc->guardian[i].id)) != NULL)
mob_guardian_guildchange(gd);
break;
}
@@ -1934,7 +1938,7 @@ int guild_castledatasave(int castle_id, int index, int value)
struct mob_data *gd;
gc->defense = value;
for (i = 0; i < MAX_GUARDIANS; i++)
- if (gc->guardian[i].visible && (gd = map_id2md(gc->guardian[i].id)) != NULL)
+ if (gc->guardian[i].visible && (gd = iMap->id2md(gc->guardian[i].id)) != NULL)
status_calc_mob(gd, 0);
break;
}
@@ -2193,15 +2197,15 @@ void do_init_guild(void) {
guild_flags_count = 0;
- sv->readdb(db_path, "castle_db.txt", ',', 4, 5, -1, &guild_read_castledb);
+ sv->readdb(iMap->db_path, "castle_db.txt", ',', 4, 5, -1, &guild_read_castledb);
memset(guild_skill_tree,0,sizeof(guild_skill_tree));
- sv->readdb(db_path, "guild_skill_tree.txt", ',', 2+MAX_GUILD_SKILL_REQUIRE*2, 2+MAX_GUILD_SKILL_REQUIRE*2, -1, &guild_read_guildskill_tree_db); //guild skill tree [Komurka]
+ sv->readdb(iMap->db_path, "guild_skill_tree.txt", ',', 2+MAX_GUILD_SKILL_REQUIRE*2, 2+MAX_GUILD_SKILL_REQUIRE*2, -1, &guild_read_guildskill_tree_db); //guild skill tree [Komurka]
- add_timer_func_list(guild_payexp_timer,"guild_payexp_timer");
- add_timer_func_list(guild_send_xy_timer, "guild_send_xy_timer");
- add_timer_interval(gettick()+GUILD_PAYEXP_INVERVAL,guild_payexp_timer,0,0,GUILD_PAYEXP_INVERVAL);
- add_timer_interval(gettick()+GUILD_SEND_XY_INVERVAL,guild_send_xy_timer,0,0,GUILD_SEND_XY_INVERVAL);
+ iTimer->add_timer_func_list(guild_payexp_timer,"guild_payexp_timer");
+ iTimer->add_timer_func_list(guild_send_xy_timer, "guild_send_xy_timer");
+ iTimer->add_timer_interval(iTimer->gettick()+GUILD_PAYEXP_INVERVAL,guild_payexp_timer,0,0,GUILD_PAYEXP_INVERVAL);
+ iTimer->add_timer_interval(iTimer->gettick()+GUILD_SEND_XY_INVERVAL,guild_send_xy_timer,0,0,GUILD_SEND_XY_INVERVAL);
}
void do_final_guild(void) {
@@ -2211,6 +2215,10 @@ void do_final_guild(void) {
for( g = dbi_first(iter); dbi_exists(iter); g = dbi_next(iter) ) {
if( g->channel != NULL )
clif->chsys_delete((struct hChSysCh *)g->channel);
+ if( g->instance != NULL ) {
+ aFree(g->instance);
+ g->instance = NULL;
+ }
}
dbi_destroy(iter);
diff --git a/src/map/homunculus.c b/src/map/homunculus.c
index e306e7f60..efb5c0eb3 100644
--- a/src/map/homunculus.c
+++ b/src/map/homunculus.c
@@ -402,7 +402,7 @@ bool homunculus_evolve(struct homun_data *hd) {
hom->intimacy = 500;
unit_remove_map(&hd->bl, CLR_OUTSIGHT);
- map_addblock(&hd->bl);
+ iMap->addblock(&hd->bl);
clif->spawn(&hd->bl);
clif->emotion(&sd->bl, E_NO1);
@@ -414,7 +414,7 @@ bool homunculus_evolve(struct homun_data *hd) {
status_calc_homunculus(hd,1);
if (!(battle_config.hom_setting&0x2))
- skill->unit_move(&sd->hd->bl,gettick(),1); // apply land skills immediately
+ skill->unit_move(&sd->hd->bl,iTimer->gettick(),1); // apply land skills immediately
return true;
}
@@ -446,7 +446,7 @@ bool homunculus_mutate(struct homun_data *hd, int homun_id) {
}
unit_remove_map(&hd->bl, CLR_OUTSIGHT);
- map_addblock(&hd->bl);
+ iMap->addblock(&hd->bl);
clif->spawn(&hd->bl);
clif->emotion(&sd->bl, E_NO1);
@@ -461,7 +461,7 @@ bool homunculus_mutate(struct homun_data *hd, int homun_id) {
status_calc_homunculus(hd,1);
if (!(battle_config.hom_setting&0x2))
- skill->unit_move(&sd->hd->bl,gettick(),1); // apply land skills immediately
+ skill->unit_move(&sd->hd->bl,iTimer->gettick(),1); // apply land skills immediately
return true;
}
@@ -573,12 +573,12 @@ bool homunculus_feed(struct map_session_data *sd, struct homun_data *hd) {
return false;
foodID = hd->homunculusDB->foodID;
- i = pc_search_inventory(sd,foodID);
+ i = pc->search_inventory(sd,foodID);
if(i < 0) {
clif->hom_food(sd,foodID,0);
return false;
}
- pc_delitem(sd,i,1,0,0,LOG_TYPE_CONSUME);
+ pc->delitem(sd,i,1,0,0,LOG_TYPE_CONSUME);
if ( hd->homunculus.hunger >= 91 ) {
homun->consume_intimacy(hd, 50);
@@ -617,7 +617,7 @@ int homunculus_hunger_timer(int tid, unsigned int tick, int id, intptr_t data) {
struct map_session_data *sd;
struct homun_data *hd;
- if(!(sd=map_id2sd(id)) || !sd->status.hom_id || !(hd=sd->hd))
+ if(!(sd=iMap->id2sd(id)) || !sd->status.hom_id || !(hd=sd->hd))
return 1;
if(hd->hungry_timer != tid){
@@ -645,14 +645,14 @@ int homunculus_hunger_timer(int tid, unsigned int tick, int id, intptr_t data) {
}
clif->send_homdata(sd,SP_HUNGRY,hd->homunculus.hunger);
- hd->hungry_timer = add_timer(tick+hd->homunculusDB->hungryDelay,homun->hunger_timer,sd->bl.id,0); //simple Fix albator
+ hd->hungry_timer = iTimer->add_timer(tick+hd->homunculusDB->hungryDelay,homun->hunger_timer,sd->bl.id,0); //simple Fix albator
return 0;
}
void homunculus_hunger_timer_delete(struct homun_data *hd) {
nullpo_retv(hd);
if(hd->hungry_timer != INVALID_TIMER) {
- delete_timer(hd->hungry_timer,homun->hunger_timer);
+ iTimer->delete_timer(hd->hungry_timer,homun->hunger_timer);
hd->hungry_timer = INVALID_TIMER;
}
}
@@ -754,7 +754,7 @@ bool homunculus_create(struct map_session_data *sd, struct s_homunculus *hom) {
hd->bl.x = hd->ud.to_x;
hd->bl.y = hd->ud.to_y;
- map_addiddb(&hd->bl);
+ iMap->addiddb(&hd->bl);
status_calc_homunculus(hd,1);
hd->hungry_timer = INVALID_TIMER;
@@ -763,7 +763,7 @@ bool homunculus_create(struct map_session_data *sd, struct s_homunculus *hom) {
void homunculus_init_timers(struct homun_data * hd) {
if (hd->hungry_timer == INVALID_TIMER)
- hd->hungry_timer = add_timer(gettick()+hd->homunculusDB->hungryDelay,homun->hunger_timer,hd->master->bl.id,0);
+ hd->hungry_timer = iTimer->add_timer(iTimer->gettick()+hd->homunculusDB->hungryDelay,homun->hunger_timer,hd->master->bl.id,0);
hd->regen.state.block = 0; //Restore HP/SP block.
}
@@ -788,7 +788,7 @@ bool homunculus_call(struct map_session_data *sd) {
hd->bl.x = sd->bl.x;
hd->bl.y = sd->bl.y;
hd->bl.m = sd->bl.m;
- map_addblock(&hd->bl);
+ iMap->addblock(&hd->bl);
clif->spawn(&hd->bl);
clif->send_homdata(sd,SP_ACK,0);
clif->hominfo(sd,hd,1);
@@ -808,7 +808,7 @@ bool homunculus_recv_data(int account_id, struct s_homunculus *sh, int flag) {
struct map_session_data *sd;
struct homun_data *hd;
- sd = map_id2sd(account_id);
+ sd = iMap->id2sd(account_id);
if(!sd)
return false;
if (sd->status.char_id != sh->char_id) {
@@ -834,7 +834,7 @@ bool homunculus_recv_data(int account_id, struct s_homunculus *sh, int flag) {
if(hd && hd->homunculus.hp && !hd->homunculus.vaporize && hd->bl.prev == NULL && sd->bl.prev != NULL) {
enum homun_type htype = homun->class2type(hd->homunculus.class_);
- map_addblock(&hd->bl);
+ iMap->addblock(&hd->bl);
clif->spawn(&hd->bl);
clif->send_homdata(sd,SP_ACK,0);
clif->hominfo(sd,hd,1);
@@ -919,7 +919,7 @@ bool homunculus_ressurect(struct map_session_data* sd, unsigned char per, short
hd->bl.m = sd->bl.m;
hd->bl.x = x;
hd->bl.y = y;
- map_addblock(&hd->bl);
+ iMap->addblock(&hd->bl);
clif->spawn(&hd->bl);
}
status_revive(&hd->bl, per, 0);
@@ -1127,14 +1127,14 @@ void homunculus_read_db(void) {
if( i > 0 ) {
char path[256];
- sprintf(path, "%s/%s", db_path, filename[i]);
+ sprintf(path, "%s/%s", iMap->db_path, filename[i]);
if( !exists(path) ) {
continue;
}
}
- sv->readdb(db_path, filename[i], ',', 50, 50, MAX_HOMUNCULUS_CLASS, homun->read_db_sub);
+ sv->readdb(iMap->db_path, filename[i], ',', 50, 50, MAX_HOMUNCULUS_CLASS, homun->read_db_sub);
}
}
@@ -1180,7 +1180,7 @@ bool homunculus_read_skill_db_sub(char* split[], int columns, int current) {
void homunculus_skill_db_read(void) {
memset(homun->skill_tree,0,sizeof(homun->skill_tree));
- sv->readdb(db_path, "homun_skill_tree.txt", ',', 13, 15, -1, homun->read_skill_db_sub);
+ sv->readdb(iMap->db_path, "homun_skill_tree.txt", ',', 13, 15, -1, homun->read_skill_db_sub);
}
@@ -1194,7 +1194,7 @@ void homunculus_exp_db_read(void) {
memset(homun->exptable,0,sizeof(homun->exptable));
for(i = 0; i < 2; i++) {
- sprintf(line, "%s/%s", db_path, filename[i]);
+ sprintf(line, "%s/%s", iMap->db_path, filename[i]);
if( (fp=fopen(line,"r")) == NULL) {
if(i != 0)
continue;
@@ -1233,7 +1233,7 @@ void do_init_homunculus(void) {
homun->exp_db_read();
homun->skill_db_read();
// Add homunc timer function to timer func list [Toms]
- add_timer_func_list(homun->hunger_timer, "homunculus_hunger_timer");
+ iTimer->add_timer_func_list(homun->hunger_timer, "homunculus_hunger_timer");
//Stock view data for homuncs
memset(&homun->viewdb, 0, sizeof(homun->viewdb));
diff --git a/src/map/instance.c b/src/map/instance.c
index 8ddde8b3e..6b80f5d75 100644
--- a/src/map/instance.c
+++ b/src/map/instance.c
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#include "../common/cbasetypes.h"
#include "../common/socket.h"
@@ -24,20 +25,13 @@
#include <stdarg.h>
#include <time.h>
-int instance_start = 0; // To keep the last index + 1 of normal map inserted in the map[ARRAY]
-struct s_instance instance[MAX_INSTANCE];
-
-
/// Checks whether given instance id is valid or not.
-static bool instance_is_valid(int instance_id)
-{
- if( instance_id < 1 || instance_id >= ARRAYLENGTH(instance) )
- {// out of range
+bool instance_is_valid(int instance_id) {
+ if( instance_id < 0 || instance_id >= instance->instances ) {// out of range
return false;
}
- if( instance[instance_id].state == INSTANCE_FREE )
- {// uninitialized/freed instance slot
+ if( instances[instance_id].state == INSTANCE_FREE ) {// uninitialized/freed instance slot
return false;
}
@@ -48,99 +42,154 @@ static bool instance_is_valid(int instance_id)
/*--------------------------------------
* name : instance name
* Return value could be
- * -4 = already exists | -3 = no free instances | -2 = party not found | -1 = invalid type
+ * -4 = already exists | -3 = no free instances | -2 = owner not found | -1 = invalid type
* On success return instance_id
*--------------------------------------*/
-int instance_create(int party_id, const char *name)
-{
- int i;
- struct party_data* p;
-
- if( ( p = party_search(party_id) ) == NULL )
- {
- ShowError("instance_create: party %d not found for instance '%s'.\n", party_id, name);
- return -2;
+int instance_create(int owner_id, const char *name, enum instance_owner_type type) {
+ struct map_session_data *sd = NULL;
+ unsigned short *icptr = NULL;
+ struct party_data *p = NULL;
+ struct guild *g = NULL;
+ short *iptr = NULL;
+ int i, j;
+
+ switch ( type ) {
+ case IOT_NONE:
+ break;
+ case IOT_CHAR:
+ if( ( sd = iMap->id2sd(owner_id) ) == NULL ) {
+ ShowError("instance_create: character %d not found for instance '%s'.\n", owner_id, name);
+ return -2;
+ }
+ iptr = sd->instance;
+ icptr = &sd->instances;
+ break;
+ case IOT_PARTY:
+ if( ( p = party->search(owner_id) ) == NULL ) {
+ ShowError("instance_create: party %d not found for instance '%s'.\n", owner_id, name);
+ return -2;
+ }
+ iptr = p->instance;
+ icptr = &p->instances;
+ break;
+ case IOT_GUILD:
+ if( ( g = guild->search(owner_id) ) == NULL ) {
+ ShowError("instance_create: guild %d not found for instance '%s'.\n", owner_id, name);
+ return -2;
+ }
+ iptr = g->instance;
+ icptr = &g->instances;
+ break;
+ default:
+ ShowError("instance_create: unknown type %d for owner_id %d and name %s.\n", type,owner_id,name);
+ return -1;
}
-
- if( p->instance_id )
- return -4; // Party already instancing
-
- // Searching a Free Instance
- // 0 is ignored as this mean "no instance" on maps
- ARR_FIND(1, MAX_INSTANCE, i, instance[i].state == INSTANCE_FREE);
- if( i == MAX_INSTANCE )
- {
- ShowError("instance_create: no free instances, consider increasing MAX_INSTANCE.\n");
- return -3;
+
+ if( type != IOT_NONE && *icptr ) {
+ ARR_FIND(0, *icptr, i, strcmp(instances[iptr[i]].name,name) == 0 );
+ if( i != *icptr )
+ return -4;/* already got this instance */
}
-
- instance[i].state = INSTANCE_IDLE;
- instance[i].instance_id = i;
- instance[i].idle_timer = INVALID_TIMER;
- instance[i].idle_timeout = instance[i].idle_timeoutval = 0;
- instance[i].progress_timer = INVALID_TIMER;
- instance[i].progress_timeout = 0;
- instance[i].users = 0;
- instance[i].party_id = party_id;
- instance[i].vars = idb_alloc(DB_OPT_RELEASE_DATA);
-
- safestrncpy( instance[i].name, name, sizeof(instance[i].name) );
- memset( instance[i].map, 0x00, sizeof(instance[i].map) );
- p->instance_id = i;
-
+
+ ARR_FIND(0, instance->instances, i, instances[i].state == INSTANCE_FREE);
+
+ if( i == instance->instances )
+ RECREATE(instances, struct instance_data, ++instance->instances);
+
+ instances[i].state = INSTANCE_IDLE;
+ instances[i].id = i;
+ instances[i].idle_timer = INVALID_TIMER;
+ instances[i].idle_timeout = instances[i].idle_timeoutval = 0;
+ instances[i].progress_timer = INVALID_TIMER;
+ instances[i].progress_timeout = 0;
+ instances[i].users = 0;
+ instances[i].map = NULL;
+ instances[i].num_map = 0;
+ instances[i].owner_id = owner_id;
+ instances[i].owner_type = type;
+ instances[i].vars = idb_alloc(DB_OPT_RELEASE_DATA);
+
+ safestrncpy( instances[i].name, name, sizeof(instances[i].name) );
+
+ if( type != IOT_NONE ) {
+ ARR_FIND(0, *icptr, j, iptr[j] == -1);
+ if( j == *icptr ) {
+ switch( type ) {
+ case IOT_CHAR:
+ RECREATE(sd->instance, unsigned short, ++*icptr);
+ sd->instance[sd->instances-1] = i;
+ break;
+ case IOT_PARTY:
+ RECREATE(p->instance, unsigned short, ++*icptr);
+ p->instance[p->instances-1] = i;
+ break;
+ case IOT_GUILD:
+ RECREATE(g->instance, unsigned short, ++*icptr);
+ g->instance[g->instances-1] = i;
+ break;
+ }
+ } else
+ iptr[j] = i;
+ }
+
clif->instance(i, 1, 0); // Start instancing window
- ShowInfo("[Instance] Created: %s.\n", name);
return i;
}
/*--------------------------------------
* Add a map to the instance using src map "name"
*--------------------------------------*/
-int instance_add_map(const char *name, int instance_id, bool usebasename)
-{
- int16 m = map_mapname2mapid(name);
+int instance_add_map(const char *name, int instance_id, bool usebasename, const char *map_name) {
+ int16 m = iMap->mapname2mapid(name);
int i, im = -1;
size_t num_cell, size;
if( m < 0 )
return -1; // source map not found
- if( !instance_is_valid(instance_id) )
- {
+ if( !instance->valid(instance_id) ) {
ShowError("instance_add_map: trying to attach '%s' map to non-existing instance %d.\n", name, instance_id);
return -1;
}
- if( instance[instance_id].num_map >= MAX_MAP_PER_INSTANCE )
- {
- ShowError("instance_add_map: trying to add '%s' map to instance %d (%s) failed. Please increase MAX_MAP_PER_INSTANCE.\n", name, instance_id, instance[instance_id].name);
+
+ if( map_name != NULL && strdb_iget(mapindex_db, map_name) ) {
+ ShowError("instance_add_map: trying to create instanced map with existent name '%s'\n", map_name);
return -2;
}
- if( map[m].instance_id != 0 )
- { // Source map already belong to a Instance.
+
+ if( map[m].instance_id >= 0 ) { // Source map already belong to a Instance.
ShowError("instance_add_map: trying to instance already instanced map %s.\n", name);
return -4;
}
-
- ARR_FIND( instance_start, map_num, i, !map[i].name[0] ); // Searching for a Free Map
- if( i < map_num ) im = i; // Unused map found (old instance)
- else if( map_num - 1 >= MAX_MAP_PER_SERVER )
- { // No more free maps
- ShowError("instance_add_map: no more free space to create maps on this server.\n");
- return -5;
+
+ ARR_FIND( instance->start_id, iMap->map_num, i, map[i].name[0] == 0 ); // Searching for a Free Map
+
+ if( i < iMap->map_num )
+ im = i; // Unused map found (old instance)
+ else {
+ im = iMap->map_num; // Using next map index
+ RECREATE(map,struct map_data,++iMap->map_num);
}
- else im = map_num++; // Using next map index
+
+ if( map[m].cell == (struct mapcell *)0xdeadbeaf )
+ iMap->cellfromcache(&map[m]);
memcpy( &map[im], &map[m], sizeof(struct map_data) ); // Copy source map
- snprintf(map[im].name, MAP_NAME_LENGTH, (usebasename ? "%.3d#%s" : "%.3d%s"), instance_id, name); // Generate Name for Instance Map
+ if( map_name != NULL ) {
+ snprintf(map[im].name, MAP_NAME_LENGTH, "%s", map_name);
+ map[im].cName = map[m].name;
+ } else
+ snprintf(map[im].name, MAP_NAME_LENGTH, (usebasename ? "%.3d#%s" : "%.3d%s"), instance_id, name); // Generate Name for Instance Map
map[im].index = mapindex_addmap(-1, map[im].name); // Add map index
- if( !map[im].index )
- {
+ map[im].channel = NULL;
+
+ if( !map[im].index ) {
map[im].name[0] = '\0';
ShowError("instance_add_map: no more free map indexes.\n");
return -3; // No free map index
}
-
+
// Reallocate cells
num_cell = map[im].xs * map[im].ys;
CREATE( map[im].cell, struct mapcell, num_cell );
@@ -161,9 +210,11 @@ int instance_add_map(const char *name, int instance_id, bool usebasename)
map[im].instance_src_map = m;
map[m].flag.src4instance = 1; // Flag this map as a src map for instances
- instance[instance_id].map[instance[instance_id].num_map++] = im; // Attach to actual instance
- map_addmap2db(&map[im]);
+ RECREATE(instances[instance_id].map, unsigned short, ++instances[instance_id].num_map);
+ instances[instance_id].map[instances[instance_id].num_map - 1] = im; // Attach to actual instance
+ iMap->addmap2db(&map[im]);
+
return im;
}
@@ -172,19 +223,16 @@ int instance_add_map(const char *name, int instance_id, bool usebasename)
* party_id : source party of this instance
* type : result (0 = map id | 1 = instance id)
*--------------------------------------*/
-int instance_map2imap(int16 m, int instance_id)
-{
+int instance_map2imap(int16 m, int instance_id) {
int i;
- if( !instance_is_valid(instance_id) )
- {
+ if( !instance->valid(instance_id) ) {
return -1;
}
- for( i = 0; i < instance[instance_id].num_map; i++ )
- {
- if( instance[instance_id].map[i] && map[instance[instance_id].map[i]].instance_src_map == m )
- return instance[instance_id].map[i];
+ for( i = 0; i < instances[instance_id].num_map; i++ ) {
+ if( instances[instance_id].map[i] && map[instances[instance_id].map[i]].instance_src_map == m )
+ return instances[instance_id].map[i];
}
return -1;
}
@@ -194,63 +242,60 @@ int instance_map2imap(int16 m, int instance_id)
* instance_id : where to search
* result : mapid of map "m" in this instance
*--------------------------------------*/
-int instance_mapid2imapid(int16 m, int instance_id)
-{
+int instance_mapid2imapid(int16 m, int instance_id) {
if( map[m].flag.src4instance == 0 )
return m; // not instances found for this map
- else if( map[m].instance_id )
- { // This map is a instance, not a src map instance
+ else if( map[m].instance_id >= 0 ) { // This map is a instance, not a src map instance
ShowError("map_instance_mapid2imapid: already instanced (%d / %d)\n", m, instance_id);
return -1;
}
- if( !instance_is_valid(instance_id) )
+ if( !instance->valid(instance_id) )
return -1;
- return instance_map2imap(m, instance_id);
+ return instance->map2imap(m, instance_id);
}
/*--------------------------------------
* map_instance_map_npcsub
* Used on Init instance. Duplicates each script on source map
*--------------------------------------*/
-int instance_map_npcsub(struct block_list* bl, va_list args)
-{
+int instance_map_npcsub(struct block_list* bl, va_list args) {
struct npc_data* nd = (struct npc_data*)bl;
int16 m = va_arg(args, int); // Destination Map
- npc_duplicate4instance(nd, m);
+ if ( npc_duplicate4instance(nd, m) )
+ ShowDebug("instance_map_npcsub:npc_duplicate4instance failed (%s/%d)\n",nd->name,m);
+
return 1;
}
/*--------------------------------------
* Init all map on the instance. Npcs are created here
*--------------------------------------*/
-void instance_init(int instance_id)
-{
+void instance_init(int instance_id) {
int i;
- if( !instance_is_valid(instance_id) )
+ if( !instance->valid(instance_id) )
return; // nothing to do
- for( i = 0; i < instance[instance_id].num_map; i++ )
- map_foreachinmap(instance_map_npcsub, map[instance[instance_id].map[i]].instance_src_map, BL_NPC, instance[instance_id].map[i]);
+ for( i = 0; i < instances[instance_id].num_map; i++ )
+ iMap->foreachinmap(instance_map_npcsub, map[instances[instance_id].map[i]].instance_src_map, BL_NPC, instances[instance_id].map[i]);
- instance[instance_id].state = INSTANCE_BUSY;
- ShowInfo("[Instance] Initialized %s.\n", instance[instance_id].name);
+ instances[instance_id].state = INSTANCE_BUSY;
}
/*--------------------------------------
* Used on instance deleting process.
* Warps all players on each instance map to its save points.
*--------------------------------------*/
-int instance_del_load(struct map_session_data* sd, va_list args)
-{
+int instance_del_load(struct map_session_data* sd, va_list args) {
int16 m = va_arg(args,int);
+
if( !sd || sd->bl.m != m )
return 0;
- pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
+ pc->setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
return 1;
}
@@ -260,7 +305,7 @@ int instance_cleanup_sub(struct block_list *bl, va_list ap) {
switch(bl->type) {
case BL_PC:
- map_quit((struct map_session_data *) bl);
+ iMap->quit((struct map_session_data *) bl);
break;
case BL_NPC:
npc_unload((struct npc_data *)bl,true);
@@ -272,7 +317,7 @@ int instance_cleanup_sub(struct block_list *bl, va_list ap) {
//There is no need for this, the pet is removed together with the player. [Skotlex]
break;
case BL_ITEM:
- map_clearflooritem(bl);
+ iMap->clearflooritem(bl);
break;
case BL_SKILL:
skill->delunit((struct skill_unit *) bl);
@@ -285,130 +330,162 @@ int instance_cleanup_sub(struct block_list *bl, va_list ap) {
/*--------------------------------------
* Removes a simple instance map
*--------------------------------------*/
-void instance_del_map(int16 m)
-{
+void instance_del_map(int16 m) {
int i;
- if( m <= 0 || !map[m].instance_id )
- {
- ShowError("Tried to remove non-existing instance map (%d)\n", m);
+
+ if( m <= 0 || map[m].instance_id == -1 ) {
+ ShowError("instance_del_map: tried to remove non-existing instance map (%d)\n", m);
return;
}
- map_foreachpc(instance_del_load, m);
- map_foreachinmap(instance_cleanup_sub, m, BL_ALL);
+ iMap->map_foreachpc(instance_del_load, m);
+ iMap->foreachinmap(instance_cleanup_sub, m, BL_ALL);
if( map[m].mob_delete_timer != INVALID_TIMER )
- delete_timer(map[m].mob_delete_timer, map_removemobs_timer);
-
+ iTimer->delete_timer(map[m].mob_delete_timer, iMap->removemobs_timer);
+
mapindex_removemap( map[m].index );
// Free memory
aFree(map[m].cell);
aFree(map[m].block);
aFree(map[m].block_mob);
-
+
// Remove from instance
- for( i = 0; i < instance[map[m].instance_id].num_map; i++ )
- {
- if( instance[map[m].instance_id].map[i] == m )
- {
- instance[map[m].instance_id].num_map--;
- for( ; i < instance[map[m].instance_id].num_map; i++ )
- instance[map[m].instance_id].map[i] = instance[map[m].instance_id].map[i+1];
+ for( i = 0; i < instances[map[m].instance_id].num_map; i++ ) {
+ if( instances[map[m].instance_id].map[i] == m ) {
+ instances[map[m].instance_id].num_map--;
+ for( ; i < instances[map[m].instance_id].num_map; i++ )
+ instances[map[m].instance_id].map[i] = instances[map[m].instance_id].map[i+1];
i = -1;
break;
}
}
- if( i == instance[map[m].instance_id].num_map )
- ShowError("map_instance_del: failed to remove %s from instance list (%s): %d\n", map[m].name, instance[map[m].instance_id].name, m);
-
- map_removemapdb(&map[m]);
+
+ if( i == instances[map[m].instance_id].num_map )
+ ShowError("map_instance_del: failed to remove %s from instance list (%s): %d\n", map[m].name, instances[map[m].instance_id].name, m);
+
+ if( map[m].channel )
+ clif->chsys_delete(map[m].channel);
+
+ iMap->removemapdb(&map[m]);
memset(&map[m], 0x00, sizeof(map[0]));
-
- /* for it is default and makes it not try to delete a non-existent timer since we did not delete this entry. */
+ map[m].name[0] = 0;
+ map[m].instance_id = -1;
map[m].mob_delete_timer = INVALID_TIMER;
}
/*--------------------------------------
* Timer to destroy instance by process or idle
*--------------------------------------*/
-int instance_destroy_timer(int tid, unsigned int tick, int id, intptr_t data)
-{
- instance_destroy(id);
+int instance_destroy_timer(int tid, unsigned int tick, int id, intptr_t data) {
+ instance->destroy(id);
return 0;
}
/*--------------------------------------
* Removes a instance, all its maps and npcs.
*--------------------------------------*/
-void instance_destroy(int instance_id)
-{
- int last = 0, type;
- struct party_data *p;
- time_t now = time(NULL);
-
- if( !instance_is_valid(instance_id) )
+void instance_destroy(int instance_id) {
+ struct map_session_data *sd = NULL;
+ unsigned short *icptr = NULL;
+ struct party_data *p = NULL;
+ struct guild *g = NULL;
+ short *iptr = NULL;
+ int type, j, last = 0;
+ unsigned int now = (unsigned int)time(NULL);
+
+ if( !instance->valid(instance_id) )
return; // nothing to do
- if( instance[instance_id].progress_timeout && instance[instance_id].progress_timeout <= now )
+ if( instances[instance_id].progress_timeout && instances[instance_id].progress_timeout <= now )
type = 1;
- else if( instance[instance_id].idle_timeout && instance[instance_id].idle_timeout <= now )
+ else if( instances[instance_id].idle_timeout && instances[instance_id].idle_timeout <= now )
type = 2;
else
type = 3;
-
+
clif->instance(instance_id, 5, type); // Report users this instance has been destroyed
- while( instance[instance_id].num_map && last != instance[instance_id].map[0] )
- { // Remove all maps from instance
- last = instance[instance_id].map[0];
- instance_del_map( instance[instance_id].map[0] );
+ switch ( instances[instance_id].owner_type ) {
+ case IOT_NONE:
+ break;
+ case IOT_CHAR:
+ if( ( sd = iMap->id2sd(instances[instance_id].owner_id) ) == NULL ) {
+ break;
+ }
+ iptr = sd->instance;
+ icptr = &sd->instances;
+ break;
+ case IOT_PARTY:
+ if( ( p = party->search(instances[instance_id].owner_id) ) == NULL ) {
+ break;
+ }
+ iptr = p->instance;
+ icptr = &p->instances;
+ break;
+ case IOT_GUILD:
+ if( ( g = guild->search(instances[instance_id].owner_id) ) == NULL ) {
+ break;
+ }
+ iptr = g->instance;
+ icptr = &g->instances;
+ break;
+ default:
+ ShowError("instance_destroy: unknown type %d for owner_id %d and name '%s'.\n", instances[instance_id].owner_type,instances[instance_id].owner_id,instances[instance_id].name);
+ break;
}
-
- if( instance[instance_id].vars )
- db_destroy(instance[instance_id].vars);
-
- if( instance[instance_id].progress_timer != INVALID_TIMER )
- delete_timer( instance[instance_id].progress_timer, instance_destroy_timer);
- if( instance[instance_id].idle_timer != INVALID_TIMER )
- delete_timer( instance[instance_id].idle_timer, instance_destroy_timer);
-
- instance[instance_id].vars = NULL;
-
- if( instance[instance_id].party_id && (p = party_search(instance[instance_id].party_id)) != NULL )
- p->instance_id = 0; // Update Party information
-
- ShowInfo("[Instance] Destroyed %s.\n", instance[instance_id].name);
- memset( &instance[instance_id], 0x00, sizeof(instance[0]) );
-
- instance[instance_id].state = INSTANCE_FREE;
+
+ if( iptr != NULL ) {
+ ARR_FIND(0, *icptr, j, iptr[j] == instance_id);
+ if( j != *icptr )
+ iptr[j] = -1;
+ }
+
+ while( instances[instance_id].num_map && last != instances[instance_id].map[0] ) { // Remove all maps from instance
+ last = instances[instance_id].map[0];
+ instance->del_map( instances[instance_id].map[0] );
+ }
+
+ if( instances[instance_id].vars )
+ db_destroy(instances[instance_id].vars);
+
+ if( instances[instance_id].progress_timer != INVALID_TIMER )
+ iTimer->delete_timer( instances[instance_id].progress_timer, instance_destroy_timer);
+ if( instances[instance_id].idle_timer != INVALID_TIMER )
+ iTimer->delete_timer( instances[instance_id].idle_timer, instance_destroy_timer);
+
+ instances[instance_id].vars = NULL;
+
+ if( instances[instance_id].map )
+ aFree(instances[instance_id].map);
+
+ instances[instance_id].map = NULL;
+ instances[instance_id].state = INSTANCE_FREE;
+ instances[instance_id].num_map = 0;
}
/*--------------------------------------
* Checks if there are users in the instance or not to start idle timer
*--------------------------------------*/
-void instance_check_idle(int instance_id)
-{
+void instance_check_idle(int instance_id) {
bool idle = true;
- time_t now = time(NULL);
+ unsigned int now = (unsigned int)time(NULL);
- if( !instance_is_valid(instance_id) || instance[instance_id].idle_timeoutval == 0 )
+ if( !instance->valid(instance_id) || instances[instance_id].idle_timeoutval == 0 )
return;
- if( instance[instance_id].users )
+ if( instances[instance_id].users )
idle = false;
- if( instance[instance_id].idle_timer != INVALID_TIMER && !idle )
- {
- delete_timer(instance[instance_id].idle_timer, instance_destroy_timer);
- instance[instance_id].idle_timer = INVALID_TIMER;
- instance[instance_id].idle_timeout = 0;
+ if( instances[instance_id].idle_timer != INVALID_TIMER && !idle ) {
+ iTimer->delete_timer(instances[instance_id].idle_timer, instance_destroy_timer);
+ instances[instance_id].idle_timer = INVALID_TIMER;
+ instances[instance_id].idle_timeout = 0;
clif->instance(instance_id, 3, 0); // Notify instance users normal instance expiration
- }
- else if( instance[instance_id].idle_timer == INVALID_TIMER && idle )
- {
- instance[instance_id].idle_timeout = now + instance[instance_id].idle_timeoutval;
- instance[instance_id].idle_timer = add_timer( gettick() + (unsigned int)instance[instance_id].idle_timeoutval * 1000, instance_destroy_timer, instance_id, 0);
+ } else if( instances[instance_id].idle_timer == INVALID_TIMER && idle ) {
+ instances[instance_id].idle_timeout = now + instances[instance_id].idle_timeoutval;
+ instances[instance_id].idle_timer = iTimer->add_timer( iTimer->gettick() + instances[instance_id].idle_timeoutval * 1000, instance_destroy_timer, instance_id, 0);
clif->instance(instance_id, 4, 0); // Notify instance users it will be destroyed of no user join it again in "X" time
}
}
@@ -418,71 +495,91 @@ void instance_check_idle(int instance_id)
*--------------------------------------*/
void instance_set_timeout(int instance_id, unsigned int progress_timeout, unsigned int idle_timeout)
{
- time_t now = time(0);
+ unsigned int now = (unsigned int)time(0);
- if( !instance_is_valid(instance_id) )
+ if( !instance->valid(instance_id) )
return;
- if( instance[instance_id].progress_timer != INVALID_TIMER )
- delete_timer( instance[instance_id].progress_timer, instance_destroy_timer);
- if( instance[instance_id].idle_timer != INVALID_TIMER )
- delete_timer( instance[instance_id].idle_timer, instance_destroy_timer);
-
- if( progress_timeout )
- {
- instance[instance_id].progress_timeout = now + progress_timeout;
- instance[instance_id].progress_timer = add_timer( gettick() + progress_timeout * 1000, instance_destroy_timer, instance_id, 0);
- }
- else
- {
- instance[instance_id].progress_timeout = 0;
- instance[instance_id].progress_timer = INVALID_TIMER;
+ if( instances[instance_id].progress_timer != INVALID_TIMER )
+ iTimer->delete_timer( instances[instance_id].progress_timer, instance_destroy_timer);
+ if( instances[instance_id].idle_timer != INVALID_TIMER )
+ iTimer->delete_timer( instances[instance_id].idle_timer, instance_destroy_timer);
+
+ if( progress_timeout ) {
+ instances[instance_id].progress_timeout = now + progress_timeout;
+ instances[instance_id].progress_timer = iTimer->add_timer( iTimer->gettick() + progress_timeout * 1000, instance_destroy_timer, instance_id, 0);
+ } else {
+ instances[instance_id].progress_timeout = 0;
+ instances[instance_id].progress_timer = INVALID_TIMER;
}
- if( idle_timeout )
- {
- instance[instance_id].idle_timeoutval = idle_timeout;
- instance[instance_id].idle_timer = INVALID_TIMER;
+ if( idle_timeout ) {
+ instances[instance_id].idle_timeoutval = idle_timeout;
+ instances[instance_id].idle_timer = INVALID_TIMER;
instance_check_idle(instance_id);
- }
- else
- {
- instance[instance_id].idle_timeoutval = 0;
- instance[instance_id].idle_timeout = 0;
- instance[instance_id].idle_timer = INVALID_TIMER;
+ } else {
+ instances[instance_id].idle_timeoutval = 0;
+ instances[instance_id].idle_timeout = 0;
+ instances[instance_id].idle_timer = INVALID_TIMER;
}
- if( instance[instance_id].idle_timer == INVALID_TIMER && instance[instance_id].progress_timer != INVALID_TIMER )
+ if( instances[instance_id].idle_timer == INVALID_TIMER && instances[instance_id].progress_timer != INVALID_TIMER )
clif->instance(instance_id, 3, 0);
}
/*--------------------------------------
* Checks if sd in on a instance and should be kicked from it
*--------------------------------------*/
-void instance_check_kick(struct map_session_data *sd)
-{
+void instance_check_kick(struct map_session_data *sd) {
int16 m = sd->bl.m;
clif->instance_leave(sd->fd);
- if( map[m].instance_id )
- { // User was on the instance map
+ if( map[m].instance_id >= 0 ) { // User was on the instance map
if( map[m].save.map )
- pc_setpos(sd, map[m].save.map, map[m].save.x, map[m].save.y, CLR_TELEPORT);
+ pc->setpos(sd, map[m].save.map, map[m].save.x, map[m].save.y, CLR_TELEPORT);
else
- pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
+ pc->setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
}
}
-void do_final_instance(void)
-{
+void do_final_instance(void) {
int i;
+
+ for(i = 0; i < instance->instances; i++) {
+ instance->destroy(i);
+ }
+
+ if( instances )
+ aFree(instances);
- for( i = 1; i < MAX_INSTANCE; i++ )
- instance_destroy(i);
+ instance->instances = 0;
}
-void do_init_instance(void)
-{
- memset(instance, 0x00, sizeof(instance));
- add_timer_func_list(instance_destroy_timer, "instance_destroy_timer");
+void do_init_instance(void) {
+ iTimer->add_timer_func_list(instance_destroy_timer, "instance_destroy_timer");
+}
+
+void instance_defaults(void) {
+ instance = &instance_s;
+
+ instance->init = do_init_instance;
+ instance->final = do_final_instance;
+
+ /* start point */
+ instance->start_id = 0;
+ /* count */
+ instance->instances = 0;
+
+ /* */
+ instance->create = instance_create;
+ instance->add_map = instance_add_map;
+ instance->del_map = instance_del_map;
+ instance->map2imap = instance_map2imap;
+ instance->mapid2imapid = instance_mapid2imapid;
+ instance->destroy = instance_destroy;
+ instance->start = instance_init;
+ instance->check_idle = instance_check_idle;
+ instance->check_kick = instance_check_kick;
+ instance->set_timeout = instance_set_timeout;
+ instance->valid = instance_is_valid;
}
diff --git a/src/map/instance.h b/src/map/instance.h
index 03b0d0898..e86586e44 100644
--- a/src/map/instance.h
+++ b/src/map/instance.h
@@ -1,51 +1,71 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#ifndef _INSTANCE_H_
#define _INSTANCE_H_
-#define MAX_MAP_PER_INSTANCE 10
-#define MAX_INSTANCE 500
-
#define INSTANCE_NAME_LENGTH (60+1)
-typedef enum instance_state { INSTANCE_FREE, INSTANCE_IDLE, INSTANCE_BUSY } instance_state;
+typedef enum instance_state {
+ INSTANCE_FREE,
+ INSTANCE_IDLE,
+ INSTANCE_BUSY
+} instance_state;
+
+enum instance_owner_type {
+ IOT_NONE,
+ IOT_CHAR,
+ IOT_PARTY,
+ IOT_GUILD,
+ /* ... */
+ IOT_MAX,
+};
-struct s_instance {
+struct instance_data {
+ unsigned short id;
char name[INSTANCE_NAME_LENGTH]; // Instance Name - required for clif functions.
instance_state state;
- short instance_id;
- int party_id;
+ enum instance_owner_type owner_type;
+ int owner_id;
- int map[MAX_MAP_PER_INSTANCE];
- int num_map;
- int users;
+ unsigned short *map;
+ unsigned short num_map;
+ unsigned short users;
struct DBMap* vars; // Instance Variable for scripts
int progress_timer;
- time_t progress_timeout;
+ unsigned int progress_timeout;
int idle_timer;
- time_t idle_timeout, idle_timeoutval;
+ unsigned int idle_timeout, idle_timeoutval;
};
-extern int instance_start;
-extern struct s_instance instance[MAX_INSTANCE];
+struct instance_data *instances;
-int instance_create(int party_id, const char *name);
-int instance_add_map(const char *name, int instance_id, bool usebasename);
-void instance_del_map(int16 m);
-int instance_map2imap(int16 m, int instance_id);
-int instance_mapid2imapid(int16 m, int instance_id);
-void instance_destroy(int instance_id);
-void instance_init(int instance_id);
+struct instance_interface {
+ void (*init) (void);
+ void (*final) (void);
+ /* start point */
+ unsigned short start_id;
+ unsigned short instances;
+ /* */
+ int (*create) (int party_id, const char *name, enum instance_owner_type type);
+ int (*add_map) (const char *name, int instance_id, bool usebasename, const char *map_name);
+ void (*del_map) (int16 m);
+ int (*map2imap) (int16 m, int instance_id);
+ int (*mapid2imapid) (int16 m, int instance_id);
+ void (*destroy) (int instance_id);
+ void (*start) (int instance_id);
+ void (*check_idle) (int instance_id);
+ void (*check_kick) (struct map_session_data *sd);
+ void (*set_timeout) (int instance_id, unsigned int progress_timeout, unsigned int idle_timeout);
+ bool (*valid) (int instance_id);
+} instance_s;
-void instance_check_idle(int instance_id);
-void instance_check_kick(struct map_session_data *sd);
-void instance_set_timeout(int instance_id, unsigned int progress_timeout, unsigned int idle_timeout);
+struct instance_interface *instance;
-void do_final_instance(void);
-void do_init_instance(void);
+void instance_defaults(void);
#endif
diff --git a/src/map/intif.c b/src/map/intif.c
index 93bb8add7..e364f5c25 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -467,7 +467,7 @@ int intif_party_changemap(struct map_session_data *sd,int online)
if(!sd)
return 0;
- if( (m=map_mapindex2mapid(sd->mapindex)) >= 0 && map[m].instance_id )
+ if( (m=iMap->mapindex2mapid(sd->mapindex)) >= 0 && map[m].instance_id >= 0 )
mapindex = map[map[m].instance_src_map].index;
else
mapindex = sd->mapindex;
@@ -862,7 +862,7 @@ int intif_parse_WisMessage(int fd)
id=RFIFOL(fd,4);
safestrncpy(name, (char*)RFIFOP(fd,32), NAME_LENGTH);
- sd = map_nick2sd(name);
+ sd = iMap->nick2sd(name);
if(sd == NULL || strcmp(sd->status.name, name) != 0)
{ //Not found
intif_wis_replay(id,1);
@@ -896,7 +896,7 @@ int intif_parse_WisEnd(int fd)
if (battle_config.etc_log)
ShowInfo("intif_parse_wisend: player: %s, flag: %d\n", RFIFOP(fd,2), RFIFOB(fd,26)); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
- sd = (struct map_session_data *)map_nick2sd((char *) RFIFOP(fd,2));
+ sd = (struct map_session_data *)iMap->nick2sd((char *) RFIFOP(fd,2));
if (sd != NULL)
clif->wis_end(sd->fd, RFIFOB(fd,26));
@@ -935,7 +935,7 @@ int mapif_parse_WisToGM(int fd)
safestrncpy(Wisp_name, (char*)RFIFOP(fd,4), NAME_LENGTH);
safestrncpy(message, (char*)RFIFOP(fd,32), mes_len);
// information is sent to all online GM
- map_foreachpc(mapif_parse_WisToGM_sub, permission, Wisp_name, message, mes_len);
+ iMap->map_foreachpc(mapif_parse_WisToGM_sub, permission, Wisp_name, message, mes_len);
if (message != mbuf)
aFree(message);
@@ -954,7 +954,7 @@ int intif_parse_Registers(int fd)
if (node)
sd = node->sd;
else { //Normally registries should arrive for in log-in chars.
- sd = map_id2sd(account_id);
+ sd = iMap->id2sd(account_id);
if (sd && RFIFOB(fd,12) == 3 && sd->status.char_id != char_id)
sd = NULL; //Character registry from another character.
}
@@ -993,7 +993,7 @@ int intif_parse_Registers(int fd)
*qty = j;
if (flag && sd->save_reg.global_num > -1 && sd->save_reg.account_num > -1 && sd->save_reg.account2_num > -1)
- pc_reg_received(sd); //Received all registry values, execute init scripts and what-not. [Skotlex]
+ pc->reg_received(sd); //Received all registry values, execute init scripts and what-not. [Skotlex]
return 1;
}
@@ -1006,12 +1006,12 @@ int intif_parse_LoadGuildStorage(int fd)
guild_id = RFIFOL(fd,8);
if(guild_id <= 0)
return 1;
- sd=map_id2sd( RFIFOL(fd,4) );
+ sd=iMap->id2sd( RFIFOL(fd,4) );
if(sd==NULL){
ShowError("intif_parse_LoadGuildStorage: user not found %d\n",RFIFOL(fd,4));
return 1;
}
- gstor=guild2storage(guild_id);
+ gstor=gstorage->id2storage(guild_id);
if(!gstor) {
ShowWarning("intif_parse_LoadGuildStorage: error guild_id %d not exist\n",guild_id);
return 1;
@@ -1031,14 +1031,14 @@ int intif_parse_LoadGuildStorage(int fd)
}
memcpy(gstor,RFIFOP(fd,12),sizeof(struct guild_storage));
- storage_guild_storageopen(sd);
+ gstorage->open(sd);
return 0;
}
// ACK guild_storage saved
int intif_parse_SaveGuildStorage(int fd)
{
- storage_guild_storagesaved(/*RFIFOL(fd,2), */RFIFOL(fd,6));
+ gstorage->saved(/*RFIFOL(fd,2), */RFIFOL(fd,6));
return 0;
}
@@ -1047,7 +1047,7 @@ int intif_parse_PartyCreated(int fd)
{
if(battle_config.etc_log)
ShowInfo("intif: party created by account %d\n\n", RFIFOL(fd,2));
- party_created(RFIFOL(fd,2), RFIFOL(fd,6),RFIFOB(fd,10),RFIFOL(fd,11), (char *)RFIFOP(fd,15));
+ party->created(RFIFOL(fd,2), RFIFOL(fd,6),RFIFOB(fd,10),RFIFOL(fd,11), (char *)RFIFOP(fd,15));
return 0;
}
@@ -1056,13 +1056,13 @@ int intif_parse_PartyInfo(int fd)
{
if( RFIFOW(fd,2) == 12 ){
ShowWarning("intif: party noinfo (char_id=%d party_id=%d)\n", RFIFOL(fd,4), RFIFOL(fd,8));
- party_recv_noinfo(RFIFOL(fd,8), RFIFOL(fd,4));
+ party->recv_noinfo(RFIFOL(fd,8), RFIFOL(fd,4));
return 0;
}
if( RFIFOW(fd,2) != 8+sizeof(struct party) )
ShowError("intif: party info : data size error (char_id=%d party_id=%d packet_len=%d expected_len=%d)\n", RFIFOL(fd,4), RFIFOL(fd,8), RFIFOW(fd,2), 8+sizeof(struct party));
- party_recv_info((struct party *)RFIFOP(fd,8), RFIFOL(fd,4));
+ party->recv_info((struct party *)RFIFOP(fd,8), RFIFOL(fd,4));
return 0;
}
@@ -1071,14 +1071,14 @@ int intif_parse_PartyMemberAdded(int fd)
{
if(battle_config.etc_log)
ShowInfo("intif: party member added Party (%d), Account(%d), Char(%d)\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
- party_member_added(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10), RFIFOB(fd, 14));
+ party->member_added(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10), RFIFOB(fd, 14));
return 0;
}
// ACK changing party option
int intif_parse_PartyOptionChanged(int fd)
{
- party_optionchanged(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOW(fd,10),RFIFOW(fd,12),RFIFOB(fd,14));
+ party->optionchanged(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOW(fd,10),RFIFOW(fd,12),RFIFOB(fd,14));
return 0;
}
@@ -1087,28 +1087,28 @@ int intif_parse_PartyMemberWithdraw(int fd)
{
if(battle_config.etc_log)
ShowInfo("intif: party member withdraw: Party(%d), Account(%d), Char(%d)\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
- party_member_withdraw(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
+ party->member_withdraw(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
return 0;
}
// ACK party break
int intif_parse_PartyBroken(int fd)
{
- party_broken(RFIFOL(fd,2));
+ party->broken(RFIFOL(fd,2));
return 0;
}
// ACK party on new map
int intif_parse_PartyMove(int fd)
{
- party_recv_movemap(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOW(fd,14),RFIFOB(fd,16),RFIFOW(fd,17));
+ party->recv_movemap(RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10),RFIFOW(fd,14),RFIFOB(fd,16),RFIFOW(fd,17));
return 0;
}
// ACK party messages
int intif_parse_PartyMessage(int fd)
{
- party_recv_message(RFIFOL(fd,4),RFIFOL(fd,8),(char *) RFIFOP(fd,12),RFIFOW(fd,2)-12);
+ party->recv_message(RFIFOL(fd,4),RFIFOL(fd,8),(char *) RFIFOP(fd,12),RFIFOW(fd,2)-12);
return 0;
}
@@ -1322,7 +1322,7 @@ int intif_parse_DeletePetOk(int fd)
int intif_parse_ChangeNameOk(int fd)
{
struct map_session_data *sd = NULL;
- if((sd=map_id2sd(RFIFOL(fd,2)))==NULL ||
+ if((sd=iMap->id2sd(RFIFOL(fd,2)))==NULL ||
sd->status.char_id != RFIFOL(fd,6))
return 0;
@@ -1405,7 +1405,7 @@ int intif_parse_questlog(int fd)
{
int char_id = RFIFOL(fd, 4);
int i;
- TBL_PC * sd = map_charid2sd(char_id);
+ TBL_PC * sd = iMap->charid2sd(char_id);
//User not online anymore
if(!sd)
@@ -1442,7 +1442,7 @@ int intif_parse_questlog(int fd)
int intif_parse_questsave(int fd)
{
int cid = RFIFOL(fd, 2);
- TBL_PC *sd = map_id2sd(cid);
+ TBL_PC *sd = iMap->id2sd(cid);
if( !RFIFOB(fd, 6) )
ShowError("intif_parse_questsave: Failed to save quest(s) for character %d!\n", cid);
@@ -1500,7 +1500,7 @@ int intif_parse_Mail_inboxreceived(int fd)
struct map_session_data *sd;
unsigned char flag = RFIFOB(fd,8);
- sd = map_charid2sd(RFIFOL(fd,4));
+ sd = iMap->charid2sd(RFIFOL(fd,4));
if (sd == NULL)
{
@@ -1566,7 +1566,7 @@ int intif_parse_Mail_getattach(int fd)
struct item item;
int zeny = RFIFOL(fd,8);
- sd = map_charid2sd( RFIFOL(fd,4) );
+ sd = iMap->charid2sd( RFIFOL(fd,4) );
if (sd == NULL)
{
@@ -1582,7 +1582,7 @@ int intif_parse_Mail_getattach(int fd)
memcpy(&item, RFIFOP(fd,12), sizeof(struct item));
- mail_getattachment(sd, zeny, &item);
+ mail->getattachment(sd, zeny, &item);
return 0;
}
/*------------------------------------------
@@ -1608,7 +1608,7 @@ int intif_parse_Mail_delete(int fd)
int mail_id = RFIFOL(fd,6);
bool failed = RFIFOB(fd,10);
- struct map_session_data *sd = map_charid2sd(char_id);
+ struct map_session_data *sd = iMap->charid2sd(char_id);
if (sd == NULL)
{
ShowError("intif_parse_Mail_delete: char not found %d\n", char_id);
@@ -1651,7 +1651,7 @@ int intif_Mail_return(int char_id, int mail_id)
int intif_parse_Mail_return(int fd)
{
- struct map_session_data *sd = map_charid2sd(RFIFOL(fd,2));
+ struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2));
int mail_id = RFIFOL(fd,6);
short fail = RFIFOB(fd,10);
@@ -1714,15 +1714,15 @@ static void intif_parse_Mail_send(int fd)
fail = (msg.id == 0);
// notify sender
- sd = map_charid2sd(msg.send_id);
+ sd = iMap->charid2sd(msg.send_id);
if( sd != NULL )
{
if( fail )
- mail_deliveryfail(sd, &msg);
+ mail->deliveryfail(sd, &msg);
else
{
clif->mail_send(sd->fd, false);
- if( save_settings&16 )
+ if( iMap->save_settings&16 )
chrif_save(sd, 0);
}
}
@@ -1730,7 +1730,7 @@ static void intif_parse_Mail_send(int fd)
static void intif_parse_Mail_new(int fd)
{
- struct map_session_data *sd = map_charid2sd(RFIFOL(fd,2));
+ struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2));
int mail_id = RFIFOL(fd,6);
const char* sender_name = (char*)RFIFOP(fd,10);
const char* title = (char*)RFIFOP(fd,34);
@@ -1768,7 +1768,7 @@ int intif_Auction_requestlist(int char_id, short type, int price, const char* se
static void intif_parse_Auction_results(int fd)
{
- struct map_session_data *sd = map_charid2sd(RFIFOL(fd,4));
+ struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,4));
short count = RFIFOW(fd,8);
short pages = RFIFOW(fd,10);
uint8* data = RFIFOP(fd,12);
@@ -1807,13 +1807,13 @@ static void intif_parse_Auction_register(int fd)
}
memcpy(&auction, RFIFOP(fd,4), sizeof(struct auction_data));
- if( (sd = map_charid2sd(auction.seller_id)) == NULL )
+ if( (sd = iMap->charid2sd(auction.seller_id)) == NULL )
return;
if( auction.auction_id > 0 )
{
clif->auction_message(sd->fd, 1); // Confirmation Packet ??
- if( save_settings&32 )
+ if( iMap->save_settings&32 )
chrif_save(sd,0);
}
else
@@ -1821,9 +1821,9 @@ static void intif_parse_Auction_register(int fd)
int zeny = auction.hours*battle_config.auction_feeperhour;
clif->auction_message(sd->fd, 4);
- pc_additem(sd, &auction.item, auction.item.amount, LOG_TYPE_AUCTION);
+ pc->additem(sd, &auction.item, auction.item.amount, LOG_TYPE_AUCTION);
- pc_getzeny(sd, zeny, LOG_TYPE_AUCTION, NULL);
+ pc->getzeny(sd, zeny, LOG_TYPE_AUCTION, NULL);
}
}
@@ -1843,7 +1843,7 @@ int intif_Auction_cancel(int char_id, unsigned int auction_id)
static void intif_parse_Auction_cancel(int fd)
{
- struct map_session_data *sd = map_charid2sd(RFIFOL(fd,2));
+ struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2));
int result = RFIFOB(fd,6);
if( sd == NULL )
@@ -1874,7 +1874,7 @@ int intif_Auction_close(int char_id, unsigned int auction_id)
static void intif_parse_Auction_close(int fd)
{
- struct map_session_data *sd = map_charid2sd(RFIFOL(fd,2));
+ struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2));
unsigned char result = RFIFOB(fd,6);
if( sd == NULL )
@@ -1910,7 +1910,7 @@ int intif_Auction_bid(int char_id, const char* name, unsigned int auction_id, in
static void intif_parse_Auction_bid(int fd)
{
- struct map_session_data *sd = map_charid2sd(RFIFOL(fd,2));
+ struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2));
int bid = RFIFOL(fd,6);
unsigned char result = RFIFOB(fd,10);
@@ -1919,7 +1919,7 @@ static void intif_parse_Auction_bid(int fd)
clif->auction_message(sd->fd, result);
if( bid > 0 ) {
- pc_getzeny(sd, bid, LOG_TYPE_AUCTION,NULL);
+ pc->getzeny(sd, bid, LOG_TYPE_AUCTION,NULL);
}
if( result == 1 ) { // To update the list, display your buy list
clif->pAuction_cancelreg(fd, sd);
@@ -1930,7 +1930,7 @@ static void intif_parse_Auction_bid(int fd)
// Used to send 'You have won the auction' and 'You failed to won the auction' messages
static void intif_parse_Auction_message(int fd)
{
- struct map_session_data *sd = map_charid2sd(RFIFOL(fd,2));
+ struct map_session_data *sd = iMap->charid2sd(RFIFOL(fd,2));
unsigned char result = RFIFOB(fd,6);
if( sd == NULL )
diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c
index 0e155011e..7f03ed8d4 100644
--- a/src/map/irc-bot.c
+++ b/src/map/irc-bot.c
@@ -22,15 +22,19 @@
char send_string[200];
int irc_connect_timer(int tid, unsigned int tick, int id, intptr_t data) {
+ struct hSockOpt opt;
if( ircbot->isOn || ++ircbot->fails >= 3 )
return 0;
- ircbot->last_try = gettick();
+ opt.silent = 1;
+ opt.setTimeo = 0;
+
+ ircbot->last_try = iTimer->gettick();
- if( ( ircbot->fd = make_connection(ircbot->ip,hChSys.irc_server_port,true) ) > 0 ){
+ if( ( ircbot->fd = make_connection(ircbot->ip,hChSys.irc_server_port,&opt) ) > 0 ){
session[ircbot->fd]->func_parse = ircbot->parse;
session[ircbot->fd]->flag.server = 1;
- add_timer(gettick() + 3000, ircbot->identify_timer, 0, 0);
+ iTimer->add_timer(iTimer->gettick() + 3000, ircbot->identify_timer, 0, 0);
ircbot->isOn = true;
}
return 0;
@@ -45,7 +49,7 @@ int irc_identify_timer(int tid, unsigned int tick, int id, intptr_t data) {
sprintf(send_string, "NICK %s", hChSys.irc_nick);
ircbot->send(send_string);
- add_timer(gettick() + 3000, ircbot->join_timer, 0, 0);
+ iTimer->add_timer(iTimer->gettick() + 3000, ircbot->join_timer, 0, 0);
return 0;
}
@@ -86,7 +90,7 @@ int irc_parse(int fd) {
ircbot->isIn = false;
ircbot->fails = 0;
ircbot->ip = host2ip(hChSys.irc_server);
- add_timer(gettick() + 120000, ircbot->connect_timer, 0, 0);
+ iTimer->add_timer(iTimer->gettick() + 120000, ircbot->connect_timer, 0, 0);
return 0;
}
@@ -114,14 +118,14 @@ void irc_parse_source(char *source, char *nick, char *ident, char *host) {
for(i = 0; i < len; i++) {
if( stage == 0 && source[i] == '!' ) {
- memcpy(nick, &source[0], len - i);
+ memcpy(nick, &source[0], min(i,IRC_NICK_LENGTH));
nick[i] = '\0';
pos = i+1;
stage = 1;
} else if( stage == 1 && source[i] == '@' ) {
- memcpy(ident, &source[pos], i - pos);
+ memcpy(ident, &source[pos], min(i - pos,IRC_IDENT_LENGTH));
ident[i-pos] = '\0';
- memcpy(host, &source[i+1], len);
+ memcpy(host, &source[i+1], min(len - i,IRC_HOST_LENGTH));
host[len] = '\0';
break;
}
@@ -173,7 +177,7 @@ void irc_privmsg(int fd, char *cmd, char *source, char *target, char *msg) {
if( strcmpi(target,hChSys.irc_nick) == 0 ) {
if( msg[0] == ':' ) msg++;
if( strcmpi(msg,"VERSION") == 0 ) {
- char source_nick[40], source_ident[40], source_host[100];
+ char source_nick[IRC_NICK_LENGTH], source_ident[IRC_IDENT_LENGTH], source_host[IRC_HOST_LENGTH];
source_nick[0] = source_ident[0] = source_host[0] = '\0';
@@ -185,13 +189,13 @@ void irc_privmsg(int fd, char *cmd, char *source, char *target, char *msg) {
return;
}
} else if( strcmpi(target,hChSys.irc_channel) == 0 ) {
- char source_nick[40], source_ident[40], source_host[100];
+ char source_nick[IRC_NICK_LENGTH], source_ident[IRC_IDENT_LENGTH], source_host[IRC_HOST_LENGTH];
source_nick[0] = source_ident[0] = source_host[0] = '\0';
if( source[0] != '\0' )
ircbot->parse_source(source,source_nick,source_ident,source_host);
-
+
if( ircbot->channel ) {
snprintf(send_string, 150, "[ #%s ] IRC.%s : %s",ircbot->channel->name,source_nick,msg);
clif->chsys_msg2(ircbot->channel,send_string);
@@ -241,8 +245,8 @@ void irc_bot_init(void) {
ircbot->isIn = false;
ircbot->isOn = false;
- add_timer_func_list(ircbot->connect_timer, "irc_connect_timer");
- add_timer(gettick() + 7000, ircbot->connect_timer, 0, 0);
+ iTimer->add_timer_func_list(ircbot->connect_timer, "irc_connect_timer");
+ iTimer->add_timer(iTimer->gettick() + 7000, ircbot->connect_timer, 0, 0);
}
void irc_bot_final(void) {
diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h
index f4244e024..911a15b0e 100644
--- a/src/map/irc-bot.h
+++ b/src/map/irc-bot.h
@@ -6,6 +6,9 @@
#ifndef _IRC_BOT_H_
#define _IRC_BOT_H_
+#define IRC_NICK_LENGTH 40
+#define IRC_IDENT_LENGTH 40
+#define IRC_HOST_LENGTH 63
#define IRC_FUNC_LENGTH 30
struct hChSysCh;
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 2a5fa48de..5fae29500 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -8,6 +8,7 @@
#include "../common/showmsg.h"
#include "../common/strlib.h"
#include "../common/utils.h"
+#include "../common/conf.h"
#include "itemdb.h"
#include "map.h"
#include "battle.h" // struct battle_config
@@ -52,14 +53,12 @@ static int itemdb_searchname_sub(DBKey key, DBData *data, va_list ap)
/*==========================================
* Return item data from item name. (lookup)
*------------------------------------------*/
-struct item_data* itemdb_searchname(const char *str)
-{
+struct item_data* itemdb_searchname(const char *str) {
struct item_data* item;
struct item_data* item2=NULL;
int i;
- for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i )
- {
+ for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i ) {
item = itemdb_array[i];
if( item == NULL )
continue;
@@ -77,6 +76,10 @@ struct item_data* itemdb_searchname(const char *str)
itemdb_other->foreach(itemdb_other,itemdb_searchname_sub,str,&item,&item2);
return item?item:item2;
}
+/* name to item data */
+struct item_data* itemdb_name2id(const char *str) {
+ return strdb_get(itemdb->names,str);
+}
/**
* @see DBMatcher
@@ -98,8 +101,7 @@ static int itemdb_searchname_array_sub(DBKey key, DBData data, va_list ap)
/*==========================================
* Founds up to N matches. Returns number of matches [Skotlex]
*------------------------------------------*/
-int itemdb_searchname_array(struct item_data** data, int size, const char *str)
-{
+int itemdb_searchname_array(struct item_data** data, int size, const char *str) {
struct item_data* item;
int i;
int count=0;
@@ -132,38 +134,130 @@ int itemdb_searchname_array(struct item_data** data, int size, const char *str)
}
return count;
}
-
-
-/*==========================================
- * Return a random item id from group. (takes into account % chance giving/tot group)
- *------------------------------------------*/
-int itemdb_searchrandomid(int group)
-{
- if(group<1 || group>=MAX_ITEMGROUP) {
- ShowError("itemdb_searchrandomid: Invalid group id %d\n", group);
+/* [Ind/Hercules] */
+int itemdb_chain_item(unsigned short chain_id, int *rate) {
+ struct item_chain_entry *entry;
+ int i = 0;
+
+ if( chain_id >= itemdb->chain_count ) {
+ ShowError("itemdb_chain_item: unknown chain id %d\n", chain_id);
return UNKNOWN_ITEM_ID;
}
- if (itemgroup_db[group].qty)
- return itemgroup_db[group].nameid[rnd()%itemgroup_db[group].qty];
- ShowError("itemdb_searchrandomid: No item entries for group id %d\n", group);
- return UNKNOWN_ITEM_ID;
+ entry = &itemdb->chains[chain_id].items[ rnd()%itemdb->chains[chain_id].qty ];
+
+ for( i = 0; i < itemdb->chains[chain_id].qty; i++ ) {
+ if( rnd()%10000 >= entry->rate ) {
+ entry = entry->next;
+ continue;
+ } else {
+ if( rate )
+ rate[0] = entry->rate;
+ return entry->id;
+ }
+ }
+
+ return 0;
}
+/* [Ind/Hercules] */
+void itemdb_package_item(struct map_session_data *sd, struct item_package *package) {
+ int i = 0, get_count, j, flag;
+
+ for( i = 0; i < package->must_qty; i++ ) {
+ struct item it;
+ memset(&it, 0, sizeof(it));
+ it.nameid = package->must_items[i].id;
+ it.identify = 1;
+
+ if( package->must_items[i].hours ) {
+ it.expire_time = (unsigned int)(time(NULL) + ((package->must_items[i].hours*60)*60));
+ }
+
+ if( package->must_items[i].named ) {
+ it.card[0] = CARD0_FORGE;
+ it.card[1] = 0;
+ it.card[2] = GetWord(sd->status.char_id, 0);
+ it.card[3] = GetWord(sd->status.char_id, 1);
+ }
+
+ if( package->must_items[i].announce )
+ clif->package_announce(sd,package->must_items[i].id,package->id);
+
+ get_count = itemdb_isstackable(package->must_items[i].id) ? package->must_items[i].qty : 1;
+
+ it.amount = get_count == 1 ? 1 : get_count;
+
+ for( j = 0; j < package->must_items[i].qty; j += get_count ) {
+ if ( ( flag = pc->additem(sd, &it, get_count, LOG_TYPE_SCRIPT) ) )
+ clif->additem(sd, 0, 0, flag);
+ }
+ }
+
+ if( package->random_qty ) {
+ struct item_package_rand_entry *entry;
+
+ entry = &package->random_list[rnd()%package->random_qty];
+
+ while( 1 ) {
+ if( rnd()%10000 >= entry->rate ) {
+ entry = entry->next;
+ continue;
+ } else {
+ struct item it;
+ memset(&it, 0, sizeof(it));
+
+ it.nameid = entry->id;
+ it.identify = 1;
+
+ if( entry->hours ) {
+ it.expire_time = (unsigned int)(time(NULL) + ((entry->hours*60)*60));
+ }
+
+ if( entry->named ) {
+ it.card[0] = CARD0_FORGE;
+ it.card[1] = 0;
+ it.card[2] = GetWord(sd->status.char_id, 0);
+ it.card[3] = GetWord(sd->status.char_id, 1);
+ }
+
+ if( entry->announce )
+ clif->package_announce(sd,entry->id,package->id);
+
+ get_count = itemdb_isstackable(entry->id) ? entry->qty : 1;
+
+ it.amount = get_count == 1 ? 1 : get_count;
+
+ for( j = 0; j < entry->qty; j += get_count ) {
+ if ( ( flag = pc->additem(sd, &it, get_count, LOG_TYPE_SCRIPT) ) )
+ clif->additem(sd, 0, 0, flag);
+ }
+ break;
+ }
+ }
+ }
+
+ return;
+}
/*==========================================
- * Calculates total item-group related bonuses for the given item
+ * Return a random item id from group. (takes into account % chance giving/tot group)
*------------------------------------------*/
-int itemdb_group_bonus(struct map_session_data* sd, int itemid)
-{
- int bonus = 0, i, j;
- for (i=0; i < MAX_ITEMGROUP; i++) {
- if (!sd->itemgrouphealrate[i])
- continue;
- ARR_FIND( 0, itemgroup_db[i].qty, j, itemgroup_db[i].nameid[j] == itemid );
- if( j < itemgroup_db[i].qty )
- bonus += sd->itemgrouphealrate[i];
- }
- return bonus;
+int itemdb_searchrandomid(struct item_group *group) {
+
+ if (group->qty)
+ return group->nameid[rnd()%group->qty];
+
+ ShowError("itemdb_searchrandomid: No item entries for group id %d\n", group->id);
+ return UNKNOWN_ITEM_ID;
+}
+bool itemdb_in_group(struct item_group *group, int nameid) {
+ int i;
+
+ for( i = 0; i < group->qty; i++ )
+ if( group->nameid[i] == nameid )
+ return true;
+
+ return false;
}
/// Searches for the item_data.
@@ -296,8 +390,7 @@ static struct item_data* create_item_data(int nameid)
/*==========================================
* Loads (and creates if not found) an item from the db.
*------------------------------------------*/
-struct item_data* itemdb_load(int nameid)
-{
+struct item_data* itemdb_load(int nameid) {
struct item_data *id;
if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb_array) )
@@ -500,7 +593,7 @@ static bool itemdb_read_itemavail(char* str[], int columns, int current)
nameid = atoi(str[0]);
- if( ( id = itemdb_exists(nameid) ) == NULL )
+ if( ( id = itemdb->exists(nameid) ) == NULL )
{
ShowWarning("itemdb_read_itemavail: Invalid item id %d.\n", nameid);
return false;
@@ -521,82 +614,303 @@ static bool itemdb_read_itemavail(char* str[], int columns, int current)
return true;
}
-/*==========================================
- * read item group data
- *------------------------------------------*/
-static unsigned int itemdb_read_itemgroup_sub(const char* filename) {
- FILE *fp;
- char line[1024];
- int ln=0;
- unsigned int count = 0;
- int groupid,j,k,nameid;
- char *str[3],*p;
- char w1[1024], w2[1024];
-
- if( (fp=fopen(filename,"r"))==NULL ){
- ShowError("can't read %s\n", filename);
- return 0;
- }
+void itemdb_read_groups(void) {
+ config_t item_group_conf;
+ config_setting_t *itg = NULL, *it = NULL;
+#ifdef RENEWAL
+ const char *config_filename = "db/re/item_group.conf"; // FIXME hardcoded name
+#else
+ const char *config_filename = "db/pre-re/item_group.conf"; // FIXME hardcoded name
+#endif
+ const char *itname;
+ int i = 0, count = 0, c;
+ unsigned int *gsize = NULL;
- while(fgets(line, sizeof(line), fp))
- {
- ln++;
- if(line[0]=='/' && line[1]=='/')
+ if (conf_read_file(&item_group_conf, config_filename)) {
+ ShowError("can't read %s\n", config_filename);
+ return;
+ }
+
+ gsize = aMalloc( config_setting_length(item_group_conf.root) * sizeof(unsigned int) );
+
+ for(i = 0; i < config_setting_length(item_group_conf.root); i++)
+ gsize[i] = 0;
+
+ i = 0;
+ while( (itg = config_setting_get_elem(item_group_conf.root,i++)) ) {
+ const char *name = config_setting_name(itg);
+
+ if( !itemdb->name2id(name) ) {
+ ShowWarning("itemdb_read_groups: unknown group item '%s', skipping..\n",name);
+ config_setting_remove(item_group_conf.root, name);
+ --i;
continue;
- if(strstr(line,"import")) {
- if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2 &&
- strcmpi(w1, "import") == 0) {
- count += itemdb_read_itemgroup_sub(w2);
- continue;
- }
}
- memset(str,0,sizeof(str));
- for(j=0,p=line;j<3 && p;j++){
- str[j]=p;
- p=strchr(p,',');
- if(p) *p++=0;
+
+ c = 0;
+ while( (it = config_setting_get_elem(itg,c++)) ) {
+ if( config_setting_is_list(it) )
+ gsize[ i - 1 ] += config_setting_get_int_elem(it,1);
+ else
+ gsize[ i - 1 ] += 1;
}
- if(str[0]==NULL)
- continue;
- if (j<3) {
- if (j>1) //Or else it barks on blank lines...
- ShowWarning("itemdb_read_itemgroup: Insufficient fields for entry at %s:%d\n", filename, ln);
- continue;
+
+ }
+
+ i = 0;
+ CREATE(itemdb->groups, struct item_group, config_setting_length(item_group_conf.root));
+ itemdb->group_count = (unsigned short)config_setting_length(item_group_conf.root);
+
+ while( (itg = config_setting_get_elem(item_group_conf.root,i++)) ) {
+ struct item_data *data = itemdb->name2id(config_setting_name(itg));
+ int ecount = 0;
+
+ data->group = &itemdb->groups[count];
+
+ itemdb->groups[count].id = data->nameid;
+ itemdb->groups[count].qty = config_setting_length(itg);
+
+ CREATE(itemdb->groups[count].nameid, unsigned short, gsize[ count ] + 1);
+
+ c = 0;
+ while( (it = config_setting_get_elem(itg,c++)) ) {
+ int repeat = 1;
+ if( config_setting_is_list(it) ) {
+ itname = config_setting_get_string_elem(it,0);
+ repeat = config_setting_get_int_elem(it,1);
+ } else
+ itname = config_setting_get_string_elem(itg,c - 1);
+
+ if( !( data = itemdb->name2id(itname) ) )
+ ShowWarning("itemdb_read_groups: unknown item '%s' in group '%s'!\n",itname,config_setting_name(itg));
+
+ itemdb->groups[count].nameid[ecount] = data ? data->nameid : 0;
+ if( repeat > 1 ) {
+ //memset would be better? I failed to get the following to work though hu
+ //memset(&itemdb->groups[count].nameid[ecount+1],itemdb->groups[count].nameid[ecount],sizeof(itemdb->groups[count].nameid[0])*repeat);
+ int z;
+ for( z = ecount+1; z < ecount+repeat; z++ )
+ itemdb->groups[count].nameid[z] = itemdb->groups[count].nameid[ecount];
+ }
+ ecount += repeat;
}
- groupid = atoi(str[0]);
- if (groupid < 0 || groupid >= MAX_ITEMGROUP) {
- ShowWarning("itemdb_read_itemgroup: Invalid group %d in %s:%d\n", groupid, filename, ln);
+
+ count++;
+ }
+
+ config_destroy(&item_group_conf);
+ aFree(gsize);
+
+ ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, config_filename);
+}
+
+void itemdb_read_packages(void) {
+ config_t item_packages_conf;
+ config_setting_t *itg = NULL, *it = NULL, *t = NULL;
+#ifdef RENEWAL
+ const char *config_filename = "db/re/item_packages.conf"; // FIXME hardcoded name
+#else
+ const char *config_filename = "db/pre-re/item_packages.conf"; // FIXME hardcoded name
+#endif
+ const char *itname;
+ int i = 0, count = 0, c = 0;
+ unsigned int *must = NULL, *random = NULL;
+
+ if (conf_read_file(&item_packages_conf, config_filename)) {
+ ShowError("can't read %s\n", config_filename);
+ return;
+ }
+
+ must = aMalloc( config_setting_length(item_packages_conf.root) * sizeof(unsigned int) );
+ random = aMalloc( config_setting_length(item_packages_conf.root) * sizeof(unsigned int) );
+
+ for(i = 0; i < config_setting_length(item_packages_conf.root); i++) {
+ must[i] = 0;
+ random[i] = 0;
+ }
+
+ i = 0;
+ while( (itg = config_setting_get_elem(item_packages_conf.root,i++)) ) {
+ const char *name = config_setting_name(itg);
+
+ if( !itemdb->name2id(name) ) {
+ ShowWarning("itemdb_read_packages: unknown package item '%s', skipping..\n",name);
+ config_setting_remove(item_packages_conf.root, name);
+ --i;
continue;
}
- nameid = atoi(str[1]);
- if (!itemdb_exists(nameid)) {
- ShowWarning("itemdb_read_itemgroup: Non-existant item %d in %s:%d\n", nameid, filename, ln);
- continue;
+
+ c = 0;
+ while( (it = config_setting_get_elem(itg,c++)) ) {
+ if( ( t = config_setting_get_member(it, "Random")) && !config_setting_get_bool(t) )
+ must[ i - 1 ] += 1;
+ else
+ random[ i - 1 ] += 1;
}
- k = atoi(str[2]);
- if (itemgroup_db[groupid].qty+k >= MAX_RANDITEM) {
- ShowWarning("itemdb_read_itemgroup: Group %d is full (%d entries) in %s:%d\n", groupid, MAX_RANDITEM, filename, ln);
- continue;
+
+ }
+
+ CREATE(itemdb->packages, struct item_package, config_setting_length(item_packages_conf.root));
+ itemdb->package_count = (unsigned short)config_setting_length(item_packages_conf.root);
+
+ i = 0;
+ while( (itg = config_setting_get_elem(item_packages_conf.root,i++)) ) {
+ struct item_data *data = itemdb->name2id(config_setting_name(itg));
+ struct item_package_rand_entry *prev = NULL;
+ int r = 0, m = 0;
+
+ data->package = &itemdb->packages[count];
+
+ itemdb->packages[count].id = data->nameid;
+ itemdb->packages[count].random_list = NULL;
+ itemdb->packages[count].must_items = NULL;
+ itemdb->packages[count].random_qty = random[ i - 1 ];
+ itemdb->packages[count].must_qty = must[ i - 1 ];
+
+ if( itemdb->packages[count].random_qty )
+ CREATE(itemdb->packages[count].random_list, struct item_package_rand_entry, itemdb->packages[count].random_qty);
+ if( itemdb->packages[count].must_qty )
+ CREATE(itemdb->packages[count].must_items, struct item_package_must_entry, itemdb->packages[count].must_qty);
+
+ c = 0;
+ while( (it = config_setting_get_elem(itg,c++)) ) {
+ int icount = 1, expire = 0, rate = 10000;
+ bool announce = false, named = false;
+
+ itname = config_setting_name(it);
+
+ if( !( data = itemdb->name2id(itname) ) )
+ ShowWarning("itemdb_read_packages: unknown item '%s' in package '%s'!\n",itname,config_setting_name(itg));
+
+ if( ( t = config_setting_get_member(it, "Count")) )
+ icount = config_setting_get_int(t);
+
+ if( ( t = config_setting_get_member(it, "Expire")) )
+ expire = config_setting_get_int(t);
+
+ if( ( t = config_setting_get_member(it, "Rate")) ) {
+ if( (rate = (unsigned short)config_setting_get_int(t)) > 10000 ) {
+ ShowWarning("itemdb_read_packages: invalid rate (%d) for item '%s' in package '%s'!\n",itname,config_setting_name(itg));
+ rate = 10000;
+ }
+ }
+
+ if( ( t = config_setting_get_member(it, "Announce")) && config_setting_get_bool(t) )
+ announce = true;
+
+ if( ( t = config_setting_get_member(it, "Named")) && config_setting_get_bool(t) )
+ named = true;
+
+ if( ( t = config_setting_get_member(it, "Random")) && !config_setting_get_bool(t) ) {
+ itemdb->packages[count].must_items[m].id = data ? data->nameid : 0;
+ itemdb->packages[count].must_items[m].qty = icount;
+ itemdb->packages[count].must_items[m].hours = expire;
+ itemdb->packages[count].must_items[m].announce = announce == true ? 1 : 0;
+ itemdb->packages[count].must_items[m].named = named == true ? 1 : 0;
+ m++;
+ } else {
+ if( prev )
+ prev->next = &itemdb->packages[count].random_list[r];
+
+ itemdb->packages[count].random_list[r].id = data ? data->nameid : 0;
+ itemdb->packages[count].random_list[r].qty = icount;
+ if( (itemdb->packages[count].random_list[r].rate = rate) == 10000 ) {
+ ShowWarning("itemdb_read_packages: item '%s' in '%s' has 100% drop rate!! set this item as 'Random: false' or other items won't drop!!!\n",itname,config_setting_name(itg));
+ }
+ itemdb->packages[count].random_list[r].hours = expire;
+ itemdb->packages[count].random_list[r].announce = announce == true ? 1 : 0;
+ itemdb->packages[count].random_list[r].named = named == true ? 1 : 0;
+
+ prev = &itemdb->packages[count].random_list[r];
+
+ r++;
+ }
+
}
- for(j=0;j<k;j++)
- itemgroup_db[groupid].nameid[itemgroup_db[groupid].qty++] = nameid;
+
+ if( prev )
+ prev->next = &itemdb->packages[count].random_list[0];
+
+ if( itemdb->packages[count].random_qty == 1 ) {
+ //item packages dont stop looping until something comes out of them, so if you have only one item in it the drop is guaranteed.
+ ShowWarning("itemdb_read_packages: '%s' has only 1 random option, drop rate will be 100%!\n",itemdb_name(itemdb->packages[count].id));
+ itemdb->packages[count].random_list[0].rate = 10000;
+ }
+
count++;
}
- fclose(fp);
- return count;
+
+
+ config_destroy(&item_packages_conf);
+ aFree(must);
+ aFree(random);
+
+ ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, config_filename);
}
-static void itemdb_read_itemgroup(void)
-{
- char path[256];
- unsigned int count;
- snprintf(path, 255, "%s/"DBPATH"item_group_db.txt", db_path);
- memset(&itemgroup_db, 0, sizeof(itemgroup_db));
- count = itemdb_read_itemgroup_sub(path);
- ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, "item_group_db.txt");
- return;
+void itemdb_read_chains(void) {
+ config_t item_chain_conf;
+ config_setting_t *itc = NULL, *entry = NULL;
+#ifdef RENEWAL
+ const char *config_filename = "db/re/item_chain.conf"; // FIXME hardcoded name
+#else
+ const char *config_filename = "db/pre-re/item_chain.conf"; // FIXME hardcoded name
+#endif
+ int i = 0, count = 0;
+
+ if (conf_read_file(&item_chain_conf, config_filename)) {
+ ShowError("can't read %s\n", config_filename);
+ return;
+ }
+
+ CREATE(itemdb->chains, struct item_chain, config_setting_length(item_chain_conf.root));
+ itemdb->chain_count = (unsigned short)config_setting_length(item_chain_conf.root);
+
+ while( (itc = config_setting_get_elem(item_chain_conf.root,i++)) ) {
+ struct item_data *data = NULL;
+ struct item_chain_entry *prev = NULL;
+ const char *name = config_setting_name(itc);
+ int c = 0;
+
+ script->set_constant2(name,i-1,0);
+ itemdb->chains[count].qty = (unsigned short)config_setting_length(itc);
+
+ CREATE(itemdb->chains[count].items, struct item_chain_entry, config_setting_length(itc));
+
+ while( (entry = config_setting_get_elem(itc,c++)) ) {
+ const char *itname = config_setting_name(entry);
+ if( itname[0] == 'I' && itname[1] == 'D' && strlen(itname) < 7 ) {
+ if( !( data = itemdb->exists(atoi(itname+2)) ) )
+ ShowWarning("itemdb_read_chains: unknown item ID '%d' in chain '%s'!\n",atoi(itname+2),name);
+ } else if( !( data = itemdb->name2id(itname) ) )
+ ShowWarning("itemdb_read_chains: unknown item '%s' in chain '%s'!\n",itname,name);
+
+ if( prev )
+ prev->next = &itemdb->chains[count].items[c - 1];
+
+ itemdb->chains[count].items[c - 1].id = data ? data->nameid : 0;
+ itemdb->chains[count].items[c - 1].rate = data ? config_setting_get_int(entry) : 0;
+
+ prev = &itemdb->chains[count].items[c - 1];
+ }
+
+ if( prev )
+ prev->next = &itemdb->chains[count].items[0];
+
+ count++;
+ }
+
+ config_destroy(&item_chain_conf);
+
+ if( !script->get_constant("ITMCHAIN_ORE",&i) )
+ ShowWarning("itemdb_read_chains: failed to find 'ITMCHAIN_ORE' chain to link to cache!\n");
+ else
+ itemdb->chain_cache[ECC_ORE] = i;
+
+ ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", count, config_filename);
}
+
/*==========================================
* Reads item trade restrictions [Skotlex]
*------------------------------------------*/
@@ -607,7 +921,7 @@ static bool itemdb_read_itemtrade(char* str[], int columns, int current)
nameid = atoi(str[0]);
- if( ( id = itemdb_exists(nameid) ) == NULL )
+ if( ( id = itemdb->exists(nameid) ) == NULL )
{
//ShowWarning("itemdb_read_itemtrade: Invalid item id %d.\n", nameid);
//return false;
@@ -644,7 +958,7 @@ static bool itemdb_read_itemdelay(char* str[], int columns, int current)
nameid = atoi(str[0]);
- if( ( id = itemdb_exists(nameid) ) == NULL )
+ if( ( id = itemdb->exists(nameid) ) == NULL )
{
ShowWarning("itemdb_read_itemdelay: Invalid item id %d.\n", nameid);
return false;
@@ -674,7 +988,7 @@ static bool itemdb_read_stack(char* fields[], int columns, int current)
nameid = (unsigned short)strtoul(fields[0], NULL, 10);
- if( ( id = itemdb_exists(nameid) ) == NULL )
+ if( ( id = itemdb->exists(nameid) ) == NULL )
{
ShowWarning("itemdb_read_stack: Unknown item id '%hu'.\n", nameid);
return false;
@@ -712,7 +1026,7 @@ static bool itemdb_read_buyingstore(char* fields[], int columns, int current)
nameid = atoi(fields[0]);
- if( ( id = itemdb_exists(nameid) ) == NULL )
+ if( ( id = itemdb->exists(nameid) ) == NULL )
{
ShowWarning("itemdb_read_buyingstore: Invalid item id %d.\n", nameid);
return false;
@@ -739,7 +1053,7 @@ static bool itemdb_read_nouse(char* fields[], int columns, int current)
nameid = atoi(fields[0]);
- if( ( id = itemdb_exists(nameid) ) == NULL ) {
+ if( ( id = itemdb->exists(nameid) ) == NULL ) {
ShowWarning("itemdb_read_nouse: Invalid item id %d.\n", nameid);
return false;
}
@@ -785,7 +1099,7 @@ void itemdb_read_combos() {
char path[256];
FILE* fp;
- sprintf(path, "%s/%s", db_path, DBPATH"item_combo_db.txt");
+ sprintf(path, "%s/%s", iMap->db_path, DBPATH"item_combo_db.txt");
if ((fp = fopen(path, "r")) == NULL) {
ShowError("itemdb_read_combos: File not found \"%s\".\n", path);
@@ -848,7 +1162,7 @@ void itemdb_read_combos() {
/* validate */
for(v = 0; v < retcount; v++) {
- if( !itemdb_exists(items[v]) ) {
+ if( !itemdb->exists(items[v]) ) {
ShowError("itemdb_read_combos: line %d of \"%s\" contains unknown item ID %d, skipping.\n", lines, path,items[v]);
break;
}
@@ -857,7 +1171,7 @@ void itemdb_read_combos() {
if( v < retcount )
continue;
- id = itemdb_exists(items[0]);
+ id = itemdb->exists(items[0]);
idx = id->combos_count;
@@ -886,7 +1200,7 @@ void itemdb_read_combos() {
struct item_data * it;
int index;
- it = itemdb_exists(items[v]);
+ it = itemdb->exists(items[v]);
index = it->combos_count;
@@ -967,7 +1281,7 @@ void itemdb_re_split_atoi(char *str, int *atk, int *matk) {
/*==========================================
* processes one itemdb entry
*------------------------------------------*/
-static bool itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt) {
+int itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt) {
/*
+----+--------------+---------------+------+-----------+------------+--------+--------+---------+-------+-------+------------+-------------+---------------+-----------------+--------------+-------------+------------+------+--------+--------------+----------------+
| 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
@@ -977,12 +1291,12 @@ static bool itemdb_parse_dbrow(char** str, const char* source, int line, int scr
*/
int nameid;
struct item_data* id;
+ unsigned char offset = 0;
nameid = atoi(str[0]);
- if( nameid <= 0 )
- {
+ if( nameid <= 0 ) {
ShowWarning("itemdb_parse_dbrow: Invalid id %d in line %d of \"%s\", skipping.\n", nameid, line, source);
- return false;
+ return 0;
}
//ID,Name,Jname,Type,Price,Sell,Weight,ATK,DEF,Range,Slot,Job,Job Upper,Gender,Loc,wLV,eLV,refineable,View
@@ -1030,39 +1344,47 @@ static bool itemdb_parse_dbrow(char** str, const char* source, int line, int scr
id->weight = atoi(str[6]);
#ifdef RENEWAL
- itemdb_re_split_atoi(str[7],&id->atk,&id->matk);
+ if( iMap->db_use_sqldbs ) {
+ id->atk = atoi(str[7]);
+ id->matk = atoi(str[8]);
+ offset += 1;
+ } else
+ itemdb_re_split_atoi(str[7],&id->atk,&id->matk);
#else
id->atk = atoi(str[7]);
#endif
- id->def = atoi(str[8]);
- id->range = atoi(str[9]);
- id->slot = atoi(str[10]);
+ id->def = atoi(str[8+offset]);
+ id->range = atoi(str[9+offset]);
+ id->slot = atoi(str[10+offset]);
- if (id->slot > MAX_SLOTS)
- {
+ if (id->slot > MAX_SLOTS) {
ShowWarning("itemdb_parse_dbrow: Item %d (%s) specifies %d slots, but the server only supports up to %d. Using %d slots.\n", nameid, id->jname, id->slot, MAX_SLOTS, MAX_SLOTS);
id->slot = MAX_SLOTS;
}
- itemdb_jobid2mapid(id->class_base, (unsigned int)strtoul(str[11],NULL,0));
- id->class_upper = atoi(str[12]);
- id->sex = atoi(str[13]);
- id->equip = atoi(str[14]);
+ itemdb_jobid2mapid(id->class_base, (unsigned int)strtoul(str[11+offset],NULL,0));
+ id->class_upper = atoi(str[12+offset]);
+ id->sex = atoi(str[13+offset]);
+ id->equip = atoi(str[14+offset]);
- if (!id->equip && itemdb_isequip2(id))
- {
+ if (!id->equip && itemdb_isequip2(id)) {
ShowWarning("Item %d (%s) is an equipment with no equip-field! Making it an etc item.\n", nameid, id->jname);
id->type = IT_ETC;
}
- id->wlv = cap_value(atoi(str[15]), REFINE_TYPE_ARMOR, REFINE_TYPE_MAX);
+ id->wlv = cap_value(atoi(str[15+offset]), REFINE_TYPE_ARMOR, REFINE_TYPE_MAX);
#ifdef RENEWAL
- itemdb_re_split_atoi(str[16],&id->elv,&id->elvmax);
+ if( iMap->db_use_sqldbs ) {
+ id->elv = atoi(str[16+offset]);
+ id->elvmax = atoi(str[17+offset]);
+ offset += 1;
+ } else
+ itemdb_re_split_atoi(str[16],&id->elv,&id->elvmax);
#else
id->elv = atoi(str[16]);
#endif
- id->flag.no_refine = atoi(str[17]) ? 0 : 1; //FIXME: verify this
- id->look = atoi(str[18]);
+ id->flag.no_refine = atoi(str[17+offset]) ? 0 : 1; //FIXME: verify this
+ id->look = atoi(str[18+offset]);
id->flag.available = 1;
id->view_id = 0;
@@ -1081,14 +1403,15 @@ static bool itemdb_parse_dbrow(char** str, const char* source, int line, int scr
id->unequip_script = NULL;
}
- if (*str[19])
- id->script = parse_script(str[19], source, line, scriptopt);
- if (*str[20])
- id->equip_script = parse_script(str[20], source, line, scriptopt);
- if (*str[21])
- id->unequip_script = parse_script(str[21], source, line, scriptopt);
+ if (*str[19+offset])
+ id->script = parse_script(str[19+offset], source, line, scriptopt);
+ if (*str[20+offset])
+ id->equip_script = parse_script(str[20+offset], source, line, scriptopt);
+ if (*str[21+offset])
+ id->unequip_script = parse_script(str[21+offset], source, line, scriptopt);
- return true;
+ strdb_put(itemdb->names, id->name, id);
+ return id->nameid;
}
/*==========================================
@@ -1110,7 +1433,7 @@ static int itemdb_readdb(void)
char path[256];
FILE* fp;
- sprintf(path, "%s/%s", db_path, filename[fi]);
+ sprintf(path, "%s/%s", iMap->db_path, filename[fi]);
fp = fopen(path, "r");
if( fp == NULL ) {
ShowWarning("itemdb_readdb: File not found \"%s\", skipping.\n", path);
@@ -1205,7 +1528,7 @@ static int itemdb_readdb(void)
}
}
- if (!itemdb_parse_dbrow(str, path, lines, 0))
+ if (!itemdb->parse_dbrow(str, path, lines, 0))
continue;
count++;
@@ -1218,7 +1541,6 @@ static int itemdb_readdb(void)
return 0;
}
-
/*======================================
* item_db table reading
*======================================*/
@@ -1226,15 +1548,15 @@ static int itemdb_read_sqldb(void) {
const char* item_db_name[] = {
#ifdef RENEWAL
- item_db_re_db,
+ iMap->item_db_re_db,
#else
- item_db_db,
+ iMap->item_db_db,
#endif
- item_db2_db };
+ iMap->item_db2_db };
int fi;
for( fi = 0; fi < ARRAYLENGTH(item_db_name); ++fi ) {
- uint32 lines = 0, count = 0;
+ uint32 count = 0;
// retrieve all rows from the item database
if( SQL_ERROR == SQL->Query(mmysql_handle, "SELECT * FROM `%s`", item_db_name[fi]) ) {
@@ -1244,17 +1566,16 @@ static int itemdb_read_sqldb(void) {
// process rows one by one
while( SQL_SUCCESS == SQL->NextRow(mmysql_handle) ) {// wrap the result into a TXT-compatible format
- char* str[22];
+ char* str[ITEMDB_SQL_COLUMNS];
char* dummy = "";
int i;
- ++lines;
- for( i = 0; i < 22; ++i ) {
+ for( i = 0; i < ITEMDB_SQL_COLUMNS; ++i ) {
SQL->GetData(mmysql_handle, i, &str[i], NULL);
if( str[i] == NULL )
str[i] = dummy; // get rid of NULL columns
}
- if (!itemdb_parse_dbrow(str, item_db_name[fi], lines, SCRIPT_IGNORE_EXTERNAL_BRACKETS))
+ if (!itemdb->parse_dbrow(str, item_db_name[fi], -(atoi(str[0])), SCRIPT_IGNORE_EXTERNAL_BRACKETS))
continue;
++count;
}
@@ -1293,14 +1614,13 @@ uint64 itemdb_unique_id(int8 flag, int64 value) {
return ++item_uid;
}
-int itemdb_uid_load(){
+int itemdb_uid_load() {
char * uid;
- if (SQL_ERROR == SQL->Query(mmysql_handle, "SELECT `value` FROM `interreg` WHERE `varname`='unique_id'"))
+ if (SQL_ERROR == SQL->Query(mmysql_handle, "SELECT `value` FROM `%s` WHERE `varname`='unique_id'",iMap->interreg_db))
Sql_ShowDebug(mmysql_handle);
- if( SQL_SUCCESS != SQL->NextRow(mmysql_handle) )
- {
+ if( SQL_SUCCESS != SQL->NextRow(mmysql_handle) ) {
ShowError("itemdb_uid_load: Unable to fetch unique_id data\n");
SQL->FreeResult(mmysql_handle);
return -1;
@@ -1317,20 +1637,25 @@ int itemdb_uid_load(){
* read all item-related databases
*------------------------------------*/
static void itemdb_read(void) {
-
- if (db_use_sqldbs)
+ if (iMap->db_use_sqldbs)
itemdb_read_sqldb();
else
itemdb_readdb();
itemdb_read_combos();
- itemdb_read_itemgroup();
- sv->readdb(db_path, "item_avail.txt", ',', 2, 2, -1, &itemdb_read_itemavail);
- sv->readdb(db_path, DBPATH"item_trade.txt", ',', 3, 3, -1, &itemdb_read_itemtrade);
- sv->readdb(db_path, "item_delay.txt", ',', 2, 2, -1, &itemdb_read_itemdelay);
- sv->readdb(db_path, "item_stack.txt", ',', 3, 3, -1, &itemdb_read_stack);
- sv->readdb(db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, &itemdb_read_buyingstore);
- sv->readdb(db_path, "item_nouse.txt", ',', 3, 3, -1, &itemdb_read_nouse);
+ itemdb->read_groups();
+ itemdb->read_chains();
+ itemdb->read_packages();
+
+ sv->readdb(iMap->db_path, "item_avail.txt", ',', 2, 2, -1, &itemdb_read_itemavail);
+ sv->readdb(iMap->db_path, DBPATH"item_trade.txt", ',', 3, 3, -1, &itemdb_read_itemtrade);
+ sv->readdb(iMap->db_path, "item_delay.txt", ',', 2, 2, -1, &itemdb_read_itemdelay);
+ sv->readdb(iMap->db_path, "item_stack.txt", ',', 3, 3, -1, &itemdb_read_stack);
+ sv->readdb(iMap->db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, &itemdb_read_buyingstore);
+ sv->readdb(iMap->db_path, "item_nouse.txt", ',', 3, 3, -1, &itemdb_read_nouse);
+
+
+ itemdb->name_constants();
itemdb_uid_load();
}
@@ -1384,8 +1709,7 @@ static int itemdb_final_sub(DBKey key, DBData *data, va_list ap)
return 0;
}
-void itemdb_reload(void)
-{
+void itemdb_reload(void) {
struct s_mapiterator* iter;
struct map_session_data* sd;
@@ -1396,9 +1720,46 @@ void itemdb_reload(void)
if( itemdb_array[i] )
destroy_item_data(itemdb_array[i], 1);
+ for( i = 0; i < itemdb->group_count; i++ ) {
+ if( itemdb->groups[i].nameid )
+ aFree(itemdb->groups[i].nameid);
+ }
+
+ if( itemdb->groups )
+ aFree(itemdb->groups);
+
+ itemdb->groups = NULL;
+ itemdb->group_count = 0;
+
+ for( i = 0; i < itemdb->chain_count; i++ ) {
+ if( itemdb->chains[i].items )
+ aFree(itemdb->chains[i].items);
+ }
+
+ if( itemdb->chains )
+ aFree(itemdb->chains);
+
+ itemdb->chains = NULL;
+ itemdb->chain_count = 0;
+
+ for( i = 0; i < itemdb->package_count; i++ ) {
+ if( itemdb->packages[i].random_list )
+ aFree(itemdb->packages[i].random_list);
+ if( itemdb->packages[i].must_items )
+ aFree(itemdb->packages[i].must_items);
+ }
+
+ if( itemdb->packages )
+ aFree(itemdb->packages);
+
+ itemdb->packages = NULL;
+ itemdb->package_count = 0;
+
itemdb_other->clear(itemdb_other, itemdb_final_sub);
-
+
memset(itemdb_array, 0, sizeof(itemdb_array));
+
+ db_clear(itemdb->names);
// read new data
itemdb_read();
@@ -1435,7 +1796,7 @@ void itemdb_reload(void)
iter = mapit_geteachpc();
for( sd = (struct map_session_data*)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data*)mapit->next(iter) ) {
memset(sd->item_delay, 0, sizeof(sd->item_delay)); // reset item delays
- pc_setinventorydata(sd);
+ pc->setinventorydata(sd);
/* clear combo bonuses */
if( sd->combos.count ) {
aFree(sd->combos.bonus);
@@ -1443,32 +1804,101 @@ void itemdb_reload(void)
sd->combos.bonus = NULL;
sd->combos.id = NULL;
sd->combos.count = 0;
- if( pc_load_combo(sd) > 0 )
+ if( pc->load_combo(sd) > 0 )
status_calc_pc(sd,0);
}
}
mapit->free(iter);
}
+void itemdb_name_constants(void) {
+ DBIterator *iter = db_iterator(itemdb->names);
+ struct item_data *data;
+
+ for( data = dbi_first(iter); dbi_exists(iter); data = dbi_next(iter) )
+ script->set_constant2(data->name,data->nameid,0);
-void do_final_itemdb(void)
-{
+ dbi_destroy(iter);
+}
+void do_final_itemdb(void) {
int i;
for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i )
if( itemdb_array[i] )
destroy_item_data(itemdb_array[i], 1);
+ for( i = 0; i < itemdb->group_count; i++ ) {
+ if( itemdb->groups[i].nameid )
+ aFree(itemdb->groups[i].nameid);
+ }
+
+ if( itemdb->groups )
+ aFree(itemdb->groups);
+
+ for( i = 0; i < itemdb->chain_count; i++ ) {
+ if( itemdb->chains[i].items )
+ aFree(itemdb->chains[i].items);
+ }
+
+ if( itemdb->chains )
+ aFree(itemdb->chains);
+
+ for( i = 0; i < itemdb->package_count; i++ ) {
+ if( itemdb->packages[i].random_list )
+ aFree(itemdb->packages[i].random_list);
+ if( itemdb->packages[i].must_items )
+ aFree(itemdb->packages[i].must_items);
+ }
+
+ if( itemdb->packages )
+ aFree(itemdb->packages);
+
itemdb_other->destroy(itemdb_other, itemdb_final_sub);
destroy_item_data(&dummy_item, 0);
+ db_destroy(itemdb->names);
}
-int do_init_itemdb(void) {
+void do_init_itemdb(void) {
memset(itemdb_array, 0, sizeof(itemdb_array));
itemdb_other = idb_alloc(DB_OPT_BASE);
+ itemdb->names = strdb_alloc(DB_OPT_BASE,ITEM_NAME_LENGTH);
create_dummy_data(); //Dummy data item.
itemdb_read();
clif->cashshop_load();
-
- return 0;
+}
+/* incomplete */
+void itemdb_defaults(void) {
+ itemdb = &itemdb_s;
+
+ itemdb->init = do_init_itemdb;
+ itemdb->final = do_final_itemdb;
+ itemdb->reload = itemdb_reload;//incomplete
+ itemdb->name_constants = itemdb_name_constants;
+ /* */
+ itemdb->groups = NULL;
+ itemdb->group_count = 0;
+ /* */
+ itemdb->chains = NULL;
+ itemdb->chain_count = 0;
+ /* */
+ itemdb->packages = NULL;
+ itemdb->package_count = 0;
+ /* */
+ itemdb->names = NULL;
+ /* */
+ itemdb->read_groups = itemdb_read_groups;
+ itemdb->read_chains = itemdb_read_chains;
+ itemdb->read_packages = itemdb_read_packages;
+ /* */
+ itemdb->search_name = itemdb_searchname;
+ itemdb->search_name_array = itemdb_searchname_array;
+ itemdb->load = itemdb_load;
+ itemdb->search = itemdb_search;
+ itemdb->parse_dbrow = itemdb_parse_dbrow;
+ itemdb->exists = itemdb_exists;//incomplete
+ itemdb->name2id = itemdb_name2id;
+ itemdb->in_group = itemdb_in_group;
+ itemdb->group_item = itemdb_searchrandomid;
+ itemdb->chain_item = itemdb_chain_item;
+ itemdb->package_item = itemdb_package_item;
}
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index c441de26a..5e870a5f2 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#ifndef _ITEMDB_H_
#define _ITEMDB_H_
@@ -8,25 +9,38 @@
#include "../common/mmo.h" // ITEM_NAME_LENGTH
#include "map.h"
-// 32k array entries in array (the rest goes to the db)
-#define MAX_ITEMDB 0x8000
+/**
+ * Declarations
+ **/
+struct item_group;
+struct item_package;
-#define MAX_RANDITEM 11000
+/**
+ * Defines
+ **/
+#define MAX_ITEMDB 0x8000 // 32k array entries in array (the rest goes to the db)
+#define MAX_ITEMDELAYS 10 // The maximum number of item delays
+#define MAX_SEARCH 5 //Designed for search functions, species max number of matches to display.
+#define MAX_ITEMS_PER_COMBO 6 /* maximum amount of items a combo may require */
-// The maximum number of item delays
-#define MAX_ITEMDELAYS 10
+#define CARD0_FORGE 0x00FF
+#define CARD0_CREATE 0x00FE
+#define CARD0_PET ((short)0xFF00)
-#define MAX_SEARCH 5 //Designed for search functions, species max number of matches to display.
+//Marks if the card0 given is "special" (non-item id used to mark pets/created items. [Skotlex]
+#define itemdb_isspecial(i) (i == CARD0_FORGE || i == CARD0_CREATE || i == CARD0_PET)
-/* maximum amount of items a combo may require */
-#define MAX_ITEMS_PER_COMBO 6
+//Use apple for unknown items.
+#define UNKNOWN_ITEM_ID 512
enum item_itemid {
+ ITEMID_HOLY_WATER = 523,
ITEMID_EMPERIUM = 714,
ITEMID_YELLOW_GEMSTONE = 715,
ITEMID_RED_GEMSTONE = 716,
ITEMID_BLUE_GEMSTONE = 717,
ITEMID_TRAP = 1065,
+ ITEMID_FACE_PAINT = 6120,
ITEMID_STONE = 7049,
ITEMID_SKULL_ = 7420,
ITEMID_TOKEN_OF_SIEGFRIED = 7621,
@@ -66,27 +80,19 @@ enum {
ITEMID_CAMOUFLAGE_GENERATOR,
ITEMID_HIGH_QUALITY_COOLER,
ITEMID_SPECIAL_COOLER,
+ ITEMID_MONKEY_SPANNER = 6186,
} mecha_item_list;
enum {
NOUSE_SITTING = 0x01,
} item_nouse_list;
-//The only item group required by the code to be known. See const.txt for the full list.
-#define IG_FINDINGORE 6
-#define IG_POTION 37
-//The max. item group count (increase this when needed).
-#define MAX_ITEMGROUP 63
-
-#define CARD0_FORGE 0x00FF
-#define CARD0_CREATE 0x00FE
-#define CARD0_PET ((short)0xFF00)
-
-//Marks if the card0 given is "special" (non-item id used to mark pets/created items. [Skotlex]
-#define itemdb_isspecial(i) (i == CARD0_FORGE || i == CARD0_CREATE || i == CARD0_PET)
-
-//Use apple for unknown items.
-#define UNKNOWN_ITEM_ID 512
+//
+enum e_chain_cache {
+ ECC_ORE,
+ /* */
+ ECC_MAX,
+};
struct item_data {
uint16 nameid;
@@ -148,11 +154,9 @@ struct item_data {
/* bugreport:309 */
struct item_combo **combos;
unsigned char combos_count;
-};
-
-struct item_group {
- int nameid[MAX_RANDITEM];
- int qty; //Counts amount of items in the group.
+ /* TODO add a pointer to some sort of (struct extra) and gather all the not-common vals into it to save memory */
+ struct item_group *group;
+ struct item_package *package;
};
struct item_combo {
@@ -163,29 +167,65 @@ struct item_combo {
bool isRef;/* whether this struct is a reference or the master */
};
-struct item_group itemgroup_db[MAX_ITEMGROUP];
-
-struct item_data* itemdb_searchname(const char *name);
-int itemdb_searchname_array(struct item_data** data, int size, const char *str);
-struct item_data* itemdb_load(int nameid);
-struct item_data* itemdb_search(int nameid);
-struct item_data* itemdb_exists(int nameid);
-#define itemdb_name(n) itemdb_search(n)->name
-#define itemdb_jname(n) itemdb_search(n)->jname
-#define itemdb_type(n) itemdb_search(n)->type
-#define itemdb_atk(n) itemdb_search(n)->atk
-#define itemdb_def(n) itemdb_search(n)->def
-#define itemdb_look(n) itemdb_search(n)->look
-#define itemdb_weight(n) itemdb_search(n)->weight
-#define itemdb_equip(n) itemdb_search(n)->equip
-#define itemdb_usescript(n) itemdb_search(n)->script
-#define itemdb_equipscript(n) itemdb_search(n)->script
-#define itemdb_wlv(n) itemdb_search(n)->wlv
-#define itemdb_range(n) itemdb_search(n)->range
-#define itemdb_slot(n) itemdb_search(n)->slot
-#define itemdb_available(n) (itemdb_search(n)->flag.available)
-#define itemdb_viewid(n) (itemdb_search(n)->view_id)
-#define itemdb_autoequip(n) (itemdb_search(n)->flag.autoequip)
+struct item_group {
+ unsigned short id;
+ unsigned short *nameid;
+ unsigned short qty;
+};
+
+struct item_chain_entry {
+ unsigned short id;
+ unsigned short rate;
+ struct item_chain_entry *next;
+};
+
+struct item_chain {
+ struct item_chain_entry *items;
+ unsigned short qty;
+};
+
+struct item_package_rand_entry {
+ unsigned short id;
+ unsigned short qty;
+ unsigned short rate;
+ unsigned short hours;
+ unsigned int announce : 1;
+ unsigned int named : 1;
+ struct item_package_rand_entry *next;
+};
+
+struct item_package_must_entry {
+ unsigned short id;
+ unsigned short qty;
+ unsigned short hours;
+ unsigned int announce : 1;
+ unsigned int named : 1;
+};
+
+struct item_package {
+ unsigned short id;
+ struct item_package_rand_entry *random_list;
+ struct item_package_must_entry *must_items;
+ unsigned short random_qty;
+ unsigned short must_qty;
+};
+
+#define itemdb_name(n) itemdb->search(n)->name
+#define itemdb_jname(n) itemdb->search(n)->jname
+#define itemdb_type(n) itemdb->search(n)->type
+#define itemdb_atk(n) itemdb->search(n)->atk
+#define itemdb_def(n) itemdb->search(n)->def
+#define itemdb_look(n) itemdb->search(n)->look
+#define itemdb_weight(n) itemdb->search(n)->weight
+#define itemdb_equip(n) itemdb->search(n)->equip
+#define itemdb_usescript(n) itemdb->search(n)->script
+#define itemdb_equipscript(n) itemdb->search(n)->script
+#define itemdb_wlv(n) itemdb->search(n)->wlv
+#define itemdb_range(n) itemdb->search(n)->range
+#define itemdb_slot(n) itemdb->search(n)->slot
+#define itemdb_available(n) (itemdb->search(n)->flag.available)
+#define itemdb_viewid(n) (itemdb->search(n)->view_id)
+#define itemdb_autoequip(n) (itemdb->search(n)->flag.autoequip)
#define itemdb_is_rune(n) (n >= ITEMID_NAUTHIZ && n <= ITEMID_HAGALAZ)
#define itemdb_is_element(n) (n >= 990 && n <= 993)
#define itemdb_is_spellbook(n) (n >= 6188 && n <= 6205)
@@ -196,12 +236,9 @@ struct item_data* itemdb_exists(int nameid);
#define itemdb_is_GNthrowable(n) (n >= 13268 && n <= 13290)
const char* itemdb_typename(int type);
-int itemdb_group_bonus(struct map_session_data* sd, int itemid);
-int itemdb_searchrandomid(int flags);
-
-#define itemdb_value_buy(n) itemdb_search(n)->value_buy
-#define itemdb_value_sell(n) itemdb_search(n)->value_sell
-#define itemdb_canrefine(n) (!itemdb_search(n)->flag.no_refine)
+#define itemdb_value_buy(n) itemdb->search(n)->value_buy
+#define itemdb_value_sell(n) itemdb->search(n)->value_sell
+#define itemdb_canrefine(n) (!itemdb->search(n)->flag.no_refine)
//Item trade restrictions [Skotlex]
int itemdb_isdropable_sub(struct item_data *, int, int);
int itemdb_cantrade_sub(struct item_data*, int, int);
@@ -231,9 +268,44 @@ int itemdb_isstackable(int);
int itemdb_isstackable2(struct item_data *);
uint64 itemdb_unique_id(int8 flag, int64 value); // Unique Item ID
-void itemdb_reload(void);
+/* incomplete */
+struct itemdb_interface {
+ void (*init) (void);
+ void (*final) (void);
+ void (*reload) (void);
+ void (*name_constants) (void);
+ /* */
+ struct item_group *groups;
+ unsigned short group_count;
+ /* */
+ struct item_chain *chains;
+ unsigned short chain_count;
+ unsigned short chain_cache[ECC_MAX];
+ /* */
+ struct item_package *packages;
+ unsigned short package_count;
+ /* */
+ DBMap *names;
+ /* */
+ void (*read_groups) (void);
+ void (*read_chains) (void);
+ void (*read_packages) (void);
+ /* */
+ struct item_data* (*name2id) (const char *str);
+ struct item_data* (*search_name) (const char *name);
+ int (*search_name_array) (struct item_data** data, int size, const char *str);
+ struct item_data* (*load)(int nameid);
+ struct item_data* (*search)(int nameid);
+ int (*parse_dbrow) (char** str, const char* source, int line, int scriptopt);
+ struct item_data* (*exists) (int nameid);
+ bool (*in_group) (struct item_group *group, int nameid);
+ int (*group_item) (struct item_group *group);
+ int (*chain_item) (unsigned short chain_id, int *rate);
+ void (*package_item) (struct map_session_data *sd, struct item_package *package);
+} itemdb_s;
+
+struct itemdb_interface *itemdb;
-void do_final_itemdb(void);
-int do_init_itemdb(void);
+void itemdb_defaults(void);
#endif /* _ITEMDB_H_ */
diff --git a/src/map/log.c b/src/map/log.c
index f57b91a2a..ae516b84e 100644
--- a/src/map/log.c
+++ b/src/map/log.c
@@ -118,16 +118,16 @@ static bool should_log_item(int nameid, int amount, int refine, struct item_data
}
void log_branch_sub_sql(struct map_session_data* sd) {
SqlStmt* stmt;
- stmt = SqlStmt_Malloc(logmysql_handle);
- if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', ?, '%s')", logs->config.log_branch, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
- || SQL_SUCCESS != SqlStmt_Execute(stmt) )
+ stmt = SQL->StmtMalloc(logmysql_handle);
+ if( SQL_SUCCESS != SQL->StmtPrepare(stmt, LOG_QUERY " INTO `%s` (`branch_date`, `account_id`, `char_id`, `char_name`, `map`) VALUES (NOW(), '%d', '%d', ?, '%s')", logs->config.log_branch, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
+ || SQL_SUCCESS != SQL->StmtExecute(stmt) )
{
SqlStmt_ShowDebug(stmt);
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
return;
}
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
}
void log_branch_sub_txt(struct map_session_data* sd) {
char timestring[255];
@@ -187,14 +187,14 @@ void log_pick(int id, int16 m, e_log_pick_type type, int amount, struct item* it
/// logs item transactions (players)
void log_pick_pc(struct map_session_data* sd, e_log_pick_type type, int amount, struct item* itm, struct item_data *data) {
nullpo_retv(sd);
- log_pick(sd->status.char_id, sd->bl.m, type, amount, itm, data ? data : itemdb_exists(itm->nameid));
+ log_pick(sd->status.char_id, sd->bl.m, type, amount, itm, data ? data : itemdb->exists(itm->nameid));
}
/// logs item transactions (monsters)
void log_pick_mob(struct mob_data* md, e_log_pick_type type, int amount, struct item* itm, struct item_data *data) {
nullpo_retv(md);
- log_pick(md->class_, md->bl.m, type, amount, itm, data ? data : itemdb_exists(itm->nameid));
+ log_pick(md->class_, md->bl.m, type, amount, itm, data ? data : itemdb->exists(itm->nameid));
}
void log_zeny_sub_sql(struct map_session_data* sd, e_log_pick_type type, struct map_session_data* src_sd, int amount) {
if( SQL_ERROR == SQL->Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%c', '%d', '%s')",
@@ -260,17 +260,17 @@ void log_mvpdrop(struct map_session_data* sd, int monster_id, int* log_mvp)
void log_atcommand_sub_sql(struct map_session_data* sd, const char* message) {
SqlStmt* stmt;
- stmt = SqlStmt_Malloc(logmysql_handle);
- if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`atcommand_date`, `account_id`, `char_id`, `char_name`, `map`, `command`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", logs->config.log_gm, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, 255))
- || SQL_SUCCESS != SqlStmt_Execute(stmt) )
+ stmt = SQL->StmtMalloc(logmysql_handle);
+ if( SQL_SUCCESS != SQL->StmtPrepare(stmt, LOG_QUERY " INTO `%s` (`atcommand_date`, `account_id`, `char_id`, `char_name`, `map`, `command`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", logs->config.log_gm, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, 255))
+ || SQL_SUCCESS != SQL->StmtExecute(stmt) )
{
SqlStmt_ShowDebug(stmt);
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
return;
}
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
}
void log_atcommand_sub_txt(struct map_session_data* sd, const char* message) {
char timestring[255];
@@ -298,17 +298,17 @@ void log_atcommand(struct map_session_data* sd, const char* message)
void log_npc_sub_sql(struct map_session_data *sd, const char *message) {
SqlStmt* stmt;
- stmt = SqlStmt_Malloc(logmysql_handle);
- if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", logs->config.log_npc, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, 255))
- || SQL_SUCCESS != SqlStmt_Execute(stmt) )
+ stmt = SQL->StmtMalloc(logmysql_handle);
+ if( SQL_SUCCESS != SQL->StmtPrepare(stmt, LOG_QUERY " INTO `%s` (`npc_date`, `account_id`, `char_id`, `char_name`, `map`, `mes`) VALUES (NOW(), '%d', '%d', ?, '%s', ?)", logs->config.log_npc, sd->status.account_id, sd->status.char_id, mapindex_id2name(sd->mapindex) )
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, sd->status.name, strnlen(sd->status.name, NAME_LENGTH))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, 255))
+ || SQL_SUCCESS != SQL->StmtExecute(stmt) )
{
SqlStmt_ShowDebug(stmt);
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
return;
}
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
}
void log_npc_sub_txt(struct map_session_data *sd, const char *message) {
char timestring[255];
@@ -336,17 +336,17 @@ void log_npc(struct map_session_data* sd, const char* message)
void log_chat_sub_sql(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message) {
SqlStmt* stmt;
- stmt = SqlStmt_Malloc(logmysql_handle);
- if( SQL_SUCCESS != SqlStmt_Prepare(stmt, LOG_QUERY " INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%c', '%d', '%d', '%d', '%s', '%d', '%d', ?, ?)", logs->config.log_chat, log_chattype2char(type), type_id, src_charid, src_accid, map, x, y)
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, (char*)dst_charname, safestrnlen(dst_charname, NAME_LENGTH))
- || SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, CHAT_SIZE_MAX))
- || SQL_SUCCESS != SqlStmt_Execute(stmt) )
+ stmt = SQL->StmtMalloc(logmysql_handle);
+ if( SQL_SUCCESS != SQL->StmtPrepare(stmt, LOG_QUERY " INTO `%s` (`time`, `type`, `type_id`, `src_charid`, `src_accountid`, `src_map`, `src_map_x`, `src_map_y`, `dst_charname`, `message`) VALUES (NOW(), '%c', '%d', '%d', '%d', '%s', '%d', '%d', ?, ?)", logs->config.log_chat, log_chattype2char(type), type_id, src_charid, src_accid, map, x, y)
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, (char*)dst_charname, safestrnlen(dst_charname, NAME_LENGTH))
+ || SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, (char*)message, safestrnlen(message, CHAT_SIZE_MAX))
+ || SQL_SUCCESS != SQL->StmtExecute(stmt) )
{
SqlStmt_ShowDebug(stmt);
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
return;
}
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
}
void log_chat_sub_txt(e_log_chat_type type, int type_id, int src_charid, int src_accid, const char* map, int x, int y, const char* dst_charname, const char* message) {
char timestring[255];
@@ -369,7 +369,7 @@ void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid,
return;
}
- if( logs->config.log_chat_woe_disable && ( agit_flag || agit2_flag ) )
+ if( logs->config.log_chat_woe_disable && ( iMap->agit_flag || iMap->agit2_flag ) )
{// no chat logging during woe
return;
}
diff --git a/src/map/mail.c b/src/map/mail.c
index fa842b70f..9a8d4e521 100644
--- a/src/map/mail.c
+++ b/src/map/mail.c
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#include "../common/nullpo.h"
#include "../common/showmsg.h"
@@ -31,7 +32,7 @@ int mail_removeitem(struct map_session_data *sd, short flag)
if( sd->mail.amount )
{
if (flag) // Item send
- pc_delitem(sd, sd->mail.index, sd->mail.amount, 1, 0, LOG_TYPE_MAIL);
+ pc->delitem(sd, sd->mail.index, sd->mail.amount, 1, 0, LOG_TYPE_MAIL);
else
clif->additem(sd, sd->mail.index, sd->mail.amount, 0);
}
@@ -48,7 +49,7 @@ int mail_removezeny(struct map_session_data *sd, short flag)
if (flag && sd->mail.zeny > 0)
{ //Zeny send
- pc_payzeny(sd,sd->mail.zeny,LOG_TYPE_MAIL, NULL);
+ pc->payzeny(sd,sd->mail.zeny,LOG_TYPE_MAIL, NULL);
}
sd->mail.zeny = 0;
@@ -61,7 +62,7 @@ unsigned char mail_setitem(struct map_session_data *sd, int idx, int amount) {
return 1;
if( idx == 0 ) { // Zeny Transfer
- if( amount < 0 || !pc_can_give_items(sd) )
+ if( amount < 0 || !pc->can_give_items(sd) )
return 1;
if( amount > sd->status.zeny )
@@ -72,14 +73,14 @@ unsigned char mail_setitem(struct map_session_data *sd, int idx, int amount) {
return 0;
} else { // Item Transfer
idx -= 2;
- mail_removeitem(sd, 0);
+ mail->removeitem(sd, 0);
if( idx < 0 || idx >= MAX_INVENTORY )
return 1;
if( amount < 0 || amount > sd->status.inventory[idx].amount )
return 1;
- if( !pc_can_give_items(sd) || sd->status.inventory[idx].expire_time ||
- !itemdb_canmail(&sd->status.inventory[idx],pc_get_group_level(sd)) )
+ if( !pc->can_give_items(sd) || sd->status.inventory[idx].expire_time ||
+ !itemdb_canmail(&sd->status.inventory[idx],pc->get_group_level(sd)) )
return 1;
sd->mail.index = idx;
@@ -121,8 +122,8 @@ bool mail_setattachment(struct map_session_data *sd, struct mail_message *msg)
msg->zeny = sd->mail.zeny;
// Removes the attachment from sender
- mail_removeitem(sd,1);
- mail_removezeny(sd,1);
+ mail->removeitem(sd,1);
+ mail->removezeny(sd,1);
return true;
}
@@ -131,13 +132,13 @@ void mail_getattachment(struct map_session_data* sd, int zeny, struct item* item
{
if( item->nameid > 0 && item->amount > 0 )
{
- pc_additem(sd, item, item->amount, LOG_TYPE_MAIL);
+ pc->additem(sd, item, item->amount, LOG_TYPE_MAIL);
clif->mail_getattachment(sd->fd, 0);
}
if( zeny > 0 )
{ //Zeny receive
- pc_getzeny(sd, zeny,LOG_TYPE_MAIL, NULL);
+ pc->getzeny(sd, zeny,LOG_TYPE_MAIL, NULL);
}
}
@@ -161,12 +162,12 @@ void mail_deliveryfail(struct map_session_data *sd, struct mail_message *msg)
if( msg->item.amount > 0 )
{
// Item receive (due to failure)
- pc_additem(sd, &msg->item, msg->item.amount, LOG_TYPE_MAIL);
+ pc->additem(sd, &msg->item, msg->item.amount, LOG_TYPE_MAIL);
}
if( msg->zeny > 0 )
{
- pc_getzeny(sd,msg->zeny,LOG_TYPE_MAIL, NULL); //Zeny receive (due to failure)
+ pc->getzeny(sd,msg->zeny,LOG_TYPE_MAIL, NULL); //Zeny receive (due to failure)
}
clif->mail_send(sd->fd, true);
@@ -175,7 +176,7 @@ void mail_deliveryfail(struct map_session_data *sd, struct mail_message *msg)
// This function only check if the mail operations are valid
bool mail_invalid_operation(struct map_session_data *sd)
{
- if( !map[sd->bl.m].flag.town && !pc_can_use_command(sd, "@mail") )
+ if( !map[sd->bl.m].flag.town && !pc->can_use_command(sd, "@mail") )
{
ShowWarning("clif->parse_Mail: char '%s' trying to do invalid mail operations.\n", sd->status.name);
return true;
@@ -183,3 +184,18 @@ bool mail_invalid_operation(struct map_session_data *sd)
return false;
}
+
+void mail_defaults(void)
+{
+ mail = &mail_s;
+
+ mail->clear = mail_clear;
+ mail->removeitem = mail_removeitem;
+ mail->removezeny = mail_removezeny;
+ mail->setitem = mail_setitem;
+ mail->setattachment = mail_setattachment;
+ mail->getattachment = mail_getattachment;
+ mail->openmail = mail_openmail;
+ mail->deliveryfail = mail_deliveryfail;
+ mail->invalid_operation = mail_invalid_operation;
+} \ No newline at end of file
diff --git a/src/map/mail.h b/src/map/mail.h
index cab582e55..99742c7bd 100644
--- a/src/map/mail.h
+++ b/src/map/mail.h
@@ -1,19 +1,26 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#ifndef _MAIL_H_
#define _MAIL_H_
#include "../common/mmo.h"
-void mail_clear(struct map_session_data *sd);
-int mail_removeitem(struct map_session_data *sd, short flag);
-int mail_removezeny(struct map_session_data *sd, short flag);
-unsigned char mail_setitem(struct map_session_data *sd, int idx, int amount);
-bool mail_setattachment(struct map_session_data *sd, struct mail_message *msg);
-void mail_getattachment(struct map_session_data* sd, int zeny, struct item* item);
-int mail_openmail(struct map_session_data *sd);
-void mail_deliveryfail(struct map_session_data *sd, struct mail_message *msg);
-bool mail_invalid_operation(struct map_session_data *sd);
+struct mail_interface {
+ void (*clear) (struct map_session_data *sd);
+ int (*removeitem) (struct map_session_data *sd, short flag);
+ int (*removezeny) (struct map_session_data *sd, short flag);
+ unsigned char (*setitem) (struct map_session_data *sd, int idx, int amount);
+ bool (*setattachment) (struct map_session_data *sd, struct mail_message *msg);
+ void (*getattachment) (struct map_session_data* sd, int zeny, struct item* item);
+ int (*openmail) (struct map_session_data *sd);
+ void (*deliveryfail) (struct map_session_data *sd, struct mail_message *msg);
+ bool (*invalid_operation) (struct map_session_data *sd);
+} mail_s;
+
+struct mail_interface *mail;
+
+void mail_defaults(void);
#endif /* _MAIL_H_ */
diff --git a/src/map/map.c b/src/map/map.c
index d4c15cd6e..74e2c74e0 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -70,14 +70,7 @@ char map_server_pw[32] = "ragnarok";
char map_server_db[32] = "ragnarok";
Sql* mmysql_handle;
-int db_use_sqldbs = 0;
-char item_db_db[32] = "item_db";
-char item_db2_db[32] = "item_db2";
-char item_db_re_db[32] = "item_db_re";
-char mob_db_db[32] = "mob_db";
-char mob_db2_db[32] = "mob_db2";
-char mob_skill_db_db[32] = "mob_skill_db";
-char mob_skill_db2_db[32] = "mob_skill_db2";
+int map_port=0;
// log database
char log_db_ip[32] = "127.0.0.1";
@@ -87,21 +80,12 @@ char log_db_pw[32] = "ragnarok";
char log_db_db[32] = "log";
Sql* logmysql_handle;
-char *INTER_CONF_NAME;
-char *LOG_CONF_NAME;
-char *MAP_CONF_NAME;
-char *BATTLE_CONF_FILENAME;
-char *ATCOMMAND_CONF_FILENAME;
-char *SCRIPT_CONF_NAME;
-char *MSG_CONF_NAME;
-char *GRF_PATH_FILENAME;
-
// DBMap declaartion
static DBMap* id_db=NULL; // int id -> struct block_list*
static DBMap* pc_db=NULL; // int id -> struct map_session_data*
static DBMap* mobid_db=NULL; // int id -> struct mob_data*
static DBMap* bossid_db=NULL; // int id -> struct mob_data* (MVP db)
-static DBMap* map_db=NULL; // unsigned int mapindex -> struct map_data*
+static DBMap* map_db=NULL; // unsigned int mapindex -> struct map_data_other_server*
static DBMap* nick_db=NULL; // int char_id -> struct charid2nick* (requested names of offline characters)
static DBMap* charid_db=NULL; // int char_id -> struct map_session_data*
static DBMap* regen_db=NULL; // int id -> struct block_list* (status_natural_heal processing)
@@ -117,16 +101,6 @@ static int block_free_count = 0, block_free_lock = 0;
static struct block_list *bl_list[BL_LIST_MAX];
static int bl_list_count = 0;
-int map_num = 0;
-int map_port=0;
-
-int autosave_interval = DEFAULT_AUTOSAVE_INTERVAL;
-int minsave_interval = 100;
-int save_settings = 0xFFFF;
-int agit_flag = 0;
-int agit2_flag = 0;
-int night_flag = 0; // 0=day, 1=night [Yor]
-
struct charid_request {
struct charid_request* next;
int charid;// who want to be notified of the nick
@@ -150,22 +124,17 @@ struct map_cache_map_info {
int32 len;
};
-char db_path[256] = "db";
-char help_txt[256] = "conf/help.txt";
-char help2_txt[256] = "conf/help2.txt";
-char charhelp_txt[256] = "conf/charhelp.txt";
+int16 index2mapid[MAX_MAPINDEX];
-char wisp_server_name[NAME_LENGTH] = "Server"; // can be modified in char-server configuration file
-
-int enable_spy = 0; //To enable/disable @spy commands, which consume too much cpu time when sending packets. [Skotlex]
int enable_grf = 0; //To enable/disable reading maps from GRF files, bypassing mapcache [blackhole89]
/* [Ind/Hercules] */
struct eri *map_iterator_ers;
+char *map_cache_buffer = NULL; // Has the uncompressed gat data of all maps, so just one allocation has to be made
/*==========================================
- * server player count (of all mapservers)
- *------------------------------------------*/
+* server player count (of all mapservers)
+*------------------------------------------*/
void map_setusers(int users)
{
map_users = users;
@@ -177,8 +146,8 @@ int map_getusers(void)
}
/*==========================================
- * server player count (this mapserver only)
- *------------------------------------------*/
+* server player count (this mapserver only)
+*------------------------------------------*/
int map_usercount(void)
{
return pc_db->size(pc_db);
@@ -186,8 +155,8 @@ int map_usercount(void)
/*==========================================
- * Attempt to free a map blocklist
- *------------------------------------------*/
+* Attempt to free a map blocklist
+*------------------------------------------*/
int map_freeblock (struct block_list *bl)
{
nullpo_retr(block_free_lock, bl);
@@ -203,16 +172,16 @@ int map_freeblock (struct block_list *bl)
return block_free_lock;
}
/*==========================================
- * Lock blocklist, (prevent map_freeblock usage)
- *------------------------------------------*/
+* Lock blocklist, (prevent iMap->freeblock usage)
+*------------------------------------------*/
int map_freeblock_lock (void)
{
return ++block_free_lock;
}
/*==========================================
- * Remove the lock on map_bl
- *------------------------------------------*/
+* Remove the lock on map_bl
+*------------------------------------------*/
int map_freeblock_unlock (void)
{
if ((--block_free_lock) == 0) {
@@ -238,7 +207,7 @@ int map_freeblock_timer(int tid, unsigned int tick, int id, intptr_t data)
if (block_free_lock > 0) {
ShowError("map_freeblock_timer: block_free_lock(%d) is invalid.\n", block_free_lock);
block_free_lock = 1;
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
}
return 0;
@@ -248,16 +217,16 @@ int map_freeblock_timer(int tid, unsigned int tick, int id, intptr_t data)
// blocklist
//
/*==========================================
- * Handling of map_bl[]
- * The adresse of bl_heal is set in bl->prev
- *------------------------------------------*/
+* Handling of map_bl[]
+* The adresse of bl_heal is set in bl->prev
+*------------------------------------------*/
static struct block_list bl_head;
#ifdef CELL_NOSTACK
/*==========================================
- * These pair of functions update the counter of how many objects
- * lie on a tile.
- *------------------------------------------*/
+* These pair of functions update the counter of how many objects
+* lie on a tile.
+*------------------------------------------*/
static void map_addblcell(struct block_list *bl)
{
if( bl->m<0 || bl->x<0 || bl->x>=map[bl->m].xs || bl->y<0 || bl->y>=map[bl->m].ys || !(bl->type&BL_CHAR) )
@@ -275,9 +244,9 @@ static void map_delblcell(struct block_list *bl)
#endif
/*==========================================
- * Adds a block to the map.
- * Returns 0 on success, 1 on failure (illegal coordinates).
- *------------------------------------------*/
+* Adds a block to the map.
+* Returns 0 on success, 1 on failure (illegal coordinates).
+*------------------------------------------*/
int map_addblock(struct block_list* bl)
{
int16 m, x, y;
@@ -293,9 +262,9 @@ int map_addblock(struct block_list* bl)
m = bl->m;
x = bl->x;
y = bl->y;
- if( m < 0 || m >= map_num )
+ if( m < 0 || m >= iMap->map_num )
{
- ShowError("map_addblock: invalid map id (%d), only %d are loaded.\n", m, map_num);
+ ShowError("map_addblock: invalid map id (%d), only %d are loaded.\n", m, iMap->map_num);
return 1;
}
if( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys )
@@ -326,14 +295,14 @@ int map_addblock(struct block_list* bl)
}
/*==========================================
- * Removes a block from the map.
- *------------------------------------------*/
+* Removes a block from the map.
+*------------------------------------------*/
int map_delblock(struct block_list* bl)
{
int pos;
nullpo_ret(bl);
- // blocklist (2ways chainlist)
+ // blocklist (2ways chainlist)
if (bl->prev == NULL) {
if (bl->next != NULL) {
// can't delete block (already at the begining of the chain)
@@ -351,7 +320,7 @@ int map_delblock(struct block_list* bl)
if (bl->next)
bl->next->prev = bl->prev;
if (bl->prev == &bl_head) {
- //Since the head of the list, update the block_list map of []
+ //Since the head of the list, update the block_list map of []
if (bl->type == BL_MOB) {
map[bl->m].block_mob[pos] = bl->next;
} else {
@@ -367,10 +336,10 @@ int map_delblock(struct block_list* bl)
}
/*==========================================
- * Moves a block a x/y target position. [Skotlex]
- * Pass flag as 1 to prevent doing skill->unit_move checks
- * (which are executed by default on BL_CHAR types)
- *------------------------------------------*/
+* Moves a block a x/y target position. [Skotlex]
+* Pass flag as 1 to prevent doing skill->unit_move checks
+* (which are executed by default on BL_CHAR types)
+*------------------------------------------*/
int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick)
{
int x0 = bl->x, y0 = bl->y;
@@ -389,25 +358,24 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick)
sc = status_get_sc(bl);
skill->unit_move(bl,tick,2);
- status_change_end(bl, SC_CLOSECONFINE, INVALID_TIMER);
- status_change_end(bl, SC_CLOSECONFINE2, INVALID_TIMER);
-// status_change_end(bl, SC_BLADESTOP, INVALID_TIMER); //Won't stop when you are knocked away, go figure...
- status_change_end(bl, SC_TATAMIGAESHI, INVALID_TIMER);
+ status_change_end(bl, SC_RG_CCONFINE_M, INVALID_TIMER);
+ status_change_end(bl, SC_RG_CCONFINE_S, INVALID_TIMER);
+ // status_change_end(bl, SC_BLADESTOP, INVALID_TIMER); //Won't stop when you are knocked away, go figure...
+ status_change_end(bl, SC_NJ_TATAMIGAESHI, INVALID_TIMER);
status_change_end(bl, SC_MAGICROD, INVALID_TIMER);
if (sc->data[SC_PROPERTYWALK] &&
sc->data[SC_PROPERTYWALK]->val3 >= skill->get_maxcount(sc->data[SC_PROPERTYWALK]->val1,sc->data[SC_PROPERTYWALK]->val2) )
status_change_end(bl,SC_PROPERTYWALK,INVALID_TIMER);
- } else
- if (bl->type == BL_NPC)
+ } else if (bl->type == BL_NPC)
npc_unsetcells((TBL_NPC*)bl);
- if (moveblock) map_delblock(bl);
+ if (moveblock) iMap->delblock(bl);
#ifdef CELL_NOSTACK
else map_delblcell(bl);
#endif
bl->x = x1;
bl->y = y1;
- if (moveblock) map_addblock(bl);
+ if (moveblock) iMap->addblock(bl);
#ifdef CELL_NOSTACK
else map_addblcell(bl);
#endif
@@ -418,7 +386,7 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick)
if( bl->type == BL_PC && ((TBL_PC*)bl)->shadowform_id ) {//Shadow Form Target Moving
struct block_list *d_bl;
- if( (d_bl = map_id2bl(((TBL_PC*)bl)->shadowform_id)) == NULL || !check_distance_bl(bl,d_bl,10) ) {
+ if( (d_bl = iMap->id2bl(((TBL_PC*)bl)->shadowform_id)) == NULL || !check_distance_bl(bl,d_bl,10) ) {
if( d_bl )
status_change_end(d_bl,SC__SHADOWFORM,INVALID_TIMER);
((TBL_PC*)bl)->shadowform_id = 0;
@@ -443,14 +411,14 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick)
if( sc->data[SC__SHADOWFORM] ) {//Shadow Form Caster Moving
struct block_list *d_bl;
- if( (d_bl = map_id2bl(sc->data[SC__SHADOWFORM]->val2)) == NULL || !check_distance_bl(bl,d_bl,10) )
+ if( (d_bl = iMap->id2bl(sc->data[SC__SHADOWFORM]->val2)) == NULL || !check_distance_bl(bl,d_bl,10) )
status_change_end(bl,SC__SHADOWFORM,INVALID_TIMER);
}
if (sc->data[SC_PROPERTYWALK]
- && sc->data[SC_PROPERTYWALK]->val3 < skill->get_maxcount(sc->data[SC_PROPERTYWALK]->val1,sc->data[SC_PROPERTYWALK]->val2)
- && map_find_skill_unit_oncell(bl,bl->x,bl->y,SO_ELECTRICWALK,NULL,0) == NULL
- && map_find_skill_unit_oncell(bl,bl->x,bl->y,SO_FIREWALK,NULL,0) == NULL
+ && sc->data[SC_PROPERTYWALK]->val3 < skill->get_maxcount(sc->data[SC_PROPERTYWALK]->val1,sc->data[SC_PROPERTYWALK]->val2)
+ && iMap->find_skill_unit_oncell(bl,bl->x,bl->y,SO_ELECTRICWALK,NULL,0) == NULL
+ && iMap->find_skill_unit_oncell(bl,bl->x,bl->y,SO_FIREWALK,NULL,0) == NULL
&& skill->unitsetting(bl,sc->data[SC_PROPERTYWALK]->val1,sc->data[SC_PROPERTYWALK]->val2,x0, y0,0)) {
sc->data[SC_PROPERTYWALK]->val3++;
}
@@ -469,16 +437,15 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick)
skill->unit_move_unit_group(skill->id2group(sc->data[SC_HAWKEYES]->val4), bl->m, x1-x0, y1-y0);
}
}
- } else
- if (bl->type == BL_NPC)
+ } else if (bl->type == BL_NPC)
npc_setcells((TBL_NPC*)bl);
return 0;
}
/*==========================================
- * Counts specified number of objects on given cell.
- *------------------------------------------*/
+* Counts specified number of objects on given cell.
+*------------------------------------------*/
int map_count_oncell(int16 m, int16 x, int16 y, int type)
{
int bx,by;
@@ -504,9 +471,9 @@ int map_count_oncell(int16 m, int16 x, int16 y, int type)
return count;
}
/*
- * Looks for a skill unit on a given cell
- * flag&1: runs battle_check_target check based on unit->group->target_flag
- */
+* Looks for a skill unit on a given cell
+* flag&1: runs battle_check_target check based on unit->group->target_flag
+*/
struct skill_unit* map_find_skill_unit_oncell(struct block_list* target,int16 x,int16 y,uint16 skill_id,struct skill_unit* out_unit, int flag) {
int16 m,bx,by;
struct block_list *bl;
@@ -534,8 +501,8 @@ struct skill_unit* map_find_skill_unit_oncell(struct block_list* target,int16 x,
}
/*==========================================
- * Adapted from foreachinarea for an easier invocation. [Skotlex]
- *------------------------------------------*/
+* Adapted from foreachinarea for an easier invocation. [Skotlex]
+*------------------------------------------*/
int map_foreachinrange(int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int type, ...)
{
int bx, by, m;
@@ -560,47 +527,47 @@ int map_foreachinrange(int (*func)(struct block_list*,va_list), struct block_lis
#ifdef CIRCULAR_AREA
&& check_distance_bl(center, bl, range)
#endif
- && bl_list_count < BL_LIST_MAX )
+ && bl_list_count < BL_LIST_MAX )
bl_list[ bl_list_count++ ] = bl;
}
}
}
- if( type&BL_MOB )
- for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
- for(bx=x0/BLOCK_SIZE;bx<=x1/BLOCK_SIZE;bx++) {
- for( bl = map[ m ].block_mob[ bx + by * map[ m ].bxs ]; bl != NULL; bl = bl->next ) {
- if( bl->x >= x0 && bl->x <= x1 && bl->y >= y0 && bl->y <= y1
+ if( type&BL_MOB )
+ for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
+ for(bx=x0/BLOCK_SIZE;bx<=x1/BLOCK_SIZE;bx++) {
+ for( bl = map[ m ].block_mob[ bx + by * map[ m ].bxs ]; bl != NULL; bl = bl->next ) {
+ if( bl->x >= x0 && bl->x <= x1 && bl->y >= y0 && bl->y <= y1
#ifdef CIRCULAR_AREA
- && check_distance_bl(center, bl, range)
+ && check_distance_bl(center, bl, range)
#endif
- && bl_list_count < BL_LIST_MAX )
- bl_list[ bl_list_count++ ] = bl;
+ && bl_list_count < BL_LIST_MAX )
+ bl_list[ bl_list_count++ ] = bl;
+ }
}
}
- }
- if( bl_list_count >= BL_LIST_MAX )
- ShowWarning("map_foreachinrange: block count too many!\n");
+ if( bl_list_count >= BL_LIST_MAX )
+ ShowWarning("iMap->foreachinrange: block count too many!\n");
- map_freeblock_lock();
+ iMap->freeblock_lock();
- for( i = blockcount; i < bl_list_count; i++ )
- if( bl_list[ i ]->prev ) { //func() may delete this bl_list[] slot, checking for prev ensures it wasnt queued for deletion.
- va_start(ap, type);
- returnCount += func(bl_list[ i ], ap);
- va_end(ap);
- }
+ for( i = blockcount; i < bl_list_count; i++ )
+ if( bl_list[ i ]->prev ) { //func() may delete this bl_list[] slot, checking for prev ensures it wasnt queued for deletion.
+ va_start(ap, type);
+ returnCount += func(bl_list[ i ], ap);
+ va_end(ap);
+ }
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
- bl_list_count = blockcount;
- return returnCount; //[Skotlex]
+ bl_list_count = blockcount;
+ return returnCount; //[Skotlex]
}
/*==========================================
- * Same as foreachinrange, but there must be a shoot-able range between center and target to be counted in. [Skotlex]
- *------------------------------------------*/
+* Same as foreachinrange, but there must be a shoot-able range between center and target to be counted in. [Skotlex]
+*------------------------------------------*/
int map_foreachinshootrange(int (*func)(struct block_list*,va_list),struct block_list* center, int16 range, int type,...)
{
int bx, by, m;
@@ -629,49 +596,49 @@ int map_foreachinshootrange(int (*func)(struct block_list*,va_list),struct block
&& check_distance_bl(center, bl, range)
#endif
&& path_search_long(NULL, center->m, center->x, center->y, bl->x, bl->y, CELL_CHKWALL)
- && bl_list_count < BL_LIST_MAX )
+ && bl_list_count < BL_LIST_MAX )
bl_list[ bl_list_count++ ] = bl;
}
}
}
- if( type&BL_MOB )
- for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
- for( bx=x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++ ) {
- for( bl = map[ m ].block_mob[ bx + by * map[ m ].bxs ]; bl != NULL; bl = bl->next ) {
- if( bl->x >= x0 && bl->x <= x1 && bl->y >= y0 && bl->y <= y1
+ if( type&BL_MOB )
+ for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
+ for( bx=x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++ ) {
+ for( bl = map[ m ].block_mob[ bx + by * map[ m ].bxs ]; bl != NULL; bl = bl->next ) {
+ if( bl->x >= x0 && bl->x <= x1 && bl->y >= y0 && bl->y <= y1
#ifdef CIRCULAR_AREA
- && check_distance_bl(center, bl, range)
+ && check_distance_bl(center, bl, range)
#endif
- && path_search_long(NULL, center->m, center->x, center->y, bl->x, bl->y, CELL_CHKWALL)
- && bl_list_count < BL_LIST_MAX )
- bl_list[ bl_list_count++ ] = bl;
+ && path_search_long(NULL, center->m, center->x, center->y, bl->x, bl->y, CELL_CHKWALL)
+ && bl_list_count < BL_LIST_MAX )
+ bl_list[ bl_list_count++ ] = bl;
+ }
}
}
- }
- if( bl_list_count >= BL_LIST_MAX )
- ShowWarning("map_foreachinrange: block count too many!\n");
+ if( bl_list_count >= BL_LIST_MAX )
+ ShowWarning("iMap->foreachinrange: block count too many!\n");
- map_freeblock_lock();
+ iMap->freeblock_lock();
- for( i = blockcount; i < bl_list_count; i++ )
- if( bl_list[ i ]->prev ) { //func() may delete this bl_list[] slot, checking for prev ensures it wasnt queued for deletion.
- va_start(ap, type);
- returnCount += func(bl_list[ i ], ap);
- va_end(ap);
- }
+ for( i = blockcount; i < bl_list_count; i++ )
+ if( bl_list[ i ]->prev ) { //func() may delete this bl_list[] slot, checking for prev ensures it wasnt queued for deletion.
+ va_start(ap, type);
+ returnCount += func(bl_list[ i ], ap);
+ va_end(ap);
+ }
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
- bl_list_count = blockcount;
- return returnCount; //[Skotlex]
+ bl_list_count = blockcount;
+ return returnCount; //[Skotlex]
}
/*==========================================
- * range = map m (x0,y0)-(x1,y1)
- * Apply *func with ... arguments for the range.
- * @type = BL_PC/BL_MOB etc..
- *------------------------------------------*/
+* range = map m (x0,y0)-(x1,y1)
+* Apply *func with ... arguments for the range.
+* @type = BL_PC/BL_MOB etc..
+*------------------------------------------*/
int map_foreachinarea(int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int type, ...)
{
int bx, by;
@@ -709,7 +676,7 @@ int map_foreachinarea(int (*func)(struct block_list*,va_list), int16 m, int16 x0
if( bl_list_count >= BL_LIST_MAX )
ShowWarning("map_foreachinarea: block count too many!\n");
- map_freeblock_lock();
+ iMap->freeblock_lock();
for( i = blockcount; i < bl_list_count; i++ )
if( bl_list[ i ]->prev ) { //func() may delete this bl_list[] slot, checking for prev ensures it wasnt queued for deletion.
@@ -718,14 +685,14 @@ int map_foreachinarea(int (*func)(struct block_list*,va_list), int16 m, int16 x0
va_end(ap);
}
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
- bl_list_count = blockcount;
- return returnCount; //[Skotlex]
+ bl_list_count = blockcount;
+ return returnCount; //[Skotlex]
}
/*==========================================
- * Adapted from forcountinarea for an easier invocation. [pakpil]
- *------------------------------------------*/
+* Adapted from forcountinarea for an easier invocation. [pakpil]
+*------------------------------------------*/
int map_forcountinrange(int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int count, int type, ...)
{
int bx, by, m;
@@ -750,43 +717,43 @@ int map_forcountinrange(int (*func)(struct block_list*,va_list), struct block_li
#ifdef CIRCULAR_AREA
&& check_distance_bl(center, bl, range)
#endif
- && bl_list_count < BL_LIST_MAX )
+ && bl_list_count < BL_LIST_MAX )
bl_list[ bl_list_count++ ] = bl;
}
}
}
- if( type&BL_MOB )
- for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
- for( bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++ ){
- for( bl = map[ m ].block_mob[ bx + by * map[ m ].bxs ]; bl != NULL; bl = bl->next ) {
- if( bl->x >= x0 && bl->x <= x1 && bl->y >= y0 && bl->y <= y1
+ if( type&BL_MOB )
+ for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
+ for( bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++ ){
+ for( bl = map[ m ].block_mob[ bx + by * map[ m ].bxs ]; bl != NULL; bl = bl->next ) {
+ if( bl->x >= x0 && bl->x <= x1 && bl->y >= y0 && bl->y <= y1
#ifdef CIRCULAR_AREA
- && check_distance_bl(center, bl, range)
+ && check_distance_bl(center, bl, range)
#endif
- && bl_list_count < BL_LIST_MAX )
- bl_list[ bl_list_count++ ] = bl;
+ && bl_list_count < BL_LIST_MAX )
+ bl_list[ bl_list_count++ ] = bl;
+ }
}
}
- }
- if( bl_list_count >= BL_LIST_MAX )
- ShowWarning("map_forcountinrange: block count too many!\n");
+ if( bl_list_count >= BL_LIST_MAX )
+ ShowWarning("map_forcountinrange: block count too many!\n");
- map_freeblock_lock();
+ iMap->freeblock_lock();
- for( i = blockcount; i < bl_list_count; i++ )
- if( bl_list[ i ]->prev ) { //func() may delete this bl_list[] slot, checking for prev ensures it wasnt queued for deletion.
- va_start(ap, type);
- returnCount += func(bl_list[ i ], ap);
- va_end(ap);
- if( count && returnCount >= count )
- break;
- }
+ for( i = blockcount; i < bl_list_count; i++ )
+ if( bl_list[ i ]->prev ) { //func() may delete this bl_list[] slot, checking for prev ensures it wasnt queued for deletion.
+ va_start(ap, type);
+ returnCount += func(bl_list[ i ], ap);
+ va_end(ap);
+ if( count && returnCount >= count )
+ break;
+ }
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
- bl_list_count = blockcount;
- return returnCount; //[Skotlex]
+ bl_list_count = blockcount;
+ return returnCount; //[Skotlex]
}
int map_forcountinarea(int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int count, int type, ...)
{
@@ -826,7 +793,7 @@ int map_forcountinarea(int (*func)(struct block_list*,va_list), int16 m, int16 x
if( bl_list_count >= BL_LIST_MAX )
ShowWarning("map_foreachinarea: block count too many!\n");
- map_freeblock_lock();
+ iMap->freeblock_lock();
for( i = blockcount; i < bl_list_count; i++ )
if(bl_list[ i ]->prev) { //func() may delete this bl_list[] slot, checking for prev ensures it wasnt queued for deletion.
@@ -837,17 +804,17 @@ int map_forcountinarea(int (*func)(struct block_list*,va_list), int16 m, int16 x
break;
}
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
- bl_list_count = blockcount;
- return returnCount; //[Skotlex]
+ bl_list_count = blockcount;
+ return returnCount; //[Skotlex]
}
/*==========================================
- * For what I get
- * Move bl and do func* with va_list while moving.
- * Mouvement is set by dx dy wich are distance in x and y
- *------------------------------------------*/
+* For what I get
+* Move bl and do func* with va_list while moving.
+* Mouvement is set by dx dy wich are distance in x and y
+*------------------------------------------*/
int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int16 dx, int16 dy, int type, ...)
{
int bx, by, m;
@@ -927,11 +894,11 @@ int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_
bl->x >= x0 && bl->x <= x1 &&
bl->y >= y0 && bl->y <= y1 &&
bl_list_count < BL_LIST_MAX )
- if( ( dx > 0 && bl->x < x0 + dx) ||
- ( dx < 0 && bl->x > x1 + dx) ||
- ( dy > 0 && bl->y < y0 + dy) ||
- ( dy < 0 && bl->y > y1 + dy) )
- bl_list[ bl_list_count++ ] = bl;
+ if( ( dx > 0 && bl->x < x0 + dx) ||
+ ( dx < 0 && bl->x > x1 + dx) ||
+ ( dy > 0 && bl->y < y0 + dy) ||
+ ( dy < 0 && bl->y > y1 + dy) )
+ bl_list[ bl_list_count++ ] = bl;
}
}
if ( type&BL_MOB ) {
@@ -939,11 +906,11 @@ int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_
if( bl->x >= x0 && bl->x <= x1 &&
bl->y >= y0 && bl->y <= y1 &&
bl_list_count < BL_LIST_MAX)
- if( ( dx > 0 && bl->x < x0 + dx) ||
- ( dx < 0 && bl->x > x1 + dx) ||
- ( dy > 0 && bl->y < y0 + dy) ||
- ( dy < 0 && bl->y > y1 + dy) )
- bl_list[ bl_list_count++ ] = bl;
+ if( ( dx > 0 && bl->x < x0 + dx) ||
+ ( dx < 0 && bl->x > x1 + dx) ||
+ ( dy > 0 && bl->y < y0 + dy) ||
+ ( dy < 0 && bl->y > y1 + dy) )
+ bl_list[ bl_list_count++ ] = bl;
}
}
}
@@ -954,7 +921,7 @@ int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_
if( bl_list_count >= BL_LIST_MAX )
ShowWarning("map_foreachinmovearea: block count too many!\n");
- map_freeblock_lock(); // Prohibit the release from memory
+ iMap->freeblock_lock(); // Prohibit the release from memory
for( i = blockcount; i < bl_list_count; i++ )
if( bl_list[ i ]->prev ) { //func() may delete this bl_list[] slot, checking for prev ensures it wasnt queued for deletion.
@@ -963,10 +930,10 @@ int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_
va_end(ap);
}
- map_freeblock_unlock(); // Allow Free
+ iMap->freeblock_unlock(); // Allow Free
- bl_list_count = blockcount;
- return returnCount;
+ bl_list_count = blockcount;
+ return returnCount;
}
// -- moonsoul (added map_foreachincell which is a rework of map_foreachinarea but
@@ -998,7 +965,7 @@ int map_foreachincell(int (*func)(struct block_list*,va_list), int16 m, int16 x,
if( bl_list_count >= BL_LIST_MAX )
ShowWarning("map_foreachincell: block count too many!\n");
- map_freeblock_lock();
+ iMap->freeblock_lock();
for( i = blockcount; i < bl_list_count; i++ )
if( bl_list[ i ]->prev ) { //func() may delete this bl_list[] slot, checking for prev ensures it wasnt queued for deletion.
@@ -1007,10 +974,10 @@ int map_foreachincell(int (*func)(struct block_list*,va_list), int16 m, int16 x,
va_end(ap);
}
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
- bl_list_count = blockcount;
- return returnCount;
+ bl_list_count = blockcount;
+ return returnCount;
}
/*============================================================
@@ -1019,38 +986,38 @@ int map_foreachincell(int (*func)(struct block_list*,va_list), int16 m, int16 x,
int map_foreachinpath(int (*func)(struct block_list*,va_list),int16 m,int16 x0,int16 y0,int16 x1,int16 y1,int16 range,int length, int type,...)
{
int returnCount = 0; //total sum of returned values of func() [Skotlex]
-//////////////////////////////////////////////////////////////
-//
-// sharp shooting 3 [Skotlex]
-//
-//////////////////////////////////////////////////////////////
-// problem:
-// Same as Sharp Shooting 1. Hits all targets within range of
-// the line.
-// (t1,t2 t3 and t4 get hit)
-//
-// target 1
-// x t4
-// t2
-// t3 x
-// x
-// S
-//////////////////////////////////////////////////////////////
-// Methodology:
-// My trigonometrics and math are a little rusty... so the approach I am writing
-// here is basicly do a double for to check for all targets in the square that
-// contains the initial and final positions (area range increased to match the
-// radius given), then for each object to test, calculate the distance to the
-// path and include it if the range fits and the target is in the line (0<k<1,
-// as they call it).
-// The implementation I took as reference is found at
-// http://astronomy.swin.edu.au/~pbourke/geometry/pointline/
-// (they have a link to a C implementation, too)
-// This approach is a lot like #2 commented on this function, which I have no
-// idea why it was commented. I won't use doubles/floats, but pure int math for
-// speed purposes. The range considered is always the same no matter how
-// close/far the target is because that's how SharpShooting works currently in
-// kRO.
+ //////////////////////////////////////////////////////////////
+ //
+ // sharp shooting 3 [Skotlex]
+ //
+ //////////////////////////////////////////////////////////////
+ // problem:
+ // Same as Sharp Shooting 1. Hits all targets within range of
+ // the line.
+ // (t1,t2 t3 and t4 get hit)
+ //
+ // target 1
+ // x t4
+ // t2
+ // t3 x
+ // x
+ // S
+ //////////////////////////////////////////////////////////////
+ // Methodology:
+ // My trigonometrics and math are a little rusty... so the approach I am writing
+ // here is basicly do a double for to check for all targets in the square that
+ // contains the initial and final positions (area range increased to match the
+ // radius given), then for each object to test, calculate the distance to the
+ // path and include it if the range fits and the target is in the line (0<k<1,
+ // as they call it).
+ // The implementation I took as reference is found at
+ // http://astronomy.swin.edu.au/~pbourke/geometry/pointline/
+ // (they have a link to a C implementation, too)
+ // This approach is a lot like #2 commented on this function, which I have no
+ // idea why it was commented. I won't use doubles/floats, but pure int math for
+ // speed purposes. The range considered is always the same no matter how
+ // close/far the target is because that's how SharpShooting works currently in
+ // kRO.
//Generic map_foreach* variables.
int i, blockcount = bl_list_count;
@@ -1063,7 +1030,7 @@ int map_foreachinpath(int (*func)(struct block_list*,va_list),int16 m,int16 x0,i
va_list ap;
//Avoid needless calculations by not getting the sqrt right away.
- #define MAGNITUDE2(x0, y0, x1, y1) ( ( ( x1 ) - ( x0 ) ) * ( ( x1 ) - ( x0 ) ) + ( ( y1 ) - ( y0 ) ) * ( ( y1 ) - ( y0 ) ) )
+#define MAGNITUDE2(x0, y0, x1, y1) ( ( ( x1 ) - ( x0 ) ) * ( ( x1 ) - ( x0 ) ) + ( ( y1 ) - ( y0 ) ) * ( ( y1 ) - ( y0 ) ) )
if ( m < 0 )
return 0;
@@ -1142,60 +1109,59 @@ int map_foreachinpath(int (*func)(struct block_list*,va_list),int16 m,int16 x0,i
}
}
}
- if( type&BL_MOB )
- for( by = my0 / BLOCK_SIZE; by <= my1 / BLOCK_SIZE; by++ ) {
- for( bx = mx0 / BLOCK_SIZE; bx <= mx1 / BLOCK_SIZE; bx++ ) {
- for( bl = map[ m ].block_mob[ bx + by * map[ m ].bxs ]; bl != NULL; bl = bl->next ) {
- if( bl->prev && bl_list_count < BL_LIST_MAX ) {
- xi = bl->x;
- yi = bl->y;
- k = ( xi - x0 ) * ( x1 - x0 ) + ( yi - y0 ) * ( y1 - y0 );
+ if( type&BL_MOB )
+ for( by = my0 / BLOCK_SIZE; by <= my1 / BLOCK_SIZE; by++ ) {
+ for( bx = mx0 / BLOCK_SIZE; bx <= mx1 / BLOCK_SIZE; bx++ ) {
+ for( bl = map[ m ].block_mob[ bx + by * map[ m ].bxs ]; bl != NULL; bl = bl->next ) {
+ if( bl->prev && bl_list_count < BL_LIST_MAX ) {
+ xi = bl->x;
+ yi = bl->y;
+ k = ( xi - x0 ) * ( x1 - x0 ) + ( yi - y0 ) * ( y1 - y0 );
- if ( k < 0 || k > len_limit )
- continue;
+ if ( k < 0 || k > len_limit )
+ continue;
- if ( k > magnitude2 && !path_search_long(NULL, m, x0, y0, xi, yi, CELL_CHKWALL) )
- continue; //Targets beyond the initial ending point need the wall check.
+ if ( k > magnitude2 && !path_search_long(NULL, m, x0, y0, xi, yi, CELL_CHKWALL) )
+ continue; //Targets beyond the initial ending point need the wall check.
- k = ( k << 4 ) / magnitude2; //k will be between 1~16 instead of 0~1
- xi <<= 4;
- yi <<= 4;
- xu = ( x0 << 4 ) + k * ( x1 - x0 );
- yu = ( y0 << 4 ) + k * ( y1 - y0 );
- k = MAGNITUDE2(xi, yi, xu, yu);
+ k = ( k << 4 ) / magnitude2; //k will be between 1~16 instead of 0~1
+ xi <<= 4;
+ yi <<= 4;
+ xu = ( x0 << 4 ) + k * ( x1 - x0 );
+ yu = ( y0 << 4 ) + k * ( y1 - y0 );
+ k = MAGNITUDE2(xi, yi, xu, yu);
- //If all dot coordinates were <<4 the square of the magnitude is <<8
- if ( k > range )
- continue;
+ //If all dot coordinates were <<4 the square of the magnitude is <<8
+ if ( k > range )
+ continue;
- bl_list[ bl_list_count++ ] = bl;
+ bl_list[ bl_list_count++ ] = bl;
+ }
}
}
}
- }
- if( bl_list_count >= BL_LIST_MAX )
- ShowWarning("map_foreachinpath: block count too many!\n");
+ if( bl_list_count >= BL_LIST_MAX )
+ ShowWarning("map_foreachinpath: block count too many!\n");
- map_freeblock_lock();
+ iMap->freeblock_lock();
- for( i = blockcount; i < bl_list_count; i++ )
- if( bl_list[ i ]->prev ) { //func() may delete this bl_list[] slot, checking for prev ensures it wasnt queued for deletion.
- va_start(ap, type);
- returnCount += func(bl_list[ i ], ap);
- va_end(ap);
- }
+ for( i = blockcount; i < bl_list_count; i++ )
+ if( bl_list[ i ]->prev ) { //func() may delete this bl_list[] slot, checking for prev ensures it wasnt queued for deletion.
+ va_start(ap, type);
+ returnCount += func(bl_list[ i ], ap);
+ va_end(ap);
+ }
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
- bl_list_count = blockcount;
- return returnCount; //[Skotlex]
+ bl_list_count = blockcount;
+ return returnCount; //[Skotlex]
}
// Copy of map_foreachincell, but applied to the whole map. [Skotlex]
-int map_foreachinmap(int (*func)(struct block_list*,va_list), int16 m, int type,...)
-{
+int map_foreachinmap(int (*func)(struct block_list*,va_list), int16 m, int type,...) {
int b, bsize;
int returnCount = 0; //total sum of returned values of func() [Skotlex]
struct block_list *bl;
@@ -1219,7 +1185,7 @@ int map_foreachinmap(int (*func)(struct block_list*,va_list), int16 m, int type,
if( bl_list_count >= BL_LIST_MAX )
ShowWarning("map_foreachinmap: block count too many!\n");
- map_freeblock_lock();
+ iMap->freeblock_lock();
for( i = blockcount; i < bl_list_count ; i++ )
if( bl_list[ i ]->prev ) { //func() may delete this bl_list[] slot, checking for prev ensures it wasnt queued for deletion.
@@ -1228,7 +1194,53 @@ int map_foreachinmap(int (*func)(struct block_list*,va_list), int16 m, int type,
va_end(ap);
}
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
+
+ bl_list_count = blockcount;
+ return returnCount;
+}
+// Copy of map_foreachinmap, but applied to all maps in a instance id. [Ind/Hercules]
+int map_foreachininstance(int (*func)(struct block_list*,va_list), int16 instance_id, int type,...) {
+ int b, bsize;
+ int returnCount = 0; //total sum of returned values of func() [Skotlex]
+ struct block_list *bl;
+ int blockcount = bl_list_count, i, j;
+ int16 m;
+ va_list ap;
+
+ for( j = 0; j < instances[instance_id].num_map; j++ ) {
+
+ m = instances[instance_id].map[j];
+
+ bsize = map[ m ].bxs * map[ m ].bys;
+
+ if( type&~BL_MOB )
+ for( b = 0; b < bsize; b++ )
+ for( bl = map[ m ].block[ b ]; bl != NULL; bl = bl->next )
+ if( bl->type&type && bl_list_count < BL_LIST_MAX )
+ bl_list[ bl_list_count++ ] = bl;
+
+ if( type&BL_MOB )
+ for( b = 0; b < bsize; b++ )
+ for( bl = map[ m ].block_mob[ b ]; bl != NULL; bl = bl->next )
+ if( bl_list_count < BL_LIST_MAX )
+ bl_list[ bl_list_count++ ] = bl;
+
+ if( bl_list_count >= BL_LIST_MAX )
+ ShowWarning("map_foreachininstance: block count too many!\n");
+
+ iMap->freeblock_lock();
+
+ for( i = blockcount; i < bl_list_count ; i++ )
+ if( bl_list[ i ]->prev ) { //func() may delete this bl_list[] slot, checking for prev ensures it wasnt queued for deletion.
+ va_start(ap, type);
+ returnCount += func(bl_list[ i ], ap);
+ va_end(ap);
+ }
+
+ iMap->freeblock_unlock();
+
+ }
bl_list_count = blockcount;
return returnCount;
@@ -1267,9 +1279,9 @@ int map_get_new_object_id(void)
}
/*==========================================
- * Timered function to clear the floor (remove remaining item)
- * Called each flooritem_lifetime ms
- *------------------------------------------*/
+* Timered function to clear the floor (remove remaining item)
+* Called each flooritem_lifetime ms
+*------------------------------------------*/
int map_clearflooritem_timer(int tid, unsigned int tick, int id, intptr_t data)
{
struct flooritem_data* fitem = (struct flooritem_data*)idb_get(id_db, id);
@@ -1284,32 +1296,32 @@ int map_clearflooritem_timer(int tid, unsigned int tick, int id, intptr_t data)
intif_delete_petdata(MakeDWord(fitem->item_data.card[1], fitem->item_data.card[2]));
clif->clearflooritem(fitem, 0);
- map_deliddb(&fitem->bl);
- map_delblock(&fitem->bl);
- map_freeblock(&fitem->bl);
+ iMap->deliddb(&fitem->bl);
+ iMap->delblock(&fitem->bl);
+ iMap->freeblock(&fitem->bl);
return 0;
}
/*
- * clears a single bl item out of the bazooonga.
- */
+* clears a single bl item out of the bazooonga.
+*/
void map_clearflooritem(struct block_list *bl) {
struct flooritem_data* fitem = (struct flooritem_data*)bl;
if( fitem->cleartimer )
- delete_timer(fitem->cleartimer,map_clearflooritem_timer);
+ iTimer->delete_timer(fitem->cleartimer,iMap->clearflooritem_timer);
clif->clearflooritem(fitem, 0);
- map_deliddb(&fitem->bl);
- map_delblock(&fitem->bl);
- map_freeblock(&fitem->bl);
+ iMap->deliddb(&fitem->bl);
+ iMap->delblock(&fitem->bl);
+ iMap->freeblock(&fitem->bl);
}
/*==========================================
- * (m,x,y) locates a random available free cell around the given coordinates
- * to place an BL_ITEM object. Scan area is 9x9, returns 1 on success.
- * x and y are modified with the target cell when successful.
- *------------------------------------------*/
+* (m,x,y) locates a random available free cell around the given coordinates
+* to place an BL_ITEM object. Scan area is 9x9, returns 1 on success.
+* x and y are modified with the target cell when successful.
+*------------------------------------------*/
int map_searchrandfreecell(int16 m,int16 *x,int16 *y,int stack) {
int free_cell,i,j;
int free_cells[9][2];
@@ -1320,10 +1332,10 @@ int map_searchrandfreecell(int16 m,int16 *x,int16 *y,int stack) {
for(j=-1;j<=1;j++){
if(j+*x<0 || j+*x>=map[m].xs)
continue;
- if(map_getcell(m,j+*x,i+*y,CELL_CHKNOPASS) && !map_getcell(m,j+*x,i+*y,CELL_CHKICEWALL))
+ if(iMap->getcell(m,j+*x,i+*y,CELL_CHKNOPASS) && !iMap->getcell(m,j+*x,i+*y,CELL_CHKICEWALL))
continue;
//Avoid item stacking to prevent against exploits. [Skotlex]
- if(stack && map_count_oncell(m,j+*x,i+*y, BL_ITEM) > stack)
+ if(stack && iMap->count_oncell(m,j+*x,i+*y, BL_ITEM) > stack)
continue;
free_cells[free_cell][0] = j+*x;
free_cells[free_cell++][1] = i+*y;
@@ -1344,17 +1356,17 @@ static int map_count_sub(struct block_list *bl,va_list ap)
}
/*==========================================
- * Locates a random spare cell around the object given, using range as max
- * distance from that spot. Used for warping functions. Use range < 0 for
- * whole map range.
- * Returns 1 on success. when it fails and src is available, x/y are set to src's
- * src can be null as long as flag&1
- * when ~flag&1, m is not needed.
- * Flag values:
- * &1 = random cell must be around given m,x,y, not around src
- * &2 = the target should be able to walk to the target tile.
- * &4 = there shouldn't be any players around the target tile (use the no_spawn_on_player setting)
- *------------------------------------------*/
+* Locates a random spare cell around the object given, using range as max
+* distance from that spot. Used for warping functions. Use range < 0 for
+* whole map range.
+* Returns 1 on success. when it fails and src is available, x/y are set to src's
+* src can be null as long as flag&1
+* when ~flag&1, m is not needed.
+* Flag values:
+* &1 = random cell must be around given m,x,y, not around src
+* &2 = the target should be able to walk to the target tile.
+* &4 = there shouldn't be any players around the target tile (use the no_spawn_on_player setting)
+*------------------------------------------*/
int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int16 rx, int16 ry, int flag)
{
int tries, spawn=0;
@@ -1380,7 +1392,7 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1
//No range? Return the target cell then....
*x = bx;
*y = by;
- return map_getcell(m,*x,*y,CELL_CHKREACH);
+ return iMap->getcell(m,*x,*y,CELL_CHKREACH);
}
if (rx >= 0 && ry >= 0) {
@@ -1398,7 +1410,7 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1
if (*x == bx && *y == by)
continue; //Avoid picking the same target tile.
- if (map_getcell(m,*x,*y,CELL_CHKREACH))
+ if (iMap->getcell(m,*x,*y,CELL_CHKREACH))
{
if(flag&2 && !unit_can_reach_pos(src, *x, *y, 1))
continue;
@@ -1406,10 +1418,10 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1
if (spawn >= 100) return 0; //Limit of retries reached.
if (spawn++ < battle_config.no_spawn_on_player &&
map_foreachinarea(map_count_sub, m,
- *x-AREA_SIZE, *y-AREA_SIZE,
- *x+AREA_SIZE, *y+AREA_SIZE, BL_PC)
- )
- continue;
+ *x-AREA_SIZE, *y-AREA_SIZE,
+ *x+AREA_SIZE, *y+AREA_SIZE, BL_PC)
+ )
+ continue;
}
return 1;
}
@@ -1420,14 +1432,14 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1
}
/*==========================================
- * Add an item to location (m,x,y)
- * Parameters
- * @item_data item attributes
- * @amount quantity
- * @m, @x, @y mapid,x,y
- * @first_charid, @second_charid, @third_charid, looting priority
- * @flag: &1 MVP item. &2 do stacking check.
- *------------------------------------------*/
+* Add an item to location (m,x,y)
+* Parameters
+* @item_data item attributes
+* @amount quantity
+* @m, @x, @y mapid,x,y
+* @first_charid, @second_charid, @third_charid, looting priority
+* @flag: &1 MVP item. &2 do stacking check.
+*------------------------------------------*/
int map_addflooritem(struct item *item_data,int amount,int16 m,int16 x,int16 y,int first_charid,int second_charid,int third_charid,int flags)
{
int r;
@@ -1445,14 +1457,14 @@ int map_addflooritem(struct item *item_data,int amount,int16 m,int16 x,int16 y,i
fitem->bl.m=m;
fitem->bl.x=x;
fitem->bl.y=y;
- fitem->bl.id = map_get_new_object_id();
+ fitem->bl.id = iMap->get_new_object_id();
if(fitem->bl.id==0){
aFree(fitem);
return 0;
}
fitem->first_get_charid = first_charid;
- fitem->first_get_tick = gettick() + (flags&1 ? battle_config.mvp_item_first_get_time : battle_config.item_first_get_time);
+ fitem->first_get_tick = iTimer->gettick() + (flags&1 ? battle_config.mvp_item_first_get_time : battle_config.item_first_get_time);
fitem->second_get_charid = second_charid;
fitem->second_get_tick = fitem->first_get_tick + (flags&1 ? battle_config.mvp_item_second_get_time : battle_config.item_second_get_time);
fitem->third_get_charid = third_charid;
@@ -1462,18 +1474,18 @@ int map_addflooritem(struct item *item_data,int amount,int16 m,int16 x,int16 y,i
fitem->item_data.amount=amount;
fitem->subx=(r&3)*3+3;
fitem->suby=((r>>2)&3)*3+3;
- fitem->cleartimer=add_timer(gettick()+battle_config.flooritem_lifetime,map_clearflooritem_timer,fitem->bl.id,0);
+ fitem->cleartimer=iTimer->add_timer(iTimer->gettick()+battle_config.flooritem_lifetime,iMap->clearflooritem_timer,fitem->bl.id,0);
- map_addiddb(&fitem->bl);
- map_addblock(&fitem->bl);
+ iMap->addiddb(&fitem->bl);
+ iMap->addblock(&fitem->bl);
clif->dropflooritem(fitem);
return fitem->bl.id;
}
/**
- * @see DBCreateData
- */
+* @see DBCreateData
+*/
static DBData create_charid2nick(DBKey key, va_list args)
{
struct charid2nick *p;
@@ -1489,7 +1501,7 @@ void map_addnickdb(int charid, const char* nick)
struct charid_request* req;
struct map_session_data* sd;
- if( map_charid2sd(charid) )
+ if( iMap->charid2sd(charid) )
return;// already online
p = idb_ensure(nick_db, charid, create_charid2nick);
@@ -1498,7 +1510,7 @@ void map_addnickdb(int charid, const char* nick)
while( p->requests ) {
req = p->requests;
p->requests = req->next;
- sd = map_charid2sd(req->charid);
+ sd = iMap->charid2sd(req->charid);
if( sd )
clif->solved_charname(sd->fd, charid, p->nick);
aFree(req);
@@ -1520,7 +1532,7 @@ void map_delnickdb(int charid, const char* name)
while( p->requests ) {
req = p->requests;
p->requests = req->next;
- sd = map_charid2sd(req->charid);
+ sd = iMap->charid2sd(req->charid);
if( sd )
clif->solved_charname(sd->fd, charid, name);
aFree(req);
@@ -1539,7 +1551,7 @@ void map_reqnickdb(struct map_session_data * sd, int charid)
nullpo_retv(sd);
- tsd = map_charid2sd(charid);
+ tsd = iMap->charid2sd(charid);
if( tsd ) {
clif->solved_charname(sd->fd, charid, tsd->status.name);
return;
@@ -1558,8 +1570,8 @@ void map_reqnickdb(struct map_session_data * sd, int charid)
}
/*==========================================
- * add bl to id_db
- *------------------------------------------*/
+* add bl to id_db
+*------------------------------------------*/
void map_addiddb(struct block_list *bl)
{
nullpo_retv(bl);
@@ -1586,8 +1598,8 @@ void map_addiddb(struct block_list *bl)
}
/*==========================================
- * remove bl from id_db
- *------------------------------------------*/
+* remove bl from id_db
+*------------------------------------------*/
void map_deliddb(struct block_list *bl)
{
nullpo_retv(bl);
@@ -1611,8 +1623,8 @@ void map_deliddb(struct block_list *bl)
}
/*==========================================
- * Standard call when a player connection is closed.
- *------------------------------------------*/
+* Standard call when a player connection is closed.
+*------------------------------------------*/
int map_quit(struct map_session_data *sd) {
int i;
@@ -1635,61 +1647,46 @@ int map_quit(struct map_session_data *sd) {
if( sd->bg_id )
bg_team_leave(sd,1);
- pc_itemcd_do(sd,false);
+ pc->itemcd_do(sd,false);
+
+ for( i = 0; i < sd->queues_count; i++ ) {
+ struct hQueue *queue;
+ if( (queue = script->queue(sd->queues[i])) && queue->onLogOut[0] != '\0' ) {
+ npc_event(sd, queue->onLogOut, 0);
+ }
+ }
+ /* two times, the npc event above may assign a new one or delete others */
+ for( i = 0; i < sd->queues_count; i++ ) {
+ script->queue_remove(sd->queues[i],sd->status.account_id);
+ }
npc_script_event(sd, NPCE_LOGOUT);
//Unit_free handles clearing the player related data,
- //map_quit handles extra specific data which is related to quitting normally
- //(changing map-servers invokes unit_free but bypasses map_quit)
+ //iMap->quit handles extra specific data which is related to quitting normally
+ //(changing map-servers invokes unit_free but bypasses iMap->quit)
if( sd->sc.count ) {
//Status that are not saved...
- status_change_end(&sd->bl, SC_BOSSMAPINFO, INVALID_TIMER);
- status_change_end(&sd->bl, SC_AUTOTRADE, INVALID_TIMER);
- status_change_end(&sd->bl, SC_SPURT, INVALID_TIMER);
- status_change_end(&sd->bl, SC_BERSERK, INVALID_TIMER);
- status_change_end(&sd->bl, SC__BLOODYLUST, INVALID_TIMER);
- status_change_end(&sd->bl, SC_TRICKDEAD, INVALID_TIMER);
- status_change_end(&sd->bl, SC_LEADERSHIP, INVALID_TIMER);
- status_change_end(&sd->bl, SC_GLORYWOUNDS, INVALID_TIMER);
- status_change_end(&sd->bl, SC_SOULCOLD, INVALID_TIMER);
- status_change_end(&sd->bl, SC_HAWKEYES, INVALID_TIMER);
- if(sd->sc.data[SC_ENDURE] && sd->sc.data[SC_ENDURE]->val4)
- status_change_end(&sd->bl, SC_ENDURE, INVALID_TIMER); //No need to save infinite endure.
- status_change_end(&sd->bl, SC_WEIGHT50, INVALID_TIMER);
- status_change_end(&sd->bl, SC_WEIGHT90, INVALID_TIMER);
- status_change_end(&sd->bl, SC_SATURDAYNIGHTFEVER, INVALID_TIMER);
- status_change_end(&sd->bl, SC_KYOUGAKU, INVALID_TIMER);
- if (battle_config.debuff_on_logout&1) {
- status_change_end(&sd->bl, SC_ORCISH, INVALID_TIMER);
- status_change_end(&sd->bl, SC_STRIPWEAPON, INVALID_TIMER);
- status_change_end(&sd->bl, SC_STRIPARMOR, INVALID_TIMER);
- status_change_end(&sd->bl, SC_STRIPSHIELD, INVALID_TIMER);
- status_change_end(&sd->bl, SC_STRIPHELM, INVALID_TIMER);
- status_change_end(&sd->bl, SC_EXTREMITYFIST, INVALID_TIMER);
- status_change_end(&sd->bl, SC_EXPLOSIONSPIRITS, INVALID_TIMER);
- if(sd->sc.data[SC_REGENERATION] && sd->sc.data[SC_REGENERATION]->val4)
- status_change_end(&sd->bl, SC_REGENERATION, INVALID_TIMER);
- //TO-DO Probably there are way more NPC_type negative status that are removed
- status_change_end(&sd->bl, SC_CHANGEUNDEAD, INVALID_TIMER);
- // Both these statuses are removed on logout. [L0ne_W0lf]
- status_change_end(&sd->bl, SC_SLOWCAST, INVALID_TIMER);
- status_change_end(&sd->bl, SC_CRITICALWOUND, INVALID_TIMER);
- }
- if (battle_config.debuff_on_logout&2) {
- status_change_end(&sd->bl, SC_MAXIMIZEPOWER, INVALID_TIMER);
- status_change_end(&sd->bl, SC_MAXOVERTHRUST, INVALID_TIMER);
- status_change_end(&sd->bl, SC_STEELBODY, INVALID_TIMER);
- status_change_end(&sd->bl, SC_PRESERVE, INVALID_TIMER);
- status_change_end(&sd->bl, SC_KAAHI, INVALID_TIMER);
- status_change_end(&sd->bl, SC_SPIRIT, INVALID_TIMER);
+ for(i=0; i < SC_MAX; i++){
+ if ( status_get_sc_type(i)&SC_NO_SAVE ){
+ if ( !sd->sc.data[i] )
+ continue;
+ switch( i ){
+ case SC_ENDURE:
+ case SC_GDSKILL_REGENERATION:
+ if( !sd->sc.data[i]->val4 )
+ break;
+ default:
+ status_change_end(&sd->bl, (sc_type)i, INVALID_TIMER);
+ }
+ }
}
}
for( i = 0; i < EQI_MAX; i++ ) {
if( sd->equip_index[ i ] >= 0 )
- if( !pc_isequip( sd , sd->equip_index[ i ] ) )
- pc_unequipitem( sd , sd->equip_index[ i ] , 2 );
+ if( !pc->isequip( sd , sd->equip_index[ i ] ) )
+ pc->unequipitem( sd , sd->equip_index[ i ] , 2 );
}
// Return loot to owner
@@ -1707,12 +1704,12 @@ int map_quit(struct map_session_data *sd) {
if( hChSys.local && map[sd->bl.m].channel && idb_exists(map[sd->bl.m].channel->users, sd->status.char_id) ) {
clif->chsys_left(map[sd->bl.m].channel,sd);
}
-
+
clif->chsys_quit(sd);
-
+
unit_remove_map_pc(sd,CLR_TELEPORT);
- if( map[sd->bl.m].instance_id ) { // Avoid map conflicts and warnings on next login
+ if( map[sd->bl.m].instance_id >= 0 ) { // Avoid map conflicts and warnings on next login
int16 m;
struct point *pt;
if( map[sd->bl.m].save.map )
@@ -1720,8 +1717,7 @@ int map_quit(struct map_session_data *sd) {
else
pt = &sd->status.save_point;
- if( (m=map_mapindex2mapid(pt->map)) >= 0 )
- {
+ if( (m=iMap->mapindex2mapid(pt->map)) >= 0 ) {
sd->bl.m = m;
sd->bl.x = pt->x;
sd->bl.y = pt->y;
@@ -1729,17 +1725,17 @@ int map_quit(struct map_session_data *sd) {
}
}
- party_booking_delete(sd); // Party Booking [Spiria]
- pc_makesavestatus(sd);
- pc_clean_skilltree(sd);
+ party->booking_delete(sd); // Party Booking [Spiria]
+ pc->makesavestatus(sd);
+ pc->clean_skilltree(sd);
chrif_save(sd,1);
unit_free_pc(sd);
return 0;
}
/*==========================================
- * Lookup, id to session (player,mob,npc,homon,merc..)
- *------------------------------------------*/
+* Lookup, id to session (player,mob,npc,homon,merc..)
+*------------------------------------------*/
struct map_session_data * map_id2sd(int id)
{
if (id <= 0) return NULL;
@@ -1754,28 +1750,28 @@ struct mob_data * map_id2md(int id)
struct npc_data * map_id2nd(int id)
{// just a id2bl lookup because there's no npc_db
- struct block_list* bl = map_id2bl(id);
+ struct block_list* bl = iMap->id2bl(id);
return BL_CAST(BL_NPC, bl);
}
struct homun_data* map_id2hd(int id)
{
- struct block_list* bl = map_id2bl(id);
+ struct block_list* bl = iMap->id2bl(id);
return BL_CAST(BL_HOM, bl);
}
struct mercenary_data* map_id2mc(int id)
{
- struct block_list* bl = map_id2bl(id);
+ struct block_list* bl = iMap->id2bl(id);
return BL_CAST(BL_MER, bl);
}
struct chat_data* map_id2cd(int id)
{
- struct block_list* bl = map_id2bl(id);
+ struct block_list* bl = iMap->id2bl(id);
return BL_CAST(BL_CHAT, bl);
}
@@ -1786,7 +1782,7 @@ const char* map_charid2nick(int charid)
struct charid2nick *p;
struct map_session_data* sd;
- sd = map_charid2sd(charid);
+ sd = iMap->charid2sd(charid);
if( sd )
return sd->status.name;// character is online, return it's name
@@ -1805,10 +1801,10 @@ struct map_session_data* map_charid2sd(int charid)
}
/*==========================================
- * Search session data from a nick name
- * (without sensitive case if necessary)
- * return map_session_data pointer or NULL
- *------------------------------------------*/
+* Search session data from a nick name
+* (without sensitive case if necessary)
+* return map_session_data pointer or NULL
+*------------------------------------------*/
struct map_session_data * map_nick2sd(const char *nick)
{
struct map_session_data* sd;
@@ -1856,22 +1852,22 @@ struct map_session_data * map_nick2sd(const char *nick)
}
/*==========================================
- * Looksup id_db DBMap and returns BL pointer of 'id' or NULL if not found
- *------------------------------------------*/
+* Looksup id_db DBMap and returns BL pointer of 'id' or NULL if not found
+*------------------------------------------*/
struct block_list * map_id2bl(int id) {
return (struct block_list*)idb_get(id_db,id);
}
/**
- * Same as map_id2bl except it only checks for its existence
- **/
+* Same as iMap->id2bl except it only checks for its existence
+**/
bool map_blid_exists( int id ) {
return (idb_exists(id_db,id));
}
/*==========================================
- * Convext Mirror
- *------------------------------------------*/
+* Convext Mirror
+*------------------------------------------*/
struct mob_data * map_getmob_boss(int16 m)
{
DBIterator* iter;
@@ -2027,7 +2023,7 @@ struct s_mapiterator
/// @return true if it matches
#define MAPIT_MATCHES(_mapit_,_bl_) \
( \
- ( (_bl_)->type & (_mapit_)->types /* type matches */ ) \
+ ( (_bl_)->type & (_mapit_)->types /* type matches */ ) \
)
/// Allocates a new iterator.
@@ -2158,13 +2154,12 @@ bool mapit_exists(struct s_mapiterator* mapit)
}
/*==========================================
- * Add npc-bl to id_db, basically register npc to map
- *------------------------------------------*/
-bool map_addnpc(int16 m,struct npc_data *nd)
-{
+* Add npc-bl to id_db, basically register npc to map
+*------------------------------------------*/
+bool map_addnpc(int16 m,struct npc_data *nd) {
nullpo_ret(nd);
- if( m < 0 || m >= map_num )
+ if( m < 0 || m >= iMap->map_num )
return false;
if( map[m].npc_num == MAX_NPC_PER_MAP )
@@ -2180,16 +2175,15 @@ bool map_addnpc(int16 m,struct npc_data *nd)
}
/*=========================================
- * Dynamic Mobs [Wizputer]
- *-----------------------------------------*/
+* Dynamic Mobs [Wizputer]
+*-----------------------------------------*/
// Stores the spawn data entry in the mob list.
// Returns the index of successful, or -1 if the list was full.
int map_addmobtolist(unsigned short m, struct spawn_data *spawn)
{
size_t i;
ARR_FIND( 0, MAX_MOB_LIST_PER_MAP, i, map[m].moblist[i] == NULL );
- if( i < MAX_MOB_LIST_PER_MAP )
- {
+ if( i < MAX_MOB_LIST_PER_MAP ) {
map[m].moblist[i] = spawn;
return i;
}
@@ -2201,7 +2195,7 @@ void map_spawnmobs(int16 m)
int i, k=0;
if (map[m].mob_delete_timer != INVALID_TIMER)
{ //Mobs have not been removed yet [Skotlex]
- delete_timer(map[m].mob_delete_timer, map_removemobs_timer);
+ iTimer->delete_timer(map[m].mob_delete_timer, iMap->removemobs_timer);
map[m].mob_delete_timer = INVALID_TIMER;
return;
}
@@ -2212,10 +2206,10 @@ void map_spawnmobs(int16 m)
npc_parse_mob2(map[m].moblist[i]);
}
- if (battle_config.etc_log && k > 0)
- {
- ShowStatus("Map %s: Spawned '"CL_WHITE"%d"CL_RESET"' mobs.\n",map[m].name, k);
- }
+ if (battle_config.etc_log && k > 0)
+ {
+ ShowStatus("Map %s: Spawned '"CL_WHITE"%d"CL_RESET"' mobs.\n",map[m].name, k);
+ }
}
int map_removemobs_sub(struct block_list *bl, va_list ap)
@@ -2250,13 +2244,11 @@ int map_removemobs_timer(int tid, unsigned int tick, int id, intptr_t data)
int count;
const int16 m = id;
- if (m < 0 || m >= MAX_MAP_PER_SERVER)
- { //Incorrect map id!
+ if (m < 0 || m >= iMap->map_num) { //Incorrect map id!
ShowError("map_removemobs_timer error: timer %d points to invalid map %d\n",tid, m);
return 0;
}
- if (map[m].mob_delete_timer != tid)
- { //Incorrect timer call!
+ if (map[m].mob_delete_timer != tid) { //Incorrect timer call!
ShowError("map_removemobs_timer mismatch: %d != %d (map %s)\n",map[m].mob_delete_timer, tid, map[m].name);
return 0;
}
@@ -2277,42 +2269,35 @@ void map_removemobs(int16 m)
if (map[m].mob_delete_timer != INVALID_TIMER) // should never happen
return; //Mobs are already scheduled for removal
- map[m].mob_delete_timer = add_timer(gettick()+battle_config.mob_remove_delay, map_removemobs_timer, m, 0);
+ map[m].mob_delete_timer = iTimer->add_timer(iTimer->gettick()+battle_config.mob_remove_delay, iMap->removemobs_timer, m, 0);
}
/*==========================================
- * Hookup, get map_id from map_name
- *------------------------------------------*/
-int16 map_mapname2mapid(const char* name)
-{
+* Hookup, get map_id from map_name
+*------------------------------------------*/
+int16 map_mapname2mapid(const char* name) {
unsigned short map_index;
map_index = mapindex_name2id(name);
if (!map_index)
return -1;
- return map_mapindex2mapid(map_index);
+ return iMap->mapindex2mapid(map_index);
}
/*==========================================
- * Returns the map of the given mapindex. [Skotlex]
- *------------------------------------------*/
-int16 map_mapindex2mapid(unsigned short mapindex)
-{
- struct map_data *md=NULL;
+* Returns the map of the given mapindex. [Skotlex]
+*------------------------------------------*/
+int16 map_mapindex2mapid(unsigned short mapindex) {
- if (!mapindex)
+ if (!mapindex || mapindex > MAX_MAPINDEX)
return -1;
- md = (struct map_data*)uidb_get(map_db,(unsigned int)mapindex);
- if(md==NULL || md->cell==NULL)
- return -1;
- return md->m;
+ return index2mapid[mapindex];
}
/*==========================================
- * Switching Ip, port ? (like changing map_server) get ip/port from map_name
- *------------------------------------------*/
-int map_mapname2ipport(unsigned short name, uint32* ip, uint16* port)
-{
+* Switching Ip, port ? (like changing map_server) get ip/port from map_name
+*------------------------------------------*/
+int map_mapname2ipport(unsigned short name, uint32* ip, uint16* port) {
struct map_data_other_server *mdos;
mdos = (struct map_data_other_server*)uidb_get(map_db,(unsigned int)name);
@@ -2324,28 +2309,28 @@ int map_mapname2ipport(unsigned short name, uint32* ip, uint16* port)
}
/*==========================================
- * Checks if both dirs point in the same direction.
- *------------------------------------------*/
+* Checks if both dirs point in the same direction.
+*------------------------------------------*/
int map_check_dir(int s_dir,int t_dir)
{
if(s_dir == t_dir)
return 0;
switch(s_dir) {
- case 0: if(t_dir == 7 || t_dir == 1 || t_dir == 0) return 0; break;
- case 1: if(t_dir == 0 || t_dir == 2 || t_dir == 1) return 0; break;
- case 2: if(t_dir == 1 || t_dir == 3 || t_dir == 2) return 0; break;
- case 3: if(t_dir == 2 || t_dir == 4 || t_dir == 3) return 0; break;
- case 4: if(t_dir == 3 || t_dir == 5 || t_dir == 4) return 0; break;
- case 5: if(t_dir == 4 || t_dir == 6 || t_dir == 5) return 0; break;
- case 6: if(t_dir == 5 || t_dir == 7 || t_dir == 6) return 0; break;
- case 7: if(t_dir == 6 || t_dir == 0 || t_dir == 7) return 0; break;
+ case 0: if(t_dir == 7 || t_dir == 1 || t_dir == 0) return 0; break;
+ case 1: if(t_dir == 0 || t_dir == 2 || t_dir == 1) return 0; break;
+ case 2: if(t_dir == 1 || t_dir == 3 || t_dir == 2) return 0; break;
+ case 3: if(t_dir == 2 || t_dir == 4 || t_dir == 3) return 0; break;
+ case 4: if(t_dir == 3 || t_dir == 5 || t_dir == 4) return 0; break;
+ case 5: if(t_dir == 4 || t_dir == 6 || t_dir == 5) return 0; break;
+ case 6: if(t_dir == 5 || t_dir == 7 || t_dir == 6) return 0; break;
+ case 7: if(t_dir == 6 || t_dir == 0 || t_dir == 7) return 0; break;
}
return 1;
}
/*==========================================
- * Returns the direction of the given cell, relative to 'src'
- *------------------------------------------*/
+* Returns the direction of the given cell, relative to 'src'
+*------------------------------------------*/
uint8 map_calc_dir(struct block_list* src, int16 x, int16 y)
{
uint8 dir = 0;
@@ -2389,9 +2374,9 @@ uint8 map_calc_dir(struct block_list* src, int16 x, int16 y)
}
/*==========================================
- * Randomizes target cell x,y to a random walkable cell that
- * has the same distance from object as given coordinates do. [Skotlex]
- *------------------------------------------*/
+* Randomizes target cell x,y to a random walkable cell that
+* has the same distance from object as given coordinates do. [Skotlex]
+*------------------------------------------*/
int map_random_dir(struct block_list *bl, int16 *x, int16 *y)
{
short xi = *x-bl->x;
@@ -2410,7 +2395,7 @@ int map_random_dir(struct block_list *bl, int16 *x, int16 *y)
segment = (short)sqrt((float)(dist2 - segment*segment)); //The complement of the previously picked segment
yi = bl->y + segment*diry[j];
} while (
- (map_getcell(bl->m,xi,yi,CELL_CHKNOPASS) || !path_search(NULL,bl->m,bl->x,bl->y,xi,yi,1,CELL_CHKNOREACH))
+ (iMap->getcell(bl->m,xi,yi,CELL_CHKNOPASS) || !path_search(NULL,bl->m,bl->x,bl->y,xi,yi,1,CELL_CHKNOREACH))
&& (++i)<100 );
if (i < 100) {
@@ -2428,23 +2413,22 @@ inline static struct mapcell map_gat2cell(int gat) {
memset(&cell,0,sizeof(struct mapcell));
switch( gat ) {
- case 0: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // walkable ground
- case 1: cell.walkable = 0; cell.shootable = 0; cell.water = 0; break; // non-walkable ground
- case 2: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ???
- case 3: cell.walkable = 1; cell.shootable = 1; cell.water = 1; break; // walkable water
- case 4: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ???
- case 5: cell.walkable = 0; cell.shootable = 1; cell.water = 0; break; // gap (snipable)
- case 6: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ???
- default:
- ShowWarning("map_gat2cell: unrecognized gat type '%d'\n", gat);
- break;
+ case 0: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // walkable ground
+ case 1: cell.walkable = 0; cell.shootable = 0; cell.water = 0; break; // non-walkable ground
+ case 2: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ???
+ case 3: cell.walkable = 1; cell.shootable = 1; cell.water = 1; break; // walkable water
+ case 4: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ???
+ case 5: cell.walkable = 0; cell.shootable = 1; cell.water = 0; break; // gap (snipable)
+ case 6: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ???
+ default:
+ ShowWarning("map_gat2cell: unrecognized gat type '%d'\n", gat);
+ break;
}
return cell;
}
-static int map_cell2gat(struct mapcell cell)
-{
+static int map_cell2gat(struct mapcell cell) {
if( cell.walkable == 1 && cell.shootable == 1 && cell.water == 0 ) return 0;
if( cell.walkable == 0 && cell.shootable == 0 && cell.water == 0 ) return 1;
if( cell.walkable == 1 && cell.shootable == 1 && cell.water == 1 ) return 3;
@@ -2453,17 +2437,42 @@ static int map_cell2gat(struct mapcell cell)
ShowWarning("map_cell2gat: cell has no matching gat type\n");
return 1; // default to 'wall'
}
+int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk);
+void map_setcell(int16 m, int16 x, int16 y, cell_t cell, bool flag);
+void map_cellfromcache(struct map_data *m) {
+ char decode_buffer[MAX_MAP_SIZE];
+ struct map_cache_map_info *info = NULL;
+
+ if( (info = (struct map_cache_map_info *)m->cellPos) ) {
+ unsigned long size, xy;
+ int i;
+
+ size = (unsigned long)info->xs*(unsigned long)info->ys;
+
+ // TO-DO: Maybe handle the scenario, if the decoded buffer isn't the same size as expected? [Shinryo]
+ decode_zip(decode_buffer, &size, m->cellPos+sizeof(struct map_cache_map_info), info->len);
+ CREATE(m->cell, struct mapcell, size);
+
+ for( xy = 0; xy < size; ++xy )
+ m->cell[xy] = map_gat2cell(decode_buffer[xy]);
+
+ m->getcellp = map_getcellp;
+ m->setcell = map_setcell;
+
+ for(i = 0; i < m->npc_num; i++) {
+ npc_setcells(m->npc[i]);
+ }
+ }
+}
/*==========================================
- * Confirm if celltype in (m,x,y) match the one given in cellchk
- *------------------------------------------*/
-int map_getcell(int16 m,int16 x,int16 y,cell_chk cellchk)
-{
- return (m < 0 || m >= MAX_MAP_PER_SERVER) ? 0 : map_getcellp(&map[m],x,y,cellchk);
+* Confirm if celltype in (m,x,y) match the one given in cellchk
+*------------------------------------------*/
+int map_getcell(int16 m,int16 x,int16 y,cell_chk cellchk) {
+ return (m < 0 || m >= iMap->map_num) ? 0 : map[m].getcellp(&map[m],x,y,cellchk);
}
-int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk)
-{
+int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk) {
struct mapcell cell;
nullpo_ret(m);
@@ -2474,104 +2483,118 @@ int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk)
cell = m->cell[x + y*m->xs];
- switch(cellchk)
- {
+ switch(cellchk) {
// gat type retrieval
- case CELL_GETTYPE:
- return map_cell2gat(cell);
+ case CELL_GETTYPE:
+ return map_cell2gat(cell);
// base gat type checks
- case CELL_CHKWALL:
- return (!cell.walkable && !cell.shootable);
+ case CELL_CHKWALL:
+ return (!cell.walkable && !cell.shootable);
- case CELL_CHKWATER:
- return (cell.water);
+ case CELL_CHKWATER:
+ return (cell.water);
- case CELL_CHKCLIFF:
- return (!cell.walkable && cell.shootable);
+ case CELL_CHKCLIFF:
+ return (!cell.walkable && cell.shootable);
// base cell type checks
- case CELL_CHKNPC:
- return (cell.npc);
- case CELL_CHKBASILICA:
- return (cell.basilica);
- case CELL_CHKLANDPROTECTOR:
- return (cell.landprotector);
- case CELL_CHKNOVENDING:
- return (cell.novending);
- case CELL_CHKNOCHAT:
- return (cell.nochat);
- case CELL_CHKMAELSTROM:
- return (cell.maelstrom);
- case CELL_CHKICEWALL:
- return (cell.icewall);
+ case CELL_CHKNPC:
+ return (cell.npc);
+ case CELL_CHKBASILICA:
+ return (cell.basilica);
+ case CELL_CHKLANDPROTECTOR:
+ return (cell.landprotector);
+ case CELL_CHKNOVENDING:
+ return (cell.novending);
+ case CELL_CHKNOCHAT:
+ return (cell.nochat);
+ case CELL_CHKMAELSTROM:
+ return (cell.maelstrom);
+ case CELL_CHKICEWALL:
+ return (cell.icewall);
// special checks
- case CELL_CHKPASS:
+ case CELL_CHKPASS:
#ifdef CELL_NOSTACK
- if (cell.cell_bl >= battle_config.cell_stack_limit) return 0;
+ if (cell.cell_bl >= battle_config.cell_stack_limit) return 0;
#endif
- case CELL_CHKREACH:
- return (cell.walkable);
+ case CELL_CHKREACH:
+ return (cell.walkable);
- case CELL_CHKNOPASS:
+ case CELL_CHKNOPASS:
#ifdef CELL_NOSTACK
- if (cell.cell_bl >= battle_config.cell_stack_limit) return 1;
+ if (cell.cell_bl >= battle_config.cell_stack_limit) return 1;
#endif
- case CELL_CHKNOREACH:
- return (!cell.walkable);
+ case CELL_CHKNOREACH:
+ return (!cell.walkable);
- case CELL_CHKSTACK:
+ case CELL_CHKSTACK:
#ifdef CELL_NOSTACK
- return (cell.cell_bl >= battle_config.cell_stack_limit);
+ return (cell.cell_bl >= battle_config.cell_stack_limit);
#else
- return 0;
+ return 0;
#endif
- default:
- return 0;
+ default:
+ return 0;
}
}
+/* [Ind/Hercules] */
+int map_sub_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk) {
+ iMap->cellfromcache(m);
+ m->getcellp = map_getcellp;
+ m->setcell = map_setcell;
+ return m->getcellp(m,x,y,cellchk);
+}
/*==========================================
- * Change the type/flags of a map cell
- * 'cell' - which flag to modify
- * 'flag' - true = on, false = off
- *------------------------------------------*/
-void map_setcell(int16 m, int16 x, int16 y, cell_t cell, bool flag)
-{
+* Change the type/flags of a map cell
+* 'cell' - which flag to modify
+* 'flag' - true = on, false = off
+*------------------------------------------*/
+void map_setcell(int16 m, int16 x, int16 y, cell_t cell, bool flag) {
int j;
- if( m < 0 || m >= map_num || x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys )
+ if( m < 0 || m >= iMap->map_num || x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys )
return;
j = x + y*map[m].xs;
switch( cell ) {
- case CELL_WALKABLE: map[m].cell[j].walkable = flag; break;
- case CELL_SHOOTABLE: map[m].cell[j].shootable = flag; break;
- case CELL_WATER: map[m].cell[j].water = flag; break;
-
- case CELL_NPC: map[m].cell[j].npc = flag; break;
- case CELL_BASILICA: map[m].cell[j].basilica = flag; break;
- case CELL_LANDPROTECTOR: map[m].cell[j].landprotector = flag; break;
- case CELL_NOVENDING: map[m].cell[j].novending = flag; break;
- case CELL_NOCHAT: map[m].cell[j].nochat = flag; break;
- case CELL_MAELSTROM: map[m].cell[j].maelstrom = flag; break;
- case CELL_ICEWALL: map[m].cell[j].icewall = flag; break;
- default:
- ShowWarning("map_setcell: invalid cell type '%d'\n", (int)cell);
- break;
+ case CELL_WALKABLE: map[m].cell[j].walkable = flag; break;
+ case CELL_SHOOTABLE: map[m].cell[j].shootable = flag; break;
+ case CELL_WATER: map[m].cell[j].water = flag; break;
+
+ case CELL_NPC: map[m].cell[j].npc = flag; break;
+ case CELL_BASILICA: map[m].cell[j].basilica = flag; break;
+ case CELL_LANDPROTECTOR: map[m].cell[j].landprotector = flag; break;
+ case CELL_NOVENDING: map[m].cell[j].novending = flag; break;
+ case CELL_NOCHAT: map[m].cell[j].nochat = flag; break;
+ case CELL_MAELSTROM: map[m].cell[j].maelstrom = flag; break;
+ case CELL_ICEWALL: map[m].cell[j].icewall = flag; break;
+ default:
+ ShowWarning("map_setcell: invalid cell type '%d'\n", (int)cell);
+ break;
}
}
+void map_sub_setcell(int16 m, int16 x, int16 y, cell_t cell, bool flag) {
+ if( m < 0 || m >= iMap->map_num || x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys )
+ return;
+
+ iMap->cellfromcache(&map[m]);
+ map[m].setcell = map_setcell;
+ map[m].getcellp = map_getcellp;
+ map[m].setcell(m,x,y,cell,flag);
+}
void map_setgatcell(int16 m, int16 x, int16 y, int gat)
{
int j;
struct mapcell cell;
- if( m < 0 || m >= map_num || x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys )
+ if( m < 0 || m >= iMap->map_num || x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys )
return;
j = x + y*map[m].xs;
@@ -2583,8 +2606,8 @@ void map_setgatcell(int16 m, int16 x, int16 y, int gat)
}
/*==========================================
- * Invisible Walls
- *------------------------------------------*/
+* Invisible Walls
+*------------------------------------------*/
static DBMap* iwall_db;
void map_iwall_nextxy(int16 x, int16 y, int8 dir, int pos, int16 *x1, int16 *y1)
@@ -2616,7 +2639,7 @@ bool map_iwall_set(int16 m, int16 x, int16 y, int size, int8 dir, bool shootable
if( (iwall = (struct iwall_data *)strdb_get(iwall_db, wall_name)) != NULL )
return false; // Already Exists
- if( map_getcell(m, x, y, CELL_CHKNOREACH) )
+ if( iMap->getcell(m, x, y, CELL_CHKNOREACH) )
return false; // Starting cell problem
CREATE(iwall, struct iwall_data, 1);
@@ -2632,13 +2655,13 @@ bool map_iwall_set(int16 m, int16 x, int16 y, int size, int8 dir, bool shootable
{
map_iwall_nextxy(x, y, dir, i, &x1, &y1);
- if( map_getcell(m, x1, y1, CELL_CHKNOREACH) )
+ if( iMap->getcell(m, x1, y1, CELL_CHKNOREACH) )
break; // Collision
- map_setcell(m, x1, y1, CELL_WALKABLE, false);
- map_setcell(m, x1, y1, CELL_SHOOTABLE, shootable);
+ map[m].setcell(m, x1, y1, CELL_WALKABLE, false);
+ map[m].setcell(m, x1, y1, CELL_SHOOTABLE, shootable);
- clif->changemapcell(0, m, x1, y1, map_getcell(m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP);
+ clif->changemapcell(0, m, x1, y1, iMap->getcell(m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP);
}
iwall->size = i;
@@ -2665,7 +2688,7 @@ void map_iwall_get(struct map_session_data *sd) {
for( i = 0; i < iwall->size; i++ ) {
map_iwall_nextxy(iwall->x, iwall->y, iwall->dir, i, &x1, &y1);
- clif->changemapcell(sd->fd, iwall->m, x1, y1, map_getcell(iwall->m, x1, y1, CELL_GETTYPE), SELF);
+ clif->changemapcell(sd->fd, iwall->m, x1, y1, iMap->getcell(iwall->m, x1, y1, CELL_GETTYPE), SELF);
}
}
dbi_destroy(iter);
@@ -2682,10 +2705,10 @@ void map_iwall_remove(const char *wall_name)
for( i = 0; i < iwall->size; i++ ) {
map_iwall_nextxy(iwall->x, iwall->y, iwall->dir, i, &x1, &y1);
- map_setcell(iwall->m, x1, y1, CELL_SHOOTABLE, true);
- map_setcell(iwall->m, x1, y1, CELL_WALKABLE, true);
+ map[iwall->m].setcell(iwall->m, x1, y1, CELL_SHOOTABLE, true);
+ map[iwall->m].setcell(iwall->m, x1, y1, CELL_WALKABLE, true);
- clif->changemapcell(0, iwall->m, x1, y1, map_getcell(iwall->m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP);
+ clif->changemapcell(0, iwall->m, x1, y1, iMap->getcell(iwall->m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP);
}
map[iwall->m].iwall_num--;
@@ -2693,8 +2716,8 @@ void map_iwall_remove(const char *wall_name)
}
/**
- * @see DBCreateData
- */
+* @see DBCreateData
+*/
static DBData create_map_data_other_server(DBKey key, va_list args)
{
struct map_data_other_server *mdos;
@@ -2706,8 +2729,8 @@ static DBData create_map_data_other_server(DBKey key, va_list args)
}
/*==========================================
- * Add mapindex to db of another map server
- *------------------------------------------*/
+* Add mapindex to db of another map server
+*------------------------------------------*/
int map_setipport(unsigned short mapindex, uint32 ip, uint16 port)
{
struct map_data_other_server *mdos;
@@ -2727,9 +2750,9 @@ int map_setipport(unsigned short mapindex, uint32 ip, uint16 port)
}
/**
- * Delete all the other maps server management
- * @see DBApply
- */
+* Delete all the other maps server management
+* @see DBApply
+*/
int map_eraseallipport_sub(DBKey key, DBData *data, va_list va)
{
struct map_data_other_server *mdos = DB->data2ptr(data);
@@ -2740,17 +2763,15 @@ int map_eraseallipport_sub(DBKey key, DBData *data, va_list va)
return 0;
}
-int map_eraseallipport(void)
-{
+int map_eraseallipport(void) {
map_db->foreach(map_db,map_eraseallipport_sub);
return 1;
}
/*==========================================
- * Delete mapindex from db of another map server
- *------------------------------------------*/
-int map_eraseipport(unsigned short mapindex, uint32 ip, uint16 port)
-{
+* Delete mapindex from db of another map server
+*------------------------------------------*/
+int map_eraseipport(unsigned short mapindex, uint32 ip, uint16 port) {
struct map_data_other_server *mdos;
mdos = (struct map_data_other_server*)uidb_get(map_db,(unsigned int)mapindex);
@@ -2766,8 +2787,8 @@ int map_eraseipport(unsigned short mapindex, uint32 ip, uint16 port)
}
/*==========================================
- * [Shinryo]: Init the mapcache
- *------------------------------------------*/
+* [Shinryo]: Init the mapcache
+*------------------------------------------*/
static char *map_init_mapcache(FILE *fp)
{
size_t size = 0;
@@ -2797,11 +2818,10 @@ static char *map_init_mapcache(FILE *fp)
}
/*==========================================
- * Map cache reading
- * [Shinryo]: Optimized some behaviour to speed this up
- *==========================================*/
-int map_readfromcache(struct map_data *m, char *buffer, char *decode_buffer)
-{
+* Map cache reading
+* [Shinryo]: Optimized some behaviour to speed this up
+*==========================================*/
+int map_readfromcache(struct map_data *m, char *buffer) {
int i;
struct map_cache_main_header *header = (struct map_cache_main_header *)buffer;
struct map_cache_map_info *info = NULL;
@@ -2818,7 +2838,7 @@ int map_readfromcache(struct map_data *m, char *buffer, char *decode_buffer)
}
if( info && i < header->map_count ) {
- unsigned long size, xy;
+ unsigned long size;
if( info->xs <= 0 || info->ys <= 0 )
return 0;// Invalid
@@ -2832,14 +2852,8 @@ int map_readfromcache(struct map_data *m, char *buffer, char *decode_buffer)
return 0; // Say not found to remove it from list.. [Shinryo]
}
- // TO-DO: Maybe handle the scenario, if the decoded buffer isn't the same size as expected? [Shinryo]
- decode_zip(decode_buffer, &size, p+sizeof(struct map_cache_map_info), info->len);
-
- CREATE(m->cell, struct mapcell, size);
-
-
- for( xy = 0; xy < size; ++xy )
- m->cell[xy] = map_gat2cell(decode_buffer[xy]);
+ m->cellPos = p;
+ m->cell = (struct mapcell *)0xdeadbeaf;
return 1;
}
@@ -2847,45 +2861,30 @@ int map_readfromcache(struct map_data *m, char *buffer, char *decode_buffer)
return 0; // Not found
}
-int map_addmap(char* mapname)
-{
- if( strcmpi(mapname,"clear")==0 )
- {
- map_num = 0;
- instance_start = 0;
- return 0;
- }
- if( map_num >= MAX_MAP_PER_SERVER - 1 )
- {
- ShowError("Could not add map '"CL_WHITE"%s"CL_RESET"', the limit of maps has been reached.\n",mapname);
- return 1;
- }
-
- mapindex_getmapname(mapname, map[map_num].name);
- map_num++;
+int map_addmap(char* mapname) {
+ map[iMap->map_num].instance_id = -1;
+ mapindex_getmapname(mapname, map[iMap->map_num++].name);
return 0;
}
-static void map_delmapid(int id)
-{
+static void map_delmapid(int id) {
ShowNotice("Removing map [ %s ] from maplist"CL_CLL"\n",map[id].name);
- memmove(map+id, map+id+1, sizeof(map[0])*(map_num-id-1));
- map_num--;
+ memmove(map+id, map+id+1, sizeof(map[0])*(iMap->map_num-id-1));
+ iMap->map_num--;
}
-int map_delmap(char* mapname)
-{
+int map_delmap(char* mapname) {
int i;
char map_name[MAP_NAME_LENGTH];
if (strcmpi(mapname, "all") == 0) {
- map_num = 0;
+ iMap->map_num = 0;
return 0;
}
mapindex_getmapname(mapname, map_name);
- for(i = 0; i < map_num; i++) {
+ for(i = 0; i < iMap->map_num; i++) {
if (strcmp(map[i].name, map_name) == 0) {
map_delmapid(i);
return 1;
@@ -2896,7 +2895,7 @@ int map_delmap(char* mapname)
void map_zone_db_clear(void) {
struct map_zone_data *zone;
int i;
-
+
DBIterator *iter = db_iterator(zone_db);
for(zone = dbi_first(iter); dbi_exists(iter); zone = dbi_next(iter)) {
for(i = 0; i < zone->disabled_skills_count; i++) {
@@ -2918,9 +2917,9 @@ void map_zone_db_clear(void) {
aFree(zone->capped_skills);
}
dbi_destroy(iter);
-
+
db_destroy(zone_db);/* will aFree(zone) */
-
+
/* clear the pk zone stuff */
for(i = 0; i < map_zone_pk.disabled_skills_count; i++) {
aFree(map_zone_pk.disabled_skills[i]);
@@ -2958,20 +2957,69 @@ void map_zone_db_clear(void) {
}
aFree(map_zone_all.capped_skills);
}
+void map_clean(int i) {
+ int v;
+ if(map[i].cell && map[i].cell != (struct mapcell *)0xdeadbeaf) aFree(map[i].cell);
+ if(map[i].block) aFree(map[i].block);
+ if(map[i].block_mob) aFree(map[i].block_mob);
+
+ if(battle_config.dynamic_mobs) { //Dynamic mobs flag by [random]
+ int j;
+ if(map[i].mob_delete_timer != INVALID_TIMER)
+ iTimer->delete_timer(map[i].mob_delete_timer, iMap->removemobs_timer);
+ for (j=0; j<MAX_MOB_LIST_PER_MAP; j++)
+ if (map[i].moblist[j]) aFree(map[i].moblist[j]);
+ }
+
+ if( map[i].unit_count ) {
+ for(v = 0; v < map[i].unit_count; v++) {
+ aFree(map[i].units[v]);
+ }
+ if( map[i].units ) {
+ aFree(map[i].units);
+ map[i].units = NULL;
+ }
+ map[i].unit_count = 0;
+ }
+
+ if( map[i].skill_count ) {
+ for(v = 0; v < map[i].skill_count; v++) {
+ aFree(map[i].skills[v]);
+ }
+ if( map[i].skills ) {
+ aFree(map[i].skills);
+ map[i].skills = NULL;
+ }
+ map[i].skill_count = 0;
+ }
+
+ if( map[i].zone_mf_count ) {
+ for(v = 0; v < map[i].zone_mf_count; v++) {
+ aFree(map[i].zone_mf[v]);
+ }
+ if( map[i].zone_mf ) {
+ aFree(map[i].zone_mf);
+ map[i].zone_mf = NULL;
+ }
+ map[i].zone_mf_count = 0;
+ }
+ if( map[i].channel )
+ clif->chsys_delete(map[i].channel);
+}
void do_final_maps(void) {
int i, v = 0;
- for( i = 0; i < map_num; i++ ) {
-
- if(map[i].cell) aFree(map[i].cell);
+ for( i = 0; i < iMap->map_num; i++ ) {
+
+ if(map[i].cell && map[i].cell != (struct mapcell *)0xdeadbeaf ) aFree(map[i].cell);
if(map[i].block) aFree(map[i].block);
if(map[i].block_mob) aFree(map[i].block_mob);
-
+
if(battle_config.dynamic_mobs) { //Dynamic mobs flag by [random]
int j;
if(map[i].mob_delete_timer != INVALID_TIMER)
- delete_timer(map[i].mob_delete_timer, map_removemobs_timer);
+ iTimer->delete_timer(map[i].mob_delete_timer, iMap->removemobs_timer);
for (j=0; j<MAX_MOB_LIST_PER_MAP; j++)
if (map[i].moblist[j]) aFree(map[i].moblist[j]);
}
@@ -2986,7 +3034,7 @@ void do_final_maps(void) {
}
map[i].unit_count = 0;
}
-
+
if( map[i].skill_count ) {
for(v = 0; v < map[i].skill_count; v++) {
aFree(map[i].skills[v]);
@@ -2997,7 +3045,7 @@ void do_final_maps(void) {
}
map[i].skill_count = 0;
}
-
+
if( map[i].zone_mf_count ) {
for(v = 0; v < map[i].zone_mf_count; v++) {
aFree(map[i].zone_mf[v]);
@@ -3008,19 +3056,25 @@ void do_final_maps(void) {
}
map[i].zone_mf_count = 0;
}
-
+
+ if( map[i].drop_list_count ) {
+ map[i].drop_list_count = 0;
+ }
+ if( map[i].drop_list != NULL )
+ aFree(map[i].drop_list);
+
if( map[i].channel )
clif->chsys_delete(map[i].channel);
}
-
+
map_zone_db_clear();
-
+
}
/// Initializes map flags and adjusts them depending on configuration.
void map_flags_init(void) {
int i, v = 0;
- for( i = 0; i < map_num; i++ ) {
+ for( i = 0; i < iMap->map_num; i++ ) {
// mapflags
memset(&map[i].flag, 0, sizeof(map[i].flag));
@@ -3028,7 +3082,10 @@ void map_flags_init(void) {
map[i].nocommand = 0; // nocommand mapflag level
map[i].bexp = 100; // per map base exp multiplicator
map[i].jexp = 100; // per map job exp multiplicator
- memset(map[i].drop_list, 0, sizeof(map[i].drop_list)); // pvp nightmare drop list
+ if( map[i].drop_list != NULL )
+ aFree(map[i].drop_list);
+ map[i].drop_list = NULL;
+ map[i].drop_list_count = 0;
if( map[i].unit_count ) {
for(v = 0; v < map[i].unit_count; v++) {
@@ -3038,7 +3095,7 @@ void map_flags_init(void) {
}
map[i].units = NULL;
map[i].unit_count = 0;
-
+
if( map[i].skill_count ) {
for(v = 0; v < map[i].skill_count; v++) {
aFree(map[i].skills[v]);
@@ -3047,27 +3104,27 @@ void map_flags_init(void) {
}
map[i].skills = NULL;
map[i].skill_count = 0;
-
+
// adjustments
if( battle_config.pk_mode ) {
map[i].flag.pvp = 1; // make all maps pvp for pk_mode [Valaris]
map[i].zone = &map_zone_pk;
} else /* align with 'All' zone */
map[i].zone = &map_zone_all;
-
+
if( map[i].zone_mf_count ) {
for(v = 0; v < map[i].zone_mf_count; v++) {
aFree(map[i].zone_mf[v]);
}
aFree(map[i].zone_mf);
}
-
+
map[i].zone_mf = NULL;
map[i].zone_mf_count = 0;
map[i].prev_zone = map[i].zone;
-
+
map[i].invincible_time_inc = 0;
-
+
map[i].weapon_damage_rate = 100;
map[i].magic_damage_rate = 100;
map[i].misc_damage_rate = 100;
@@ -3079,15 +3136,15 @@ void map_flags_init(void) {
#define NO_WATER 1000000
/*
- * Reads from the .rsw for each map
- * Returns water height (or NO_WATER if file doesn't exist) or other error is encountered.
- * Assumed path for file is data/mapname.rsw
- * Credits to LittleWolf
- */
+* Reads from the .rsw for each map
+* Returns water height (or NO_WATER if file doesn't exist) or other error is encountered.
+* Assumed path for file is data/mapname.rsw
+* Credits to LittleWolf
+*/
int map_waterheight(char* mapname)
{
char fn[256];
- char *rsw, *found;
+ char *rsw, *found;
//Look up for the rsw
sprintf(fn, "data\\%s.rsw", mapname);
@@ -3108,8 +3165,8 @@ int map_waterheight(char* mapname)
}
/*==================================
- * .GAT format
- *----------------------------------*/
+* .GAT format
+*----------------------------------*/
int map_readgat (struct map_data* m)
{
char filename[256];
@@ -3151,33 +3208,29 @@ int map_readgat (struct map_data* m)
}
/*======================================
- * Add/Remove map to the map_db
- *--------------------------------------*/
-void map_addmap2db(struct map_data *m)
-{
- uidb_put(map_db, (unsigned int)m->index, m);
+* Add/Remove map to the map_db
+*--------------------------------------*/
+void map_addmap2db(struct map_data *m) {
+ index2mapid[m->index] = m->m;
}
-void map_removemapdb(struct map_data *m)
-{
- uidb_remove(map_db, (unsigned int)m->index);
+void map_removemapdb(struct map_data *m) {
+ index2mapid[m->index] = -1;
}
/*======================================
- * Initiate maps loading stage
- *--------------------------------------*/
+* Initiate maps loading stage
+*--------------------------------------*/
int map_readallmaps (void) {
int i;
FILE* fp=NULL;
int maps_removed = 0;
- char *map_cache_buffer = NULL; // Has the uncompressed gat data of all maps, so just one allocation has to be made
- char map_cache_decode_buffer[MAX_MAP_SIZE];
-
+
if( enable_grf )
ShowStatus("Loading maps (using GRF files)...\n");
else {
char mapcachefilepath[254];
- sprintf(mapcachefilepath,"%s/%s%s",db_path,DBPATH,"map_cache.dat");
+ sprintf(mapcachefilepath,"%s/%s%s",iMap->db_path,DBPATH,"map_cache.dat");
ShowStatus("Loading maps (using %s as map cache)...\n", mapcachefilepath);
if( (fp = fopen(mapcachefilepath, "rb")) == NULL ) {
ShowFatalError("Unable to open map cache file "CL_WHITE"%s"CL_RESET"\n", mapcachefilepath);
@@ -3192,31 +3245,30 @@ int map_readallmaps (void) {
}
}
- for(i = 0; i < map_num; i++) {
+ for(i = 0; i < iMap->map_num; i++) {
size_t size;
// show progress
if(enable_grf)
- ShowStatus("Loading maps [%i/%i]: %s"CL_CLL"\r", i, map_num, map[i].name);
+ ShowStatus("Loading maps [%i/%i]: %s"CL_CLL"\r", i, iMap->map_num, map[i].name);
// try to load the map
if( !
(enable_grf?
- map_readgat(&map[i])
- :map_readfromcache(&map[i], map_cache_buffer, map_cache_decode_buffer))
+ map_readgat(&map[i])
+ :map_readfromcache(&map[i], map_cache_buffer))
) {
- map_delmapid(i);
- maps_removed++;
- i--;
- continue;
+ map_delmapid(i);
+ maps_removed++;
+ i--;
+ continue;
}
map[i].index = mapindex_name2id(map[i].name);
- if (uidb_get(map_db,(unsigned int)map[i].index) != NULL)
- {
+ if ( index2mapid[map[i].index] != -1 ) {
ShowWarning("Map %s already loaded!"CL_CLL"\n", map[i].name);
- if (map[i].cell) {
+ if (map[i].cell && map[i].cell != (struct mapcell *)0xdeadbeaf) {
aFree(map[i].cell);
map[i].cell = NULL;
}
@@ -3226,9 +3278,9 @@ int map_readallmaps (void) {
continue;
}
- map_addmap2db(&map[i]);
-
map[i].m = i;
+ iMap->addmap2db(&map[i]);
+
memset(map[i].moblist, 0, sizeof(map[i].moblist)); //Initialize moblist [Skotlex]
map[i].mob_delete_timer = INVALID_TIMER; //Initialize timer [Skotlex]
@@ -3238,21 +3290,21 @@ int map_readallmaps (void) {
size = map[i].bxs * map[i].bys * sizeof(struct block_list*);
map[i].block = (struct block_list**)aCalloc(size, 1);
map[i].block_mob = (struct block_list**)aCalloc(size, 1);
+
+ map[i].getcellp = map_sub_getcellp;
+ map[i].setcell = map_sub_setcell;
}
// intialization and configuration-dependent adjustments of mapflags
- map_flags_init();
+ iMap->flags_init();
if( !enable_grf ) {
fclose(fp);
-
- // The cache isn't needed anymore, so free it.. [Shinryo]
- aFree(map_cache_buffer);
}
// finished map loading
- ShowInfo("Successfully loaded '"CL_WHITE"%d"CL_RESET"' maps."CL_CLL"\n",map_num);
- instance_start = map_num; // Next Map Index will be instances
+ ShowInfo("Successfully loaded '"CL_WHITE"%d"CL_RESET"' maps."CL_CLL"\n",iMap->map_num);
+ instance->start_id = iMap->map_num; // Next Map Index will be instances
if (maps_removed)
ShowNotice("Maps removed: '"CL_WHITE"%d"CL_RESET"'\n",maps_removed);
@@ -3265,22 +3317,19 @@ static int map_ip_set = 0;
static int char_ip_set = 0;
/*==========================================
- * Read map server configuration files (conf/map_server.conf...)
- *------------------------------------------*/
-int map_config_read(char *cfgName)
-{
+* Read map server configuration files (conf/map_server.conf...)
+*------------------------------------------*/
+int map_config_read(char *cfgName) {
char line[1024], w1[1024], w2[1024];
FILE *fp;
fp = fopen(cfgName,"r");
- if( fp == NULL )
- {
+ if( fp == NULL ) {
ShowError("Map configuration file not found at: %s\n", cfgName);
return 1;
}
- while( fgets(line, sizeof(line), fp) )
- {
+ while( fgets(line, sizeof(line), fp) ) {
char* ptr;
if( line[0] == '/' && line[1] == '/' )
@@ -3320,35 +3369,35 @@ int map_config_read(char *cfgName)
clif->setport(atoi(w2));
map_port = (atoi(w2));
} else if (strcmpi(w1, "map") == 0)
- map_addmap(w2);
+ iMap->map_num++;
else if (strcmpi(w1, "delmap") == 0)
- map_delmap(w2);
+ iMap->map_num--;
else if (strcmpi(w1, "npc") == 0)
npc_addsrcfile(w2);
else if (strcmpi(w1, "delnpc") == 0)
npc_delsrcfile(w2);
else if (strcmpi(w1, "autosave_time") == 0) {
- autosave_interval = atoi(w2);
- if (autosave_interval < 1) //Revert to default saving.
- autosave_interval = DEFAULT_AUTOSAVE_INTERVAL;
+ iMap->autosave_interval = atoi(w2);
+ if (iMap->autosave_interval < 1) //Revert to default saving.
+ iMap->autosave_interval = DEFAULT_AUTOSAVE_INTERVAL;
else
- autosave_interval *= 1000; //Pass from sec to ms
+ iMap->autosave_interval *= 1000; //Pass from sec to ms
} else if (strcmpi(w1, "minsave_time") == 0) {
- minsave_interval= atoi(w2);
- if (minsave_interval < 1)
- minsave_interval = 1;
+ iMap->minsave_interval= atoi(w2);
+ if (iMap->minsave_interval < 1)
+ iMap->minsave_interval = 1;
} else if (strcmpi(w1, "save_settings") == 0)
- save_settings = atoi(w2);
+ iMap->save_settings = atoi(w2);
else if (strcmpi(w1, "help_txt") == 0)
- strcpy(help_txt, w2);
+ strcpy(iMap->help_txt, w2);
else if (strcmpi(w1, "help2_txt") == 0)
- strcpy(help2_txt, w2);
+ strcpy(iMap->help2_txt, w2);
else if (strcmpi(w1, "charhelp_txt") == 0)
- strcpy(charhelp_txt, w2);
+ strcpy(iMap->charhelp_txt, w2);
else if(strcmpi(w1,"db_path") == 0)
- safestrncpy(db_path,w2,255);
+ safestrncpy(iMap->db_path,w2,255);
else if (strcmpi(w1, "enable_spy") == 0)
- enable_spy = config_switch(w2);
+ iMap->enable_spy = config_switch(w2);
else if (strcmpi(w1, "use_grf") == 0)
enable_grf = config_switch(w2);
else if (strcmpi(w1, "console_msg_log") == 0)
@@ -3362,7 +3411,43 @@ int map_config_read(char *cfgName)
fclose(fp);
return 0;
}
+int map_config_read_sub(char *cfgName) {
+ char line[1024], w1[1024], w2[1024];
+ FILE *fp;
+ fp = fopen(cfgName,"r");
+ if( fp == NULL ) {
+ ShowError("Map configuration file not found at: %s\n", cfgName);
+ return 1;
+ }
+
+ while( fgets(line, sizeof(line), fp) ) {
+ char* ptr;
+
+ if( line[0] == '/' && line[1] == '/' )
+ continue;
+ if( (ptr = strstr(line, "//")) != NULL )
+ *ptr = '\n'; //Strip comments
+ if( sscanf(line, "%[^:]: %[^\t\r\n]", w1, w2) < 2 )
+ continue;
+
+ //Strip trailing spaces
+ ptr = w2 + strlen(w2);
+ while (--ptr >= w2 && *ptr == ' ');
+ ptr++;
+ *ptr = '\0';
+
+ if (strcmpi(w1, "map") == 0)
+ map_addmap(w2);
+ else if (strcmpi(w1, "delmap") == 0)
+ iMap->delmap(w2);
+ else if (strcmpi(w1, "import") == 0)
+ map_config_read_sub(w2);
+ }
+
+ fclose(fp);
+ return 0;
+}
void map_reloadnpc_sub(char *cfgName)
{
char line[1024], w1[1024], w2[1024];
@@ -3415,81 +3500,70 @@ void map_reloadnpc(bool clear)
#endif
}
-int inter_config_read(char *cfgName)
-{
+int inter_config_read(char *cfgName) {
char line[1024],w1[1024],w2[1024];
FILE *fp;
- fp=fopen(cfgName,"r");
- if(fp==NULL){
+ if( !( fp = fopen(cfgName,"r") ) ){
ShowError("File not found: %s\n",cfgName);
return 1;
}
- while(fgets(line, sizeof(line), fp))
- {
+ while(fgets(line, sizeof(line), fp)) {
if(line[0] == '/' && line[1] == '/')
continue;
+
if( sscanf(line,"%[^:]: %[^\r\n]",w1,w2) < 2 )
continue;
-
+ /* table names */
if(strcmpi(w1,"item_db_db")==0)
- strcpy(item_db_db,w2);
- else
- if(strcmpi(w1,"mob_db_db")==0)
- strcpy(mob_db_db,w2);
- else
- if(strcmpi(w1,"item_db2_db")==0)
- strcpy(item_db2_db,w2);
- else
- if(strcmpi(w1,"item_db_re_db")==0)
- strcpy(item_db_re_db,w2);
- else
- if(strcmpi(w1,"mob_db2_db")==0)
- strcpy(mob_db2_db,w2);
- else
- //Map Server SQL DB
- if(strcmpi(w1,"map_server_ip")==0)
+ strcpy(iMap->item_db_db,w2);
+ else if(strcmpi(w1,"mob_db_db")==0)
+ strcpy(iMap->mob_db_db,w2);
+ else if(strcmpi(w1,"item_db2_db")==0)
+ strcpy(iMap->item_db2_db,w2);
+ else if(strcmpi(w1,"item_db_re_db")==0)
+ strcpy(iMap->item_db_re_db,w2);
+ else if(strcmpi(w1,"mob_db2_db")==0)
+ strcpy(iMap->mob_db2_db,w2);
+ else if(strcmpi(w1,"mob_skill_db_db")==0)
+ strcpy(iMap->mob_skill_db_db,w2);
+ else if(strcmpi(w1,"mob_skill_db2_db")==0)
+ strcpy(iMap->mob_skill_db2_db,w2);
+ else if(strcmpi(w1,"interreg_db")==0)
+ strcpy(iMap->interreg_db,w2);
+ /* map sql stuff */
+ else if(strcmpi(w1,"map_server_ip")==0)
strcpy(map_server_ip, w2);
- else
- if(strcmpi(w1,"map_server_port")==0)
+ else if(strcmpi(w1,"map_server_port")==0)
map_server_port=atoi(w2);
- else
- if(strcmpi(w1,"map_server_id")==0)
+ else if(strcmpi(w1,"map_server_id")==0)
strcpy(map_server_id, w2);
- else
- if(strcmpi(w1,"map_server_pw")==0)
+ else if(strcmpi(w1,"map_server_pw")==0)
strcpy(map_server_pw, w2);
- else
- if(strcmpi(w1,"map_server_db")==0)
+ else if(strcmpi(w1,"map_server_db")==0)
strcpy(map_server_db, w2);
- else
- if(strcmpi(w1,"default_codepage")==0)
+ else if(strcmpi(w1,"default_codepage")==0)
strcpy(default_codepage, w2);
- else
- if(strcmpi(w1,"use_sql_db")==0) {
- db_use_sqldbs = config_switch(w2);
+ else if(strcmpi(w1,"use_sql_db")==0) {
+ iMap->db_use_sqldbs = config_switch(w2);
ShowStatus ("Using SQL dbs: %s\n",w2);
- } else
- if(strcmpi(w1,"log_db_ip")==0)
+ }
+ /* sql log db */
+ else if(strcmpi(w1,"log_db_ip")==0)
strcpy(log_db_ip, w2);
- else
- if(strcmpi(w1,"log_db_id")==0)
+ else if(strcmpi(w1,"log_db_id")==0)
strcpy(log_db_id, w2);
- else
- if(strcmpi(w1,"log_db_pw")==0)
+ else if(strcmpi(w1,"log_db_pw")==0)
strcpy(log_db_pw, w2);
- else
- if(strcmpi(w1,"log_db_port")==0)
+ else if(strcmpi(w1,"log_db_port")==0)
log_db_port = atoi(w2);
- else
- if(strcmpi(w1,"log_db_db")==0)
+ else if(strcmpi(w1,"log_db_db")==0)
strcpy(log_db_db, w2);
- else
- if( mapreg_config_read(w1,w2) )
+ /* mapreg */
+ else if( mapreg_config_read(w1,w2) )
continue;
- //support the import command, just like any other config
- else
- if(strcmpi(w1,"import")==0)
+ /* import */
+ else if(strcmpi(w1,"import")==0)
inter_config_read(w2);
}
fclose(fp);
@@ -3498,8 +3572,8 @@ int inter_config_read(char *cfgName)
}
/*=======================================
- * MySQL Init
- *---------------------------------------*/
+* MySQL Init
+*---------------------------------------*/
int map_sql_init(void)
{
// main db connection
@@ -3547,21 +3621,21 @@ int log_sql_init(void)
}
void map_zone_change2(int m, struct map_zone_data *zone) {
char empty[1] = "\0";
-
+
map[m].prev_zone = map[m].zone;
if( map[m].zone_mf_count )
- map_zone_remove(m);
-
- map_zone_apply(m,zone,empty,empty,empty);
+ iMap->zone_remove(m);
+
+ iMap->zone_apply(m,zone,empty,empty,empty);
}
/* when changing from a mapflag to another during runtime */
void map_zone_change(int m, struct map_zone_data *zone, const char* start, const char* buffer, const char* filepath) {
map[m].prev_zone = map[m].zone;
-
+
if( map[m].zone_mf_count )
- map_zone_remove(m);
- map_zone_apply(m,zone,start,buffer,filepath);
+ iMap->zone_remove(m);
+ iMap->zone_apply(m,zone,start,buffer,filepath);
}
/* removes previous mapflags from this map */
void map_zone_remove(int m) {
@@ -3579,12 +3653,12 @@ void map_zone_remove(int m) {
break;
}
}
-
+
npc_parse_mapflag(map[m].name,empty,flag,params,empty,empty,empty);
aFree(map[m].zone_mf[k]);
map[m].zone_mf[k] = NULL;
}
-
+
aFree(map[m].zone_mf);
map[m].zone_mf = NULL;
map[m].zone_mf_count = 0;
@@ -3599,31 +3673,31 @@ static inline void map_zone_mf_cache_add(int m, char *rflag) {
bool map_zone_mf_cache(int m, char *flag, char *params) {
char rflag[MAP_ZONE_MAPFLAG_LENGTH];
int state = 1;
-
+
if (params[0] != '\0' && !strcmpi(params, "off"))
state = 0;
-
+
if (!strcmpi(flag, "nosave")) {
;/* not yet supported to be reversed */
/*
char savemap[32];
int savex, savey;
if (state == 0) {
- if( map[m].flag.nosave ) {
- sprintf(rflag, "nosave SavePoint");
- map_zone_mf_cache_add(m,nosave);
- }
+ if( map[m].flag.nosave ) {
+ sprintf(rflag, "nosave SavePoint");
+ map_zone_mf_cache_add(m,nosave);
+ }
} else if (!strcmpi(params, "SavePoint")) {
- if( map[m].save.map ) {
- sprintf(rflag, "nosave %s,%d,%d",mapindex_id2name(map[m].save.map),map[m].save.x,map[m].save.y);
- } else
- sprintf(rflag, "nosave %s,%d,%d",mapindex_id2name(map[m].save.map),map[m].save.x,map[m].save.y);
- map_zone_mf_cache_add(m,nosave);
+ if( map[m].save.map ) {
+ sprintf(rflag, "nosave %s,%d,%d",mapindex_id2name(map[m].save.map),map[m].save.x,map[m].save.y);
+ } else
+ sprintf(rflag, "nosave %s,%d,%d",mapindex_id2name(map[m].save.map),map[m].save.x,map[m].save.y);
+ map_zone_mf_cache_add(m,nosave);
} else if (sscanf(params, "%31[^,],%d,%d", savemap, &savex, &savey) == 3) {
- if( map[m].save.map ) {
- sprintf(rflag, "nosave %s,%d,%d",mapindex_id2name(map[m].save.map),map[m].save.x,map[m].save.y);
- map_zone_mf_cache_add(m,nosave);
- }
+ if( map[m].save.map ) {
+ sprintf(rflag, "nosave %s,%d,%d",mapindex_id2name(map[m].save.map),map[m].save.x,map[m].save.y);
+ map_zone_mf_cache_add(m,nosave);
+ }
}*/
} else if (!strcmpi(flag,"autotrade")) {
if( state && map[m].flag.autotrade )
@@ -3765,33 +3839,33 @@ bool map_zone_mf_cache(int m, char *flag, char *params) {
/*char drop_arg1[16], drop_arg2[16];
int drop_per = 0;
if (sscanf(w4, "%[^,],%[^,],%d", drop_arg1, drop_arg2, &drop_per) == 3) {
- int drop_id = 0, drop_type = 0;
- if (!strcmpi(drop_arg1, "random"))
- drop_id = -1;
- else if (itemdb_exists((drop_id = atoi(drop_arg1))) == NULL)
- drop_id = 0;
- if (!strcmpi(drop_arg2, "inventory"))
- drop_type = 1;
- else if (!strcmpi(drop_arg2,"equip"))
- drop_type = 2;
- else if (!strcmpi(drop_arg2,"all"))
- drop_type = 3;
-
- if (drop_id != 0){
- int i;
- for (i = 0; i < MAX_DROP_PER_MAP; i++) {
- if (map[m].drop_list[i].drop_id == 0){
- map[m].drop_list[i].drop_id = drop_id;
- map[m].drop_list[i].drop_type = drop_type;
- map[m].drop_list[i].drop_per = drop_per;
- break;
- }
- }
- map[m].flag.pvp_nightmaredrop = 1;
- }
+ int drop_id = 0, drop_type = 0;
+ if (!strcmpi(drop_arg1, "random"))
+ drop_id = -1;
+ else if (itemdb->exists((drop_id = atoi(drop_arg1))) == NULL)
+ drop_id = 0;
+ if (!strcmpi(drop_arg2, "inventory"))
+ drop_type = 1;
+ else if (!strcmpi(drop_arg2,"equip"))
+ drop_type = 2;
+ else if (!strcmpi(drop_arg2,"all"))
+ drop_type = 3;
+
+ if (drop_id != 0){
+ int i;
+ for (i = 0; i < MAX_DROP_PER_MAP; i++) {
+ if (map[m].drop_list[i].drop_id == 0){
+ map[m].drop_list[i].drop_id = drop_id;
+ map[m].drop_list[i].drop_type = drop_type;
+ map[m].drop_list[i].drop_per = drop_per;
+ break;
+ }
+ }
+ map[m].flag.pvp_nightmaredrop = 1;
+ }
} else if (!state) //Disable
- map[m].flag.pvp_nightmaredrop = 0;
- */
+ map[m].flag.pvp_nightmaredrop = 0;
+ */
} else if (!strcmpi(flag,"pvp_nocalcrank")) {
if( state && map[m].flag.pvp_nocalcrank )
;/* nothing to do */
@@ -4122,10 +4196,10 @@ bool map_zone_mf_cache(int m, char *flag, char *params) {
int skill_id, k;
char skill_name[MAP_ZONE_MAPFLAG_LENGTH], modifier[MAP_ZONE_MAPFLAG_LENGTH];
int len = strlen(params);
-
+
modifier[0] = '\0';
memcpy(skill_name, params, MAP_ZONE_MAPFLAG_LENGTH);
-
+
for(k = 0; k < len; k++) {
if( skill_name[k] == '\t' ) {
memcpy(modifier, &skill_name[k+1], len - k);
@@ -4133,15 +4207,15 @@ bool map_zone_mf_cache(int m, char *flag, char *params) {
break;
}
}
-
+
if( modifier[0] == '\0' || !( skill_id = skill->name2id(skill_name) ) || !skill->get_unit_id( skill->name2id(skill_name), 0) || atoi(modifier) < 1 || atoi(modifier) > USHRT_MAX ) {
;/* we dont mind it, the server will take care of it next. */
} else {
int idx = map[m].unit_count;
-
+
k = 0;
ARR_FIND(0, idx, k, map[m].units[k]->skill_id == skill_id);
-
+
if( k < idx ) {
if( atoi(modifier) != map[m].units[k]->modifier ) {
sprintf(rflag,"adjust_unit_duration %s %d",skill_name,map[m].units[k]->modifier);
@@ -4156,10 +4230,10 @@ bool map_zone_mf_cache(int m, char *flag, char *params) {
int skill_id, k;
char skill_name[MAP_ZONE_MAPFLAG_LENGTH], modifier[MAP_ZONE_MAPFLAG_LENGTH];
int len = strlen(params);
-
+
modifier[0] = '\0';
memcpy(skill_name, params, MAP_ZONE_MAPFLAG_LENGTH);
-
+
for(k = 0; k < len; k++) {
if( skill_name[k] == '\t' ) {
memcpy(modifier, &skill_name[k+1], len - k);
@@ -4167,15 +4241,15 @@ bool map_zone_mf_cache(int m, char *flag, char *params) {
break;
}
}
-
+
if( modifier[0] == '\0' || !( skill_id = skill->name2id(skill_name) ) || atoi(modifier) < 1 || atoi(modifier) > USHRT_MAX ) {
;/* we dont mind it, the server will take care of it next. */
} else {
int idx = map[m].skill_count;
-
+
k = 0;
ARR_FIND(0, idx, k, map[m].skills[k]->skill_id == skill_id);
-
+
if( k < idx ) {
if( atoi(modifier) != map[m].skills[k]->modifier ) {
sprintf(rflag,"adjust_skill_damage %s %d",skill_name,map[m].skills[k]->modifier);
@@ -4185,7 +4259,7 @@ bool map_zone_mf_cache(int m, char *flag, char *params) {
sprintf(rflag,"adjust_skill_damage %s 100",skill_name);
map_zone_mf_cache_add(m,rflag);
}
-
+
}
} else if (!strcmpi(flag,"zone")) {
ShowWarning("You can't add a zone through a zone! ERROR, skipping for '%s'...\n",map[m].name);
@@ -4300,10 +4374,10 @@ void map_zone_apply(int m, struct map_zone_data *zone, const char* start, const
break;
}
}
-
+
if( map_zone_mf_cache(m,flag,params) )
continue;
-
+
npc_parse_mapflag(map[m].name,empty,flag,params,start,buffer,filepath);
}
}
@@ -4313,9 +4387,9 @@ void map_zone_init(void) {
struct map_zone_data *zone;
char empty[1] = "\0";
int i,k,j;
-
+
zone = &map_zone_all;
-
+
for(i = 0; i < zone->mapflags_count; i++) {
int len = strlen(zone->mapflags[i]);
params[0] = '\0';
@@ -4327,8 +4401,8 @@ void map_zone_init(void) {
break;
}
}
-
- for(j = 0; j < map_num; j++) {
+
+ for(j = 0; j < iMap->map_num; j++) {
if( map[j].zone == zone ) {
if( map_zone_mf_cache(j,flag,params) )
break;
@@ -4336,7 +4410,7 @@ void map_zone_init(void) {
}
}
}
-
+
if( battle_config.pk_mode ) {
zone = &map_zone_pk;
for(i = 0; i < zone->mapflags_count; i++) {
@@ -4350,7 +4424,7 @@ void map_zone_init(void) {
break;
}
}
- for(j = 0; j < map_num; j++) {
+ for(j = 0; j < iMap->map_num; j++) {
if( map[j].zone == zone ) {
if( map_zone_mf_cache(j,flag,params) )
break;
@@ -4359,19 +4433,19 @@ void map_zone_init(void) {
}
}
}
-
+
}
unsigned short map_zone_str2itemid(const char *name) {
struct item_data *data;
-
+
if( !name )
return 0;
if( name[0] == 'I' && name[1] == 'D' && strlen(name) <= 7 ) {
- if( !( data = itemdb_exists(atoi(name+2))) ) {
+ if( !( data = itemdb->exists(atoi(name+2))) ) {
return 0;
}
} else {
- if( !( data = itemdb_searchname(name) ) ) {
+ if( !( data = itemdb->search_name(name) ) ) {
return 0;
}
}
@@ -4379,10 +4453,10 @@ unsigned short map_zone_str2itemid(const char *name) {
}
unsigned short map_zone_str2skillid(const char *name) {
unsigned short nameid = 0;
-
+
if( !name )
return 0;
-
+
if( name[0] == 'I' && name[1] == 'D' && strlen(name) <= 7 ) {
if( !skill->get_index((nameid = atoi(name+2))) )
return 0;
@@ -4400,11 +4474,11 @@ enum bl_type map_zone_bl_type(const char *entry, enum map_zone_skill_subtype *su
if( !entry )
return BL_NUL;
-
+
safestrncpy(temp, entry, 200);
-
+
parse = strtok(temp,"|");
-
+
while (parse != NULL) {
normalize_name(parse," ");
if( strcmpi(parse,"player") == 0 )
@@ -4449,9 +4523,9 @@ void read_map_zone_db(void) {
#endif
if (conf_read_file(&map_zone_db, config_filename))
return;
-
+
zones = config_lookup(&map_zone_db, "zones");
-
+
if (zones != NULL) {
struct map_zone_data *zone;
config_setting_t *zone_e;
@@ -4466,22 +4540,22 @@ void read_map_zone_db(void) {
int zone_count = 0, disabled_skills_count = 0, disabled_items_count = 0, mapflags_count = 0,
disabled_commands_count = 0, capped_skills_count = 0;
enum map_zone_skill_subtype subtype;
-
+
zone_count = config_setting_length(zones);
for (i = 0; i < zone_count; ++i) {
bool is_all = false;
-
+
zone_e = config_setting_get_elem(zones, i);
-
+
if (!config_setting_lookup_string(zone_e, "name", &zonename)) {
ShowError("map_zone_db: missing zone name, skipping... (%s:%d)\n",
- config_setting_source_file(zone_e), config_setting_source_line(zone_e));
+ config_setting_source_file(zone_e), config_setting_source_line(zone_e));
config_setting_remove_elem(zones,i);/* remove from the tree */
--zone_count;
--i;
continue;
}
-
+
if( strdb_exists(zone_db, zonename) ) {
ShowError("map_zone_db: duplicate zone name '%s', skipping...\n",zonename);
config_setting_remove_elem(zones,i);/* remove from the tree */
@@ -4489,7 +4563,7 @@ void read_map_zone_db(void) {
--i;
continue;
}
-
+
/* is this the global template? */
if( strncmpi(zonename,MAP_ZONE_NORMAL_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) {
zone = &map_zone_all;
@@ -4503,7 +4577,7 @@ void read_map_zone_db(void) {
zone->disabled_items_count = 0;
}
safestrncpy(zone->name, zonename, MAP_ZONE_NAME_LENGTH);
-
+
if( (skills = config_setting_get_member(zone_e, "disabled_skills")) != NULL ) {
disabled_skills_count = config_setting_length(skills);
/* validate */
@@ -4527,21 +4601,21 @@ void read_map_zone_db(void) {
struct map_zone_disabled_skill_entry * entry;
enum bl_type type;
name = config_setting_name(skill);
-
+
if( (type = map_zone_bl_type(config_setting_get_string_elem(skills,h),&subtype)) ) { /* only add if enabled */
CREATE( entry, struct map_zone_disabled_skill_entry, 1 );
-
+
entry->nameid = map_zone_str2skillid(name);
entry->type = type;
entry->subtype = subtype;
-
+
zone->disabled_skills[v++] = entry;
}
-
+
}
zone->disabled_skills_count = disabled_skills_count;
}
-
+
if( (items = config_setting_get_member(zone_e, "disabled_items")) != NULL ) {
disabled_items_count = config_setting_length(items);
/* validate */
@@ -4562,31 +4636,31 @@ void read_map_zone_db(void) {
CREATE( zone->disabled_items, int, disabled_items_count );
for(h = 0, v = 0; h < config_setting_length(items); h++) {
config_setting_t *item = config_setting_get_elem(items, h);
-
+
if( config_setting_get_bool(item) ) { /* only add if enabled */
name = config_setting_name(item);
zone->disabled_items[v++] = map_zone_str2itemid(name);
}
-
+
}
zone->disabled_items_count = disabled_items_count;
}
-
+
if( (mapflags = config_setting_get_member(zone_e, "mapflags")) != NULL ) {
mapflags_count = config_setting_length(mapflags);
/* mapflags are not validated here, so we save all anyway */
CREATE( zone->mapflags, char *, mapflags_count );
for(h = 0; h < mapflags_count; h++) {
CREATE( zone->mapflags[h], char, MAP_ZONE_MAPFLAG_LENGTH );
-
+
name = config_setting_get_string_elem(mapflags, h);
-
+
safestrncpy(zone->mapflags[h], name, MAP_ZONE_MAPFLAG_LENGTH);
-
+
}
zone->mapflags_count = mapflags_count;
}
-
+
if( (commands = config_setting_get_member(zone_e, "disabled_commands")) != NULL ) {
disabled_commands_count = config_setting_length(commands);
/* validate */
@@ -4610,19 +4684,19 @@ void read_map_zone_db(void) {
struct map_zone_disabled_command_entry * entry;
int group_lv;
name = config_setting_name(command);
-
+
if( (group_lv = config_setting_get_int(command)) ) { /* only add if enabled */
CREATE( entry, struct map_zone_disabled_command_entry, 1 );
-
+
entry->cmd = atcommand->exists(name)->func;
entry->group_lv = group_lv;
-
+
zone->disabled_commands[v++] = entry;
}
}
zone->disabled_commands_count = disabled_commands_count;
}
-
+
if( (caps = config_setting_get_member(zone_e, "skill_damage_cap")) != NULL ) {
capped_skills_count = config_setting_length(caps);
/* validate */
@@ -4646,10 +4720,10 @@ void read_map_zone_db(void) {
struct map_zone_skill_damage_cap_entry * entry;
enum bl_type type;
name = config_setting_name(cap);
-
+
if( (type = map_zone_bl_type(config_setting_get_string_elem(cap,1),&subtype)) ) { /* only add if enabled */
CREATE( entry, struct map_zone_skill_damage_cap_entry, 1 );
-
+
entry->nameid = map_zone_str2skillid(name);
entry->cap = config_setting_get_int_elem(cap,0);
entry->type = type;
@@ -4659,25 +4733,25 @@ void read_map_zone_db(void) {
}
zone->capped_skills_count = capped_skills_count;
}
-
+
if( !is_all ) /* global template doesn't go into db -- since it isn't a alloc'd piece of data */
strdb_put(zone_db, zonename, zone);
-
+
}
-
+
/* process inheritance, aka loop through the whole thing again :P */
for (i = 0; i < zone_count; ++i) {
config_setting_t *inherit_tree = NULL;
config_setting_t *new_entry = NULL;
int inherit_count;
-
+
zone_e = config_setting_get_elem(zones, i);
config_setting_lookup_string(zone_e, "name", &zonename);
if( strncmpi(zonename,MAP_ZONE_ALL_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) {
continue;/* all zone doesn't inherit anything (if it did, everything would link to each other and boom endless loop) */
}
-
+
if( (inherit_tree = config_setting_get_member(zone_e, "inherit")) != NULL ) {
/* append global zone to this */
new_entry = config_setting_add(inherit_tree,MAP_ZONE_ALL_NAME,CONFIG_TYPE_STRING);
@@ -4697,7 +4771,7 @@ void read_map_zone_db(void) {
int disabled_commands_count_i = 0; /* commands count from inherit zone */
int capped_skills_count_i = 0; /* skill capped count from inherit zone */
int j;
-
+
name = config_setting_get_string_elem(inherit_tree, h);
config_setting_lookup_string(zone_e, "name", &zonename);/* will succeed for we validated it earlier */
@@ -4705,20 +4779,20 @@ void read_map_zone_db(void) {
ShowError("map_zone_db: Unknown zone '%s' being inherit by zone '%s', skipping...\n",name,zonename);
continue;
}
-
+
if( strncmpi(zonename,MAP_ZONE_NORMAL_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) {
zone = &map_zone_all;
} else if( strncmpi(zonename,MAP_ZONE_PK_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) {
zone = &map_zone_pk;
} else
zone = strdb_get(zone_db, zonename);/* will succeed for we just put it in here */
-
+
disabled_skills_count_i = izone->disabled_skills_count;
disabled_items_count_i = izone->disabled_items_count;
mapflags_count_i = izone->mapflags_count;
disabled_commands_count_i = izone->disabled_commands_count;
capped_skills_count_i = izone->capped_skills_count;
-
+
/* process everything to override, paying attention to config_setting_get_bool */
if( disabled_skills_count_i ) {
if( (skills = config_setting_get_member(zone_e, "disabled_skills")) == NULL )
@@ -4742,7 +4816,7 @@ void read_map_zone_db(void) {
}
}
}
-
+
if( disabled_items_count_i ) {
if( (items = config_setting_get_member(zone_e, "disabled_items")) == NULL )
items = config_setting_add(zone_e, "disabled_items",CONFIG_TYPE_GROUP);
@@ -4751,9 +4825,9 @@ void read_map_zone_db(void) {
int k;
for(k = 0; k < disabled_items_count; k++) {
config_setting_t *item = config_setting_get_elem(items, k);
-
+
name = config_setting_name(item);
-
+
if( map_zone_str2itemid(name) == izone->disabled_items[j] ) {
if( config_setting_get_bool(item) )
continue;
@@ -4766,7 +4840,7 @@ void read_map_zone_db(void) {
}
}
}
-
+
if( mapflags_count_i ) {
if( (mapflags = config_setting_get_member(zone_e, "mapflags")) == NULL )
mapflags = config_setting_add(zone_e, "mapflags",CONFIG_TYPE_ARRAY);
@@ -4775,7 +4849,7 @@ void read_map_zone_db(void) {
int k;
for(k = 0; k < mapflags_count; k++) {
name = config_setting_get_string_elem(mapflags, k);
-
+
if( strcmpi(name,izone->mapflags[j]) == 0 ) {
break;
}
@@ -4787,7 +4861,7 @@ void read_map_zone_db(void) {
}
}
}
-
+
if( disabled_commands_count_i ) {
if( (commands = config_setting_get_member(zone_e, "disabled_commands")) == NULL )
commands = config_setting_add(zone_e, "disabled_commands",CONFIG_TYPE_GROUP);
@@ -4811,11 +4885,11 @@ void read_map_zone_db(void) {
}
}
}
-
+
if( capped_skills_count_i ) {
if( (caps = config_setting_get_member(zone_e, "skill_damage_cap")) == NULL )
caps = config_setting_add(zone_e, "skill_damage_cap",CONFIG_TYPE_GROUP);
-
+
capped_skills_count = config_setting_length(caps);
for(j = 0; j < capped_skills_count_i; j++) {
int k;
@@ -4839,7 +4913,7 @@ void read_map_zone_db(void) {
}
}
-
+
ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' zones in '"CL_WHITE"%s"CL_RESET"'.\n", zone_count, config_filename);
/* not supposed to go in here but in skill_final whatever */
config_destroy(&map_zone_db);
@@ -4847,19 +4921,20 @@ void read_map_zone_db(void) {
}
/**
- * @see DBApply
- */
-int map_db_final(DBKey key, DBData *data, va_list ap)
-{
+* @see DBApply
+*/
+int map_db_final(DBKey key, DBData *data, va_list ap) {
struct map_data_other_server *mdos = DB->data2ptr(data);
- if(mdos && mdos->cell == NULL)
+
+ if(mdos && iMalloc->verify_ptr(mdos) && mdos->cell == NULL)
aFree(mdos);
+
return 0;
}
/**
- * @see DBApply
- */
+* @see DBApply
+*/
int nick_db_final(DBKey key, DBData *data, va_list args)
{
struct charid2nick* p = DB->data2ptr(data);
@@ -4877,45 +4952,44 @@ int nick_db_final(DBKey key, DBData *data, va_list args)
return 0;
}
-int cleanup_sub(struct block_list *bl, va_list ap)
-{
+int cleanup_sub(struct block_list *bl, va_list ap) {
nullpo_ret(bl);
switch(bl->type) {
- case BL_PC:
- map_quit((struct map_session_data *) bl);
- break;
- case BL_NPC:
- npc_unload((struct npc_data *)bl,false);
- break;
- case BL_MOB:
- unit_free(bl,CLR_OUTSIGHT);
- break;
- case BL_PET:
+ case BL_PC:
+ iMap->quit((struct map_session_data *) bl);
+ break;
+ case BL_NPC:
+ npc_unload((struct npc_data *)bl,false);
+ break;
+ case BL_MOB:
+ unit_free(bl,CLR_OUTSIGHT);
+ break;
+ case BL_PET:
//There is no need for this, the pet is removed together with the player. [Skotlex]
- break;
- case BL_ITEM:
- map_clearflooritem(bl);
- break;
- case BL_SKILL:
- skill->delunit((struct skill_unit *) bl);
- break;
+ break;
+ case BL_ITEM:
+ iMap->clearflooritem(bl);
+ break;
+ case BL_SKILL:
+ skill->delunit((struct skill_unit *) bl);
+ break;
}
return 1;
}
/**
- * @see DBApply
- */
+* @see DBApply
+*/
static int cleanup_db_sub(DBKey key, DBData *data, va_list va)
{
- return cleanup_sub(DB->data2ptr(data), va);
+ return iMap->cleanup_sub(DB->data2ptr(data), va);
}
/*==========================================
- * map destructor
- *------------------------------------------*/
+* map destructor
+*------------------------------------------*/
void do_final(void)
{
int i;
@@ -4929,24 +5003,24 @@ void do_final(void)
//Ladies and babies first.
iter = mapit_getallusers();
for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) )
- map_quit(sd);
+ iMap->quit(sd);
mapit->free(iter);
/* prepares npcs for a faster shutdown process */
do_clear_npc();
// remove all objects on maps
- for (i = 0; i < map_num; i++) {
- ShowStatus("Cleaning up maps [%d/%d]: %s..."CL_CLL"\r", i+1, map_num, map[i].name);
+ for (i = 0; i < iMap->map_num; i++) {
+ ShowStatus("Cleaning up maps [%d/%d]: %s..."CL_CLL"\r", i+1, iMap->map_num, map[i].name);
if (map[i].m >= 0)
- map_foreachinmap(cleanup_sub, i, BL_ALL);
+ map_foreachinmap(iMap->cleanup_sub, i, BL_ALL);
}
- ShowStatus("Cleaned up %d maps."CL_CLL"\n", map_num);
+ ShowStatus("Cleaned up %d maps."CL_CLL"\n", iMap->map_num);
id_db->foreach(id_db,cleanup_db_sub);
chrif_char_reset_offline();
chrif_flush_fifo();
-
+
atcommand->final();
battle->final();
do_final_chrif();
@@ -4954,12 +5028,12 @@ void do_final(void)
clif->final();
do_final_npc();
script->final();
- do_final_instance();
- do_final_itemdb();
- do_final_storage();
+ itemdb->final();
+ instance->final();
+ storage->final();
guild->final();
- do_final_party();
- do_final_pc();
+ party->do_final_party();
+ pc->do_final_pc();
do_final_pet();
do_final_mob();
homun->final();
@@ -4972,9 +5046,9 @@ void do_final(void)
do_final_elemental();
do_final_maps();
vending->final();
-
+
map_db->destroy(map_db, map_db_final);
-
+
mapindex_final();
if(enable_grf)
grfio_final();
@@ -4988,11 +5062,14 @@ void do_final(void)
iwall_db->destroy(iwall_db, NULL);
regen_db->destroy(regen_db, NULL);
- map_sql_close();
+ map_sql_close();
ers_destroy(map_iterator_ers);
-
+
aFree(map);
+ if( !enable_grf )
+ aFree(map_cache_buffer);
+
ShowStatus("Finished.\n");
}
@@ -5023,13 +5100,13 @@ void do_abort(void)
return;
}
ShowError("Server received crash signal! Attempting to save all online characters!\n");
- map_foreachpc(map_abort_sub);
+ iMap->map_foreachpc(map_abort_sub);
chrif_flush_fifo();
}
/*======================================================
- * Map-Server Version Screen [MC Cameri]
- *------------------------------------------------------*/
+* Map-Server Version Screen [MC Cameri]
+*------------------------------------------------------*/
static void map_helpscreen(bool do_exit)
{
ShowInfo("Usage: %s [options]\n", SERVER_NAME);
@@ -5051,8 +5128,8 @@ static void map_helpscreen(bool do_exit)
}
/*======================================================
- * Map-Server Version Screen [MC Cameri]
- *------------------------------------------------------*/
+* Map-Server Version Screen [MC Cameri]
+*------------------------------------------------------*/
static void map_versionscreen(bool do_exit) {
const char *svn = get_svn_revision();
const char *git = get_git_hash();
@@ -5107,23 +5184,23 @@ CPCMD(gm_position) {
return;
}
- if ( (m = map_mapname2mapid(map_name) <= 0 ) ) {
+ if ( (m = iMap->mapname2mapid(map_name) <= 0 ) ) {
ShowError("gm:info '"CL_WHITE"%s"CL_RESET"' is not a known map\n",map_name);
return;
}
-
+
if( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) {
ShowError("gm:info '"CL_WHITE"%d %d"CL_RESET"' is out of '"CL_WHITE"%s"CL_RESET"' map bounds!\n",x,y,map_name);
return;
}
-
+
ShowInfo("HCP: updated console's game position to '"CL_WHITE"%d %d %s"CL_RESET"'\n",x,y,map_name);
cpsd.bl.x = x;
cpsd.bl.y = y;
cpsd.bl.m = m;
}
CPCMD(gm_use) {
-
+
if( line == NULL ) {
ShowError("gm:use invalid syntax. use '"CL_WHITE"gm:use @command <optional params>"CL_RESET"'\n");
return;
@@ -5134,7 +5211,7 @@ CPCMD(gm_use) {
else
ShowInfo("HCP: '"CL_WHITE"%s"CL_RESET"' was used\n",line);
cpsd.fd = 0;
-
+
}
/* Hercules Console Parser */
void map_cp_defaults(void) {
@@ -5143,7 +5220,7 @@ void map_cp_defaults(void) {
strcpy(cpsd.status.name, "Hercules Console");
cpsd.bl.x = 150;
cpsd.bl.y = 150;
- cpsd.bl.m = map_mapname2mapid("prontera");
+ cpsd.bl.m = iMap->mapname2mapid("prontera");
console->addCommand("gm:info",CPCMD_A(gm_position));
console->addCommand("gm:use",CPCMD_A(gm_use));
@@ -5152,21 +5229,28 @@ void map_cp_defaults(void) {
void map_hp_symbols(void) {
/* full interfaces */
HPM->share(atcommand,"atcommand");
+ HPM->share(battle,"battle");
+ HPM->share(bg,"battlegrounds");
HPM->share(buyingstore,"buyingstore");
HPM->share(clif,"clif");
+ HPM->share(guild,"guild");
+ HPM->share(gstorage,"gstorage");
+ HPM->share(homun,"homun");
+ HPM->share(iMap,"iMap");
HPM->share(ircbot,"ircbot");
+ HPM->share(itemdb,"itemdb");
HPM->share(logs,"logs");
+ HPM->share(mail,"mail");
HPM->share(script,"script");
HPM->share(searchstore,"searchstore");
HPM->share(skill,"skill");
HPM->share(vending,"vending");
+ HPM->share(pc,"pc");
+ HPM->share(party,"party");
+ HPM->share(storage,"storage");
+ HPM->share(trade,"trade");
/* partial */
HPM->share(mapit,"mapit");
- HPM->share(map_foreachpc,"map_foreachpc");
- HPM->share(map_foreachmob,"map_foreachmob");
- HPM->share(map_foreachnpc,"map_foreachnpc");
- HPM->share(map_foreachregen,"map_foreachregen");
- HPM->share(map_foreachiddb,"map_foreachiddb");
/* sql link */
HPM->share(mmysql_handle,"sql_handle");
/* specific */
@@ -5175,39 +5259,30 @@ void map_hp_symbols(void) {
/* vars */
HPM->share(map,"map");
}
-/* temporary until the map.c "Hercules Renewal Phase One" design is complete. */
-void map_defaults(void) {
- mapit = &mapit_s;
-
- mapit->alloc = mapit_alloc;
- mapit->free = mapit_free;
- mapit->first = mapit_first;
- mapit->last = mapit_last;
- mapit->next = mapit_next;
- mapit->prev = mapit_prev;
- mapit->exists = mapit_exists;
- map_foreachpc = map_map_foreachpc;
- map_foreachmob = map_map_foreachmob;
- map_foreachnpc = map_map_foreachnpc;
- map_foreachregen = map_map_foreachregen;
- map_foreachiddb = map_map_foreachiddb;
-}
void load_defaults(void) {
atcommand_defaults();
battle_defaults();
+ battleground_defaults();
buyingstore_defaults();
clif_defaults();
guild_defaults();
+ gstorage_defaults();
homunculus_defaults();
+ instance_defaults();
ircbot_defaults();
+ itemdb_defaults();
log_defaults();
- map_defaults();
+ mail_defaults();
npc_defaults();
script_defaults();
searchstore_defaults();
skill_defaults();
vending_defaults();
+ pc_defaults();
+ party_defaults();
+ storage_defaults();
+ trade_defaults();
}
int do_init(int argc, char *argv[])
{
@@ -5217,113 +5292,114 @@ int do_init(int argc, char *argv[])
GC_enable_incremental();
#endif
- INTER_CONF_NAME="conf/inter-server.conf";
- LOG_CONF_NAME="conf/logs.conf";
- MAP_CONF_NAME = "conf/map-server.conf";
- BATTLE_CONF_FILENAME = "conf/battle.conf";
- ATCOMMAND_CONF_FILENAME = "conf/atcommand.conf";
- SCRIPT_CONF_NAME = "conf/script.conf";
- MSG_CONF_NAME = "conf/messages.conf";
- GRF_PATH_FILENAME = "conf/grf-files.txt";
+ map_defaults();
+ iMap->map_num = 0;
+
+ sprintf(iMap->db_path ,"db");
+ sprintf(iMap->help_txt ,"conf/help.txt");
+ sprintf(iMap->help2_txt ,"conf/help2.txt");
+ sprintf(iMap->charhelp_txt ,"conf/charhelp.txt");
+
+ sprintf(iMap->wisp_server_name ,"Server"); // can be modified in char-server configuration file
+
+ iMap->autosave_interval = DEFAULT_AUTOSAVE_INTERVAL;
+ iMap->minsave_interval = 100;
+ iMap->save_settings = 0xFFFF;
+ iMap->agit_flag = 0;
+ iMap->agit2_flag = 0;
+ iMap->night_flag = 0; // 0=day, 1=night [Yor]
+ iMap->enable_spy = 0; //To enable/disable @spy commands, which consume too much cpu time when sending packets. [Skotlex]
+
+ iMap->db_use_sqldbs = 0;
+
+ sprintf(iMap->item_db_db, "item_db");
+ sprintf(iMap->item_db2_db, "item_db2");
+ sprintf(iMap->item_db_re_db, "item_db_re");
+ sprintf(iMap->mob_db_db, "mob_db");
+ sprintf(iMap->mob_db2_db, "mob_db2");
+ sprintf(iMap->mob_skill_db_db, "mob_skill_db");
+ sprintf(iMap->mob_skill_db2_db, "mob_skill_db2");
+ sprintf(iMap->interreg_db, "interreg");
+
+ iMap->INTER_CONF_NAME="conf/inter-server.conf";
+ iMap->LOG_CONF_NAME="conf/logs.conf";
+ iMap->MAP_CONF_NAME = "conf/map-server.conf";
+ iMap->BATTLE_CONF_FILENAME = "conf/battle.conf";
+ iMap->ATCOMMAND_CONF_FILENAME = "conf/atcommand.conf";
+ iMap->SCRIPT_CONF_NAME = "conf/script.conf";
+ iMap->MSG_CONF_NAME = "conf/messages.conf";
+ iMap->GRF_PATH_FILENAME = "conf/grf-files.txt";
rnd_init();
- for( i = 1; i < argc ; i++ )
- {
+ for( i = 1; i < argc ; i++ ) {
const char* arg = argv[i];
- if( arg[0] != '-' && ( arg[0] != '/' || arg[1] == '-' ) )
- {// -, -- and /
+ if( arg[0] != '-' && ( arg[0] != '/' || arg[1] == '-' ) ) {// -, -- and /
ShowError("Unknown option '%s'.\n", argv[i]);
exit(EXIT_FAILURE);
- }
- else if( (++arg)[0] == '-' )
- {// long option
+ } else if( (++arg)[0] == '-' ) {// long option
arg++;
- if( strcmp(arg, "help") == 0 )
- {
+ if( strcmp(arg, "help") == 0 ) {
map_helpscreen(true);
- }
- else if( strcmp(arg, "version") == 0 )
- {
+ } else if( strcmp(arg, "version") == 0 ) {
map_versionscreen(true);
- }
- else if( strcmp(arg, "map-config") == 0 )
- {
+ } else if( strcmp(arg, "map-config") == 0 ) {
if( map_arg_next_value(arg, i, argc) )
- MAP_CONF_NAME = argv[++i];
- }
- else if( strcmp(arg, "battle-config") == 0 )
- {
+ iMap->MAP_CONF_NAME = argv[++i];
+ } else if( strcmp(arg, "battle-config") == 0 ) {
if( map_arg_next_value(arg, i, argc) )
- BATTLE_CONF_FILENAME = argv[++i];
- }
- else if( strcmp(arg, "atcommand-config") == 0 )
- {
+ iMap->BATTLE_CONF_FILENAME = argv[++i];
+ } else if( strcmp(arg, "atcommand-config") == 0 ) {
if( map_arg_next_value(arg, i, argc) )
- ATCOMMAND_CONF_FILENAME = argv[++i];
- }
- else if( strcmp(arg, "script-config") == 0 )
- {
+ iMap->ATCOMMAND_CONF_FILENAME = argv[++i];
+ } else if( strcmp(arg, "script-config") == 0 ) {
if( map_arg_next_value(arg, i, argc) )
- SCRIPT_CONF_NAME = argv[++i];
- }
- else if( strcmp(arg, "msg-config") == 0 )
- {
+ iMap->SCRIPT_CONF_NAME = argv[++i];
+ } else if( strcmp(arg, "msg-config") == 0 ) {
if( map_arg_next_value(arg, i, argc) )
- MSG_CONF_NAME = argv[++i];
- }
- else if( strcmp(arg, "grf-path-file") == 0 )
- {
+ iMap->MSG_CONF_NAME = argv[++i];
+ } else if( strcmp(arg, "grf-path-file") == 0 ) {
if( map_arg_next_value(arg, i, argc) )
- GRF_PATH_FILENAME = argv[++i];
- }
- else if( strcmp(arg, "inter-config") == 0 )
- {
+ iMap->GRF_PATH_FILENAME = argv[++i];
+ } else if( strcmp(arg, "inter-config") == 0 ) {
if( map_arg_next_value(arg, i, argc) )
- INTER_CONF_NAME = argv[++i];
- }
- else if( strcmp(arg, "log-config") == 0 )
- {
+ iMap->INTER_CONF_NAME = argv[++i];
+ } else if( strcmp(arg, "log-config") == 0 ) {
if( map_arg_next_value(arg, i, argc) )
- LOG_CONF_NAME = argv[++i];
- }
- else if( strcmp(arg, "run-once") == 0 ) // close the map-server as soon as its done.. for testing [Celest]
- {
+ iMap->LOG_CONF_NAME = argv[++i];
+ } else if( strcmp(arg, "run-once") == 0 ) { // close the map-server as soon as its done.. for testing [Celest]
runflag = CORE_ST_STOP;
- }
- else
- {
+ } else {
ShowError("Unknown option '%s'.\n", argv[i]);
exit(EXIT_FAILURE);
}
- }
- else switch( arg[0] )
- {// short option
- case '?':
- case 'h':
- map_helpscreen(true);
- break;
- case 'v':
- map_versionscreen(true);
- break;
- default:
- ShowError("Unknown option '%s'.\n", argv[i]);
- exit(EXIT_FAILURE);
+ } else switch( arg[0] ) {// short option
+ case '?':
+ case 'h':
+ map_helpscreen(true);
+ break;
+ case 'v':
+ map_versionscreen(true);
+ break;
+ default:
+ ShowError("Unknown option '%s'.\n", argv[i]);
+ exit(EXIT_FAILURE);
}
}
-
- CREATE(map,struct map_data,MAX_MAP_PER_SERVER);
-
+ memset(&index2mapid, -1, sizeof(index2mapid));
+
load_defaults();
-
- map_config_read(MAP_CONF_NAME);
+ map_config_read(iMap->MAP_CONF_NAME);
+ CREATE(map,struct map_data,iMap->map_num);
+ iMap->map_num = 0;
+ map_config_read_sub(iMap->MAP_CONF_NAME);
// loads npcs
- map_reloadnpc(false);
+ iMap->reloadnpc(false);
chrif_checkdefaultlogin();
-
+
if (!map_ip_set || !char_ip_set) {
char ip_str[16];
ip2str(addr_[0], ip_str);
@@ -5342,15 +5418,15 @@ int do_init(int argc, char *argv[])
if (!char_ip_set)
chrif_setip(ip_str);
}
-
- battle->config_read(BATTLE_CONF_FILENAME);
- atcommand->msg_read(MSG_CONF_NAME);
- script_config_read(SCRIPT_CONF_NAME);
- inter_config_read(INTER_CONF_NAME);
- logs->config_read(LOG_CONF_NAME);
+
+ battle->config_read(iMap->BATTLE_CONF_FILENAME);
+ atcommand->msg_read(iMap->MSG_CONF_NAME);
+ script_config_read(iMap->SCRIPT_CONF_NAME);
+ inter_config_read(iMap->INTER_CONF_NAME);
+ logs->config_read(iMap->LOG_CONF_NAME);
id_db = idb_alloc(DB_OPT_BASE);
- pc_db = idb_alloc(DB_OPT_BASE); //Added for reliable map_id2sd() use. [Skotlex]
+ pc_db = idb_alloc(DB_OPT_BASE); //Added for reliable iMap->id2sd() use. [Skotlex]
mobid_db = idb_alloc(DB_OPT_BASE); //Added to lower the load of the lazy mob ai. [Skotlex]
bossid_db = idb_alloc(DB_OPT_BASE); // Used for Convex Mirror quick MVP search
map_db = uidb_alloc(DB_OPT_BASE);
@@ -5362,42 +5438,42 @@ int do_init(int argc, char *argv[])
zone_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, MAP_ZONE_NAME_LENGTH);
map_iterator_ers = ers_new(sizeof(struct s_mapiterator),"map.c::map_iterator_ers",ERS_OPT_NONE);
-
+
map_sql_init();
if (logs->config.sql_logs)
log_sql_init();
mapindex_init();
if(enable_grf)
- grfio_init(GRF_PATH_FILENAME);
-
+ grfio_init(iMap->GRF_PATH_FILENAME);
+
map_readallmaps();
- add_timer_func_list(map_freeblock_timer, "map_freeblock_timer");
- add_timer_func_list(map_clearflooritem_timer, "map_clearflooritem_timer");
- add_timer_func_list(map_removemobs_timer, "map_removemobs_timer");
- add_timer_interval(gettick()+1000, map_freeblock_timer, 0, 0, 60*1000);
-
+ iTimer->add_timer_func_list(map_freeblock_timer, "map_freeblock_timer");
+ iTimer->add_timer_func_list(map_clearflooritem_timer, "map_clearflooritem_timer");
+ iTimer->add_timer_func_list(map_removemobs_timer, "map_removemobs_timer");
+ iTimer->add_timer_interval(iTimer->gettick()+1000, map_freeblock_timer, 0, 0, 60*1000);
+
HPM->symbol_defaults_sub = map_hp_symbols;
HPM->config_read();
HPM->event(HPET_INIT);
-
+
atcommand->init();
battle->init();
- do_init_instance();
+ instance->init();
do_init_chrif();
clif->init();
ircbot->init();
script->init();
- do_init_itemdb();
+ itemdb->init();
skill->init();
read_map_zone_db();/* read after item and skill initalization */
do_init_mob();
- do_init_pc();
+ pc->do_init_pc();
do_init_status();
- do_init_party();
+ party->do_init_party();
guild->init();
- do_init_storage();
+ storage->init();
do_init_pet();
homun->init();
do_init_mercenary();
@@ -5415,17 +5491,144 @@ int do_init(int argc, char *argv[])
ShowNotice("Server is running on '"CL_WHITE"PK Mode"CL_RESET"'.\n");
Sql_HerculesUpdateCheck(mmysql_handle);
-
+
ShowStatus("Server is '"CL_GREEN"ready"CL_RESET"' and listening on port '"CL_WHITE"%d"CL_RESET"'.\n\n", map_port);
-
+
if( runflag != CORE_ST_STOP ) {
- shutdown_callback = do_shutdown;
+ shutdown_callback = iMap->do_shutdown;
runflag = MAPSERVER_ST_RUNNING;
}
-
+
map_cp_defaults();
-
+
HPM->event(HPET_READY);
-
+
return 0;
}
+
+/*=====================================
+* Default Functions : map.h
+* Generated by HerculesInterfaceMaker
+* created by Susu
+*-------------------------------------*/
+void map_defaults(void) {
+ iMap = &iMap_s;
+
+ /* funcs */
+ iMap->zone_init = map_zone_init;
+ iMap->zone_remove = map_zone_remove;
+ iMap->zone_apply = map_zone_apply;
+ iMap->zone_change = map_zone_change;
+ iMap->zone_change2 = map_zone_change2;
+
+ iMap->getcell = map_getcell;
+ iMap->setgatcell = map_setgatcell;
+
+ iMap->cellfromcache = map_cellfromcache;
+ // users
+ iMap->setusers = map_setusers;
+ iMap->getusers = map_getusers;
+ iMap->usercount = map_usercount;
+ // blocklist lock
+ iMap->freeblock = map_freeblock;
+ iMap->freeblock_lock = map_freeblock_lock;
+ iMap->freeblock_unlock = map_freeblock_unlock;
+ // blocklist manipulation
+ iMap->addblock = map_addblock;
+ iMap->delblock = map_delblock;
+ iMap->moveblock = map_moveblock;
+ //blocklist nb in one cell
+ iMap->count_oncell = map_count_oncell;
+ iMap->find_skill_unit_oncell = map_find_skill_unit_oncell;
+ // search and creation
+ iMap->get_new_object_id = map_get_new_object_id;
+ iMap->search_freecell = map_search_freecell;
+ //
+ iMap->quit = map_quit;
+ // npc
+ iMap->addnpc = map_addnpc;
+ // map item
+ iMap->clearflooritem_timer = map_clearflooritem_timer;
+ iMap->removemobs_timer = map_removemobs_timer;
+ iMap->clearflooritem = map_clearflooritem;
+ iMap->addflooritem = map_addflooritem;
+ // player to map session
+ iMap->addnickdb = map_addnickdb;
+ iMap->delnickdb = map_delnickdb;
+ iMap->reqnickdb = map_reqnickdb;
+ iMap->charid2nick = map_charid2nick;
+ iMap->charid2sd = map_charid2sd;
+
+ iMap->id2sd = map_id2sd;
+ iMap->id2md = map_id2md;
+ iMap->id2nd = map_id2nd;
+ iMap->id2hd = map_id2hd;
+ iMap->id2mc = map_id2mc;
+ iMap->id2cd = map_id2cd;
+ iMap->id2bl = map_id2bl;
+ iMap->blid_exists = map_blid_exists;
+ iMap->mapindex2mapid = map_mapindex2mapid;
+ iMap->mapname2mapid = map_mapname2mapid;
+ iMap->mapname2ipport = map_mapname2ipport;
+ iMap->setipport = map_setipport;
+ iMap->eraseipport = map_eraseipport;
+ iMap->eraseallipport = map_eraseallipport;
+ iMap->addiddb = map_addiddb;
+ iMap->deliddb = map_deliddb;
+ /* */
+ iMap->nick2sd = map_nick2sd;
+ iMap->getmob_boss = map_getmob_boss;
+ iMap->id2boss = map_id2boss;
+ // reload config file looking only for npcs
+ iMap->reloadnpc = map_reloadnpc;
+
+ iMap->check_dir = map_check_dir;
+ iMap->calc_dir = map_calc_dir;
+ iMap->random_dir = map_random_dir; // [Skotlex]
+
+ iMap->cleanup_sub = cleanup_sub;
+
+ iMap->delmap = map_delmap;
+ iMap->flags_init = map_flags_init;
+
+ iMap->iwall_set = map_iwall_set;
+ iMap->iwall_get = map_iwall_get;
+ iMap->iwall_remove = map_iwall_remove;
+
+ iMap->addmobtolist = map_addmobtolist; // [Wizputer]
+ iMap->spawnmobs = map_spawnmobs; // [Wizputer]
+ iMap->removemobs = map_removemobs; // [Wizputer]
+ iMap->addmap2db = map_addmap2db;
+ iMap->removemapdb = map_removemapdb;
+ iMap->clean = map_clean;
+
+ iMap->do_shutdown = do_shutdown;
+
+ iMap->map_foreachpc = map_map_foreachpc;
+ iMap->map_foreachmob = map_map_foreachmob;
+ iMap->map_foreachnpc = map_map_foreachnpc;
+ iMap->map_foreachregen = map_map_foreachregen;
+ iMap->map_foreachiddb = map_map_foreachiddb;
+
+ iMap->foreachinrange = map_foreachinrange;
+ iMap->foreachinshootrange = map_foreachinshootrange;
+ iMap->foreachinarea=map_foreachinarea;
+ iMap->forcountinrange=map_forcountinrange;
+ iMap->forcountinarea=map_forcountinarea;
+ iMap->foreachinmovearea = map_foreachinmovearea;
+ iMap->foreachincell=map_foreachincell;
+ iMap->foreachinpath=map_foreachinpath;
+ iMap->foreachinmap=map_foreachinmap;
+ iMap->foreachininstance=map_foreachininstance;
+
+ /* temporary until the map.c "Hercules Renewal Phase One" design is complete. [Ind] */
+ mapit = &mapit_s;
+
+ mapit->alloc = mapit_alloc;
+ mapit->free = mapit_free;
+ mapit->first = mapit_first;
+ mapit->last = mapit_last;
+ mapit->next = mapit_next;
+ mapit->prev = mapit_prev;
+ mapit->exists = mapit_exists;
+}
diff --git a/src/map/map.h b/src/map/map.h
index 751cf62f6..1b15b477d 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -1,80 +1,65 @@
// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-
#ifndef _MAP_H_
#define _MAP_H_
-
#include "../common/cbasetypes.h"
#include "../common/core.h" // CORE_ST_LAST
#include "../common/mmo.h"
#include "../common/mapindex.h"
#include "../common/db.h"
-
#include "../config/core.h"
-
#include "atcommand.h"
-
#include <stdarg.h>
-
struct npc_data;
struct item_data;
struct hChSysCh;
-
enum E_MAPSERVER_ST {
MAPSERVER_ST_RUNNING = CORE_ST_LAST,
MAPSERVER_ST_SHUTDOWN,
MAPSERVER_ST_LAST
};
-
-
#define MAX_NPC_PER_MAP 512
#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 you need this higher.
-#define MAX_MOB_LIST_PER_MAP 128
+#define MAX_MOBSKILL 50
+#define MAX_MOB_LIST_PER_MAP 100
#define MAX_EVENTQUEUE 2
#define MAX_EVENTTIMER 32
#define NATURAL_HEAL_INTERVAL 500
#define MIN_FLOORITEM 2
#define MAX_FLOORITEM START_ACCOUNT_NUM
#define MAX_LEVEL 150
-#define MAX_DROP_PER_MAP 48
#define MAX_IGNORE_LIST 20 // official is 14
#define MAX_VENDING 12
#define MAX_MAP_SIZE 512*512 // Wasn't there something like this already? Can't find it.. [Shinryo]
-
// Added definitions for WoESE objects. [L0ne_W0lf]
enum MOBID {
- MOBID_EMPERIUM = 1288,
- MOBID_TREAS01 = 1324,
- MOBID_TREAS40 = 1363,
- MOBID_BARRICADE1 = 1905,
- MOBID_BARRICADE2,
- MOBID_GUARIDAN_STONE1,
- MOBID_GUARIDAN_STONE2,
- MOBID_FOOD_STOR,
- MOBID_BLUE_CRYST = 1914,
- MOBID_PINK_CRYST,
- MOBID_TREAS41 = 1938,
- MOBID_TREAS49 = 1946,
- MOBID_SILVERSNIPER = 2042,
- MOBID_MAGICDECOY_WIND = 2046,
+ MOBID_EMPERIUM = 1288,
+ MOBID_TREAS01 = 1324,
+ MOBID_TREAS40 = 1363,
+ MOBID_BARRICADE1 = 1905,
+ MOBID_BARRICADE2,
+ MOBID_GUARIDAN_STONE1,
+ MOBID_GUARIDAN_STONE2,
+ MOBID_FOOD_STOR,
+ MOBID_BLUE_CRYST = 1914,
+ MOBID_PINK_CRYST,
+ MOBID_TREAS41 = 1938,
+ MOBID_TREAS49 = 1946,
+ MOBID_SILVERSNIPER = 2042,
+ 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]
-//
// These marks the "level" of the job.
#define JOBL_2_1 0x100 //256
#define JOBL_2_2 0x200 //512
#define JOBL_2 0x300
-
#define JOBL_UPPER 0x1000 //4096
#define JOBL_BABY 0x2000 //8192
#define JOBL_THIRD 0x4000 //16384
-
// For filtering and quick checking.
#define MAPID_BASEMASK 0x00ff
#define MAPID_UPPERMASK 0x0fff
@@ -83,7 +68,7 @@ enum MOBID {
//Note the oddity of the novice:
//Super Novices are considered the 2-1 version of the novice! Novices are considered a first class type.
enum {
-//Novice And 1-1 Jobs
+ //Novice And 1-1 Jobs
MAPID_NOVICE = 0x0,
MAPID_SWORDMAN,
MAPID_MAGE,
@@ -98,7 +83,7 @@ enum {
MAPID_XMAS,
MAPID_SUMMER,
MAPID_GANGSI,
-//2-1 Jobs
+ //2-1 Jobs
MAPID_SUPER_NOVICE = JOBL_2_1|0x0,
MAPID_KNIGHT,
MAPID_WIZARD,
@@ -109,7 +94,7 @@ enum {
MAPID_STAR_GLADIATOR,
MAPID_KAGEROUOBORO = JOBL_2_1|0x0A,
MAPID_DEATH_KNIGHT = JOBL_2_1|0x0E,
-//2-2 Jobs
+ //2-2 Jobs
MAPID_CRUSADER = JOBL_2_2|0x1,
MAPID_SAGE,
MAPID_BARDDANCER,
@@ -118,7 +103,7 @@ enum {
MAPID_ROGUE,
MAPID_SOUL_LINKER,
MAPID_DARK_COLLECTOR = JOBL_2_2|0x0D,
-//Trans Novice And Trans 1-1 Jobs
+ //Trans Novice And Trans 1-1 Jobs
MAPID_NOVICE_HIGH = JOBL_UPPER|0x0,
MAPID_SWORDMAN_HIGH,
MAPID_MAGE_HIGH,
@@ -126,21 +111,21 @@ enum {
MAPID_ACOLYTE_HIGH,
MAPID_MERCHANT_HIGH,
MAPID_THIEF_HIGH,
-//Trans 2-1 Jobs
+ //Trans 2-1 Jobs
MAPID_LORD_KNIGHT = JOBL_UPPER|JOBL_2_1|0x1,
MAPID_HIGH_WIZARD,
MAPID_SNIPER,
MAPID_HIGH_PRIEST,
MAPID_WHITESMITH,
MAPID_ASSASSIN_CROSS,
-//Trans 2-2 Jobs
+ //Trans 2-2 Jobs
MAPID_PALADIN = JOBL_UPPER|JOBL_2_2|0x1,
MAPID_PROFESSOR,
MAPID_CLOWNGYPSY,
MAPID_CHAMPION,
MAPID_CREATOR,
MAPID_STALKER,
-//Baby Novice And Baby 1-1 Jobs
+ //Baby Novice And Baby 1-1 Jobs
MAPID_BABY = JOBL_BABY|0x0,
MAPID_BABY_SWORDMAN,
MAPID_BABY_MAGE,
@@ -148,7 +133,7 @@ enum {
MAPID_BABY_ACOLYTE,
MAPID_BABY_MERCHANT,
MAPID_BABY_THIEF,
-//Baby 2-1 Jobs
+ //Baby 2-1 Jobs
MAPID_SUPER_BABY = JOBL_BABY|JOBL_2_1|0x0,
MAPID_BABY_KNIGHT,
MAPID_BABY_WIZARD,
@@ -156,14 +141,14 @@ enum {
MAPID_BABY_PRIEST,
MAPID_BABY_BLACKSMITH,
MAPID_BABY_ASSASSIN,
-//Baby 2-2 Jobs
+ //Baby 2-2 Jobs
MAPID_BABY_CRUSADER = JOBL_BABY|JOBL_2_2|0x1,
MAPID_BABY_SAGE,
MAPID_BABY_BARDDANCER,
MAPID_BABY_MONK,
MAPID_BABY_ALCHEMIST,
MAPID_BABY_ROGUE,
-//3-1 Jobs
+ //3-1 Jobs
MAPID_SUPER_NOVICE_E = JOBL_THIRD|JOBL_2_1|0x0,
MAPID_RUNE_KNIGHT,
MAPID_WARLOCK,
@@ -171,28 +156,28 @@ enum {
MAPID_ARCH_BISHOP,
MAPID_MECHANIC,
MAPID_GUILLOTINE_CROSS,
-//3-2 Jobs
+ //3-2 Jobs
MAPID_ROYAL_GUARD = JOBL_THIRD|JOBL_2_2|0x1,
MAPID_SORCERER,
MAPID_MINSTRELWANDERER,
MAPID_SURA,
MAPID_GENETIC,
MAPID_SHADOW_CHASER,
-//Trans 3-1 Jobs
+ //Trans 3-1 Jobs
MAPID_RUNE_KNIGHT_T = JOBL_THIRD|JOBL_UPPER|JOBL_2_1|0x1,
MAPID_WARLOCK_T,
MAPID_RANGER_T,
MAPID_ARCH_BISHOP_T,
MAPID_MECHANIC_T,
MAPID_GUILLOTINE_CROSS_T,
-//Trans 3-2 Jobs
+ //Trans 3-2 Jobs
MAPID_ROYAL_GUARD_T = JOBL_THIRD|JOBL_UPPER|JOBL_2_2|0x1,
MAPID_SORCERER_T,
MAPID_MINSTRELWANDERER_T,
MAPID_SURA_T,
MAPID_GENETIC_T,
MAPID_SHADOW_CHASER_T,
-//Baby 3-1 Jobs
+ //Baby 3-1 Jobs
MAPID_SUPER_BABY_E = JOBL_THIRD|JOBL_BABY|JOBL_2_1|0x0,
MAPID_BABY_RUNE,
MAPID_BABY_WARLOCK,
@@ -200,7 +185,7 @@ enum {
MAPID_BABY_BISHOP,
MAPID_BABY_MECHANIC,
MAPID_BABY_CROSS,
-//Baby 3-2 Jobs
+ //Baby 3-2 Jobs
MAPID_BABY_GUARD = JOBL_THIRD|JOBL_BABY|JOBL_2_2|0x1,
MAPID_BABY_SORCERER,
MAPID_BABY_MINSTRELWANDERER,
@@ -208,7 +193,6 @@ enum {
MAPID_BABY_GENETIC,
MAPID_BABY_CHASER,
};
-
// 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'
@@ -220,20 +204,18 @@ enum {
#define CHAT_SIZE_MAX (255 + 1)
// 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
-#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)
+#define map_flag_vs(m) (map[m].flag.pvp || map[m].flag.gvg_dungeon || map[m].flag.gvg || ((iMap->agit_flag || iMap->agit2_flag) && map[m].flag.gvg_castle) || map[m].flag.battleground)
// 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)
+#define map_flag_gvg(m) (map[m].flag.gvg || ((iMap->agit_flag || iMap->agit2_flag) && map[m].flag.gvg_castle))
+// Specifies if the map is tagged as GvG/WoE (regardless of iMap->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 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]
+//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]
enum bl_type {
BL_NUL = 0x000,
BL_PC = 0x001,
@@ -328,8 +310,8 @@ struct spawn_data {
struct {
unsigned int size : 2; //Holds if mob has to be tiny/large
unsigned int ai : 4; //Special ai for summoned monsters.
- //0: Normal mob | 1: Standard summon, attacks mobs
- //2: Alchemist Marine Sphere | 3: Alchemist Summon Flora | 4: Summon Zanzou
+ //0: Normal mob | 1: Standard summon, attacks mobs
+ //2: Alchemist Marine Sphere | 3: Alchemist Summon Flora | 4: Summon Zanzou
unsigned int dynamic : 1; //Whether this data is indexed by a map's dynamic mob list
unsigned int boss : 1; //0: Non-boss monster | 1: Boss monster
} state;
@@ -404,7 +386,7 @@ enum _sp {
SP_SUBSIZE, SP_HP_DRAIN_VALUE_RACE, SP_ADD_ITEM_HEAL_RATE, SP_SP_DRAIN_VALUE_RACE, SP_EXP_ADDRACE, // 2026-2030
SP_SP_GAIN_RACE, SP_SUBRACE2, SP_UNBREAKABLE_SHOES, // 2031-2033
SP_UNSTRIPABLE_WEAPON,SP_UNSTRIPABLE_ARMOR,SP_UNSTRIPABLE_HELM,SP_UNSTRIPABLE_SHIELD, // 2034-2037
- SP_INTRAVISION, SP_ADD_MONSTER_DROP_ITEMGROUP, SP_SP_LOSS_RATE, // 2038-2040
+ SP_INTRAVISION, SP_ADD_MONSTER_DROP_CHAINITEM, SP_SP_LOSS_RATE, // 2038-2040
SP_ADD_SKILL_BLOW, SP_SP_VANISH_RATE, SP_MAGIC_SP_GAIN_VALUE, SP_MAGIC_HP_GAIN_VALUE, SP_ADD_CLASS_DROP_ITEM, //2041-2045
SP_EMATK, SP_SP_GAIN_RACE_ATTACK, SP_HP_GAIN_RACE_ATTACK, SP_SKILL_USE_SP_RATE, //2046-2049
SP_SKILL_COOLDOWN,SP_SKILL_FIXEDCAST, SP_SKILL_VARIABLECAST, SP_FIXCASTRATE, SP_VARCASTRATE, //2050-2054
@@ -443,7 +425,7 @@ typedef enum {
} cell_t;
-// used by map_getcell()
+// used by iMap->getcell()
typedef enum {
CELL_GETTYPE, // retrieves a cell's 'gat' type
@@ -471,19 +453,19 @@ struct mapcell
{
// terrain flags
unsigned char
- walkable : 1,
- shootable : 1,
- water : 1;
+walkable : 1,
+shootable : 1,
+water : 1;
// dynamic flags
unsigned char
- npc : 1,
- basilica : 1,
- landprotector : 1,
- novending : 1,
- nochat : 1,
- maelstrom : 1,
- icewall : 1;
+npc : 1,
+basilica : 1,
+landprotector : 1,
+novending : 1,
+nochat : 1,
+maelstrom : 1,
+icewall : 1;
#ifdef CELL_NOSTACK
unsigned char cell_bl; //Holds amount of bls in this cell.
@@ -506,7 +488,7 @@ enum map_zone_skill_subtype {
MZS_NONE = 0x0,
MZS_CLONE = 0x01,
MZS_BOSS = 0x02,
-
+
MZS_ALL = 0xFFF,
};
@@ -549,15 +531,16 @@ struct map_zone_data {
struct map_zone_skill_damage_cap_entry **capped_skills;
int capped_skills_count;
};
-void map_zone_init(void);
-void map_zone_remove(int m);
-void map_zone_apply(int m, struct map_zone_data *zone, const char* start, const char* buffer, const char* filepath);
-void map_zone_change(int m, struct map_zone_data *zone, const char* start, const char* buffer, const char* filepath);
-void map_zone_change2(int m, struct map_zone_data *zone);
struct map_zone_data map_zone_all;/* used as a base on all maps */
struct map_zone_data map_zone_pk;/* used for (pk_mode) */
+struct map_drop_list {
+ int drop_id;
+ int drop_type;
+ int drop_per;
+};
+
struct map_data {
char name[MAP_NAME_LENGTH];
@@ -625,11 +608,8 @@ struct map_data {
} flag;
struct point save;
struct npc_data *npc[MAX_NPC_PER_MAP];
- struct {
- int drop_id;
- int drop_type;
- int drop_per;
- } drop_list[MAX_DROP_PER_MAP];
+ struct map_drop_list *drop_list;
+ unsigned short drop_list_count;
struct spawn_data *moblist[MAX_MOB_LIST_PER_MAP]; // [Wizputer]
int mob_delete_timer; // [Skotlex]
@@ -637,35 +617,35 @@ struct map_data {
int bexp; // map experience multiplicator
int nocommand; //Blocks @/# commands for non-gms. [Skotlex]
/**
- * Ice wall reference counter for bugreport:3574
- * - since there are a thounsand mobs out there in a lot of maps checking on,
- * - every targetting for icewall on attack path would just be a waste, so,
- * - this counter allows icewall checking be only run when there is a actual ice wall on the map
- **/
+ * Ice wall reference counter for bugreport:3574
+ * - since there are a thounsand mobs out there in a lot of maps checking on,
+ * - every targetting for icewall on attack path would just be a waste, so,
+ * - this counter allows icewall checking be only run when there is a actual ice wall on the map
+ **/
int icewall_num;
// Instance Variables
int instance_id;
int instance_src_map;
-
+
/* adjust_unit_duration mapflag */
struct mapflag_skill_adjust **units;
unsigned short unit_count;
/* adjust_skill_damage mapflag */
struct mapflag_skill_adjust **skills;
unsigned short skill_count;
-
+
/* Hercules nocast db overhaul */
struct map_zone_data *zone;
char **zone_mf;/* used to store this map's zone mapflags that should be re-applied once zone is removed */
unsigned short zone_mf_count;
struct map_zone_data *prev_zone;
-
+
/* Hercules Local Chat */
struct hChSysCh *channel;
-
+
/* invincible_time_inc mapflag */
unsigned int invincible_time_inc;
-
+
/* weapon_damage_rate mapflag */
unsigned short weapon_damage_rate;
/* magic_damage_rate mapflag */
@@ -676,6 +656,14 @@ struct map_data {
unsigned short short_damage_rate;
/* long_damage_rate mapflag */
unsigned short long_damage_rate;
+
+ /* instance unique name */
+ char *cName;
+
+ /* */
+ int (*getcellp)(struct map_data* m,int16 x,int16 y,cell_chk cellchk);
+ void (*setcell) (int16 m, int16 x, int16 y, cell_t cell, bool flag);
+ char *cellPos;
};
/// Stores information about a remote map (for multi-mapserver setups).
@@ -688,111 +676,35 @@ struct map_data_other_server {
uint16 port;
};
-int map_getcell(int16 m,int16 x,int16 y,cell_chk cellchk);
-int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk);
-void map_setcell(int16 m, int16 x, int16 y, cell_t cell, bool flag);
-void map_setgatcell(int16 m, int16 x, int16 y, int gat);
struct map_data *map;
-extern int map_num;
-
-extern int autosave_interval;
-extern int minsave_interval;
-extern int save_settings;
-extern int agit_flag;
-extern int agit2_flag;
-extern int night_flag; // 0=day, 1=night [Yor]
-extern int enable_spy; //Determines if @spy commands are active.
-extern char db_path[256];
-
-extern char help_txt[];
-extern char help2_txt[];
-extern char charhelp_txt[];
-
-extern char wisp_server_name[];
-
-// users
-void map_setusers(int);
-int map_getusers(void);
-int map_usercount(void);
-
-// blocklist lock
-int map_freeblock(struct block_list *bl);
-int map_freeblock_lock(void);
-int map_freeblock_unlock(void);
-// blocklist manipulation
-int map_addblock(struct block_list* bl);
-int map_delblock(struct block_list* bl);
-int map_moveblock(struct block_list *, int, int, unsigned int);
-int map_foreachinrange(int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int type, ...);
-int map_foreachinshootrange(int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int type, ...);
-int map_foreachinarea(int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int type, ...);
-int map_forcountinrange(int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int count, int type, ...);
-int map_forcountinarea(int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int count, int type, ...);
-int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int16 dx, int16 dy, int type, ...);
-int map_foreachincell(int (*func)(struct block_list*,va_list), int16 m, int16 x, int16 y, int type, ...);
-int map_foreachinpath(int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int16 range, int length, int type, ...);
-int map_foreachinmap(int (*func)(struct block_list*,va_list), int16 m, int type, ...);
-//blocklist nb in one cell
-int map_count_oncell(int16 m,int16 x,int16 y,int type);
-struct skill_unit *map_find_skill_unit_oncell(struct block_list *,int16 x,int16 y,uint16 skill_id,struct skill_unit *, int flag);
-// search and creation
-int map_get_new_object_id(void);
-int map_search_freecell(struct block_list *src, int16 m, int16 *x, int16 *y, int16 rx, int16 ry, int flag);
+
+
+
+
+
+
+//int map_foreachinrange(int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int type, ...);
+//int map_foreachinshootrange(int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int type, ...);
+//int map_foreachinarea(int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int type, ...);
+//int map_forcountinrange(int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int count, int type, ...);
+//int map_forcountinarea(int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int count, int type, ...);
+//int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int16 dx, int16 dy, int type, ...);
+//int map_foreachincell(int (*func)(struct block_list*,va_list), int16 m, int16 x, int16 y, int type, ...);
+//int map_foreachinpath(int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int16 range, int length, int type, ...);
+//int map_foreachinmap(int (*func)(struct block_list*,va_list), int16 m, int type, ...);
+//int map_foreachininstance(int (*func)(struct block_list*,va_list), int16 instance_id, int type,...);
//
-int map_quit(struct map_session_data *);
-// npc
-bool map_addnpc(int16 m,struct npc_data *);
-
-// map item
-int map_clearflooritem_timer(int tid, unsigned int tick, int id, intptr_t data);
-int map_removemobs_timer(int tid, unsigned int tick, int id, intptr_t data);
-void map_clearflooritem(struct block_list* bl);
-int map_addflooritem(struct item *item_data,int amount,int16 m,int16 x,int16 y,int first_charid,int second_charid,int third_charid,int flags);
-
-// player to map session
-void map_addnickdb(int charid, const char* nick);
-void map_delnickdb(int charid, const char* nick);
-void map_reqnickdb(struct map_session_data* sd,int charid);
-const char* map_charid2nick(int charid);
-struct map_session_data* map_charid2sd(int charid);
-
-struct map_session_data * map_id2sd(int id);
-struct mob_data * map_id2md(int id);
-struct npc_data * map_id2nd(int id);
-struct homun_data* map_id2hd(int id);
-struct mercenary_data* map_id2mc(int id);
-struct chat_data* map_id2cd(int id);
-struct block_list * map_id2bl(int id);
-bool map_blid_exists( int id );
+
+
+
#define map_id2index(id) map[(id)].index
-int16 map_mapindex2mapid(unsigned short mapindex);
-int16 map_mapname2mapid(const char* name);
-int map_mapname2ipport(unsigned short name, uint32* ip, uint16* port);
-int map_setipport(unsigned short map, uint32 ip, uint16 port);
-int map_eraseipport(unsigned short map, uint32 ip, uint16 port);
-int map_eraseallipport(void);
-void map_addiddb(struct block_list *);
-void map_deliddb(struct block_list *bl);
-/* temporary until the map.c "Hercules Renewal Phase One" design is complete. */
-void (*map_foreachpc) (int (*func)(struct map_session_data* sd, va_list args), ...);
-void (*map_foreachmob) (int (*func)(struct mob_data* md, va_list args), ...);
-void (*map_foreachnpc) (int (*func)(struct npc_data* nd, va_list args), ...);
-void (*map_foreachregen) (int (*func)(struct block_list* bl, va_list args), ...);
-void (*map_foreachiddb) (int (*func)(struct block_list* bl, va_list args), ...);
-/* */
-struct map_session_data * map_nick2sd(const char*);
-struct mob_data * map_getmob_boss(int16 m);
-struct mob_data * map_id2boss(int id);
-
-// reload config file looking only for npcs
-void map_reloadnpc(bool clear);
/// Bitfield of flags for the iterator.
enum e_mapitflags {
MAPIT_NORMAL = 0,
-// MAPIT_PCISPLAYING = 1,// Unneeded as pc_db/id_db will only hold auth'ed, active players.
+ // MAPIT_PCISPLAYING = 1,// Unneeded as pc_db/id_db will only hold auth'ed, active players.
};
struct s_mapiterator;
/* temporary until the map.c "Hercules Renewal Phase One" design is complete. */
@@ -812,34 +724,11 @@ struct mapit_interface *mapit;
#define mapit_geteachnpc() mapit->alloc(MAPIT_NORMAL,BL_NPC)
#define mapit_geteachiddb() mapit->alloc(MAPIT_NORMAL,BL_ALL)
-int map_check_dir(int s_dir,int t_dir);
-uint8 map_calc_dir( struct block_list *src,int16 x,int16 y);
-int map_random_dir(struct block_list *bl, short *x, short *y); // [Skotlex]
-int cleanup_sub(struct block_list *bl, va_list ap);
-int map_delmap(char* mapname);
-void map_flags_init(void);
-bool map_iwall_set(int16 m, int16 x, int16 y, int size, int8 dir, bool shootable, const char* wall_name);
-void map_iwall_get(struct map_session_data *sd);
-void map_iwall_remove(const char *wall_name);
-int map_addmobtolist(unsigned short m, struct spawn_data *spawn); // [Wizputer]
-void map_spawnmobs(int16 m); // [Wizputer]
-void map_removemobs(int16 m); // [Wizputer]
-void do_reconnect_map(void); //Invoked on map-char reconnection [Skotlex]
-void map_addmap2db(struct map_data *m);
-void map_removemapdb(struct map_data *m);
-extern char *INTER_CONF_NAME;
-extern char *LOG_CONF_NAME;
-extern char *MAP_CONF_NAME;
-extern char *BATTLE_CONF_FILENAME;
-extern char *ATCOMMAND_CONF_FILENAME;
-extern char *SCRIPT_CONF_NAME;
-extern char *MSG_CONF_NAME;
-extern char *GRF_PATH_FILENAME;
//Useful typedefs from jA [Skotlex]
typedef struct map_session_data TBL_PC;
@@ -858,19 +747,168 @@ typedef struct elemental_data TBL_ELEM;
#include "../common/sql.h"
-extern int db_use_sqldbs;
extern Sql* mmysql_handle;
extern Sql* logmysql_handle;
-extern char item_db_db[32];
-extern char item_db2_db[32];
-extern char item_db_re_db[32];
-extern char mob_db_db[32];
-extern char mob_db2_db[32];
-extern char mob_skill_db_db[32];
-extern char mob_skill_db2_db[32];
-void do_shutdown(void);
+
+/*=====================================
+* Interface : map.h
+* Generated by HerculesInterfaceMaker
+* created by Susu
+*-------------------------------------*/
+struct map_interface {
+
+ /* vars */
+ int map_num;
+
+ int autosave_interval;
+ int minsave_interval;
+ int save_settings;
+ int agit_flag;
+ int agit2_flag;
+ int night_flag; // 0=day, 1=night [Yor]
+ int enable_spy; //Determines if @spy commands are active.
+ char db_path[256];
+
+ char help_txt[256];
+ char help2_txt[256];
+ char charhelp_txt[256];
+
+ char wisp_server_name[NAME_LENGTH];
+
+ char *INTER_CONF_NAME;
+ char *LOG_CONF_NAME;
+ char *MAP_CONF_NAME;
+ char *BATTLE_CONF_FILENAME;
+ char *ATCOMMAND_CONF_FILENAME;
+ char *SCRIPT_CONF_NAME;
+ char *MSG_CONF_NAME;
+ char *GRF_PATH_FILENAME;
+
+ int db_use_sqldbs;
+
+ char item_db_db[32];
+ char item_db2_db[32];
+ char item_db_re_db[32];
+ char mob_db_db[32];
+ char mob_db2_db[32];
+ char mob_skill_db_db[32];
+ char mob_skill_db2_db[32];
+ char interreg_db[32];
+
+ /* funcs */
+ void (*zone_init) (void);
+ void (*zone_remove) (int m);
+ void (*zone_apply) (int m, struct map_zone_data *zone, const char* start, const char* buffer, const char* filepath);
+ void (*zone_change) (int m, struct map_zone_data *zone, const char* start, const char* buffer, const char* filepath);
+ void (*zone_change2) (int m, struct map_zone_data *zone);
+
+ int (*getcell) (int16 m,int16 x,int16 y,cell_chk cellchk);
+ void (*setgatcell) (int16 m, int16 x, int16 y, int gat);
+
+ void (*cellfromcache) (struct map_data *m);
+ // users
+ void (*setusers) (int);
+ int (*getusers) (void);
+ int (*usercount) (void);
+ // blocklist lock
+ int (*freeblock) (struct block_list *bl);
+ int (*freeblock_lock) (void);
+ int (*freeblock_unlock) (void);
+ // blocklist manipulation
+ int (*addblock) (struct block_list* bl);
+ int (*delblock) (struct block_list* bl);
+ int (*moveblock) (struct block_list *, int, int, unsigned int);
+ //blocklist nb in one cell
+ int (*count_oncell) (int16 m,int16 x,int16 y,int type);
+ struct skill_unit * (*find_skill_unit_oncell) (struct block_list *,int16 x,int16 y,uint16 skill_id,struct skill_unit *, int flag);
+ // search and creation
+ int (*get_new_object_id) (void);
+ int (*search_freecell) (struct block_list *src, int16 m, int16 *x, int16 *y, int16 rx, int16 ry, int flag);
+ //
+ int (*quit) (struct map_session_data *);
+ // npc
+ bool (*addnpc) (int16 m,struct npc_data *);
+ // map item
+ int (*clearflooritem_timer) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*removemobs_timer) (int tid, unsigned int tick, int id, intptr_t data);
+ void (*clearflooritem) (struct block_list* bl);
+ int (*addflooritem) (struct item *item_data,int amount,int16 m,int16 x,int16 y,int first_charid,int second_charid,int third_charid,int flags);
+ // player to map session
+ void (*addnickdb) (int charid, const char* nick);
+ void (*delnickdb) (int charid, const char* nick);
+ void (*reqnickdb) (struct map_session_data* sd,int charid);
+ const char* (*charid2nick) (int charid);
+ struct map_session_data* (*charid2sd) (int charid);
+
+ void (*map_foreachpc) (int (*func)(struct map_session_data* sd, va_list args), ...);
+ void (*map_foreachmob) (int (*func)(struct mob_data* md, va_list args), ...);
+ void (*map_foreachnpc) (int (*func)(struct npc_data* nd, va_list args), ...);
+ void (*map_foreachregen) (int (*func)(struct block_list* bl, va_list args), ...);
+ void (*map_foreachiddb) (int (*func)(struct block_list* bl, va_list args), ...);
+
+ int (*foreachinrange) (int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int type, ...);
+ int (*foreachinshootrange) (int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int type, ...);
+ int (*foreachinarea) (int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int type, ...);
+ int (*forcountinrange) (int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int count, int type, ...);
+ int (*forcountinarea) (int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int count, int type, ...);
+ int (*foreachinmovearea) (int (*func)(struct block_list*,va_list), struct block_list* center, int16 range, int16 dx, int16 dy, int type, ...);
+ int (*foreachincell) (int (*func)(struct block_list*,va_list), int16 m, int16 x, int16 y, int type, ...);
+ int (*foreachinpath) (int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int16 range, int length, int type, ...);
+ int (*foreachinmap) (int (*func)(struct block_list*,va_list), int16 m, int type, ...);
+ int (*foreachininstance)(int (*func)(struct block_list*,va_list), int16 instance_id, int type,...);
+
+ struct map_session_data * (*id2sd) (int id);
+ struct mob_data * (*id2md) (int id);
+ struct npc_data * (*id2nd) (int id);
+ struct homun_data* (*id2hd) (int id);
+ struct mercenary_data* (*id2mc) (int id);
+ struct chat_data* (*id2cd) (int id);
+ struct block_list * (*id2bl) (int id);
+ bool (*blid_exists) (int id);
+ int16 (*mapindex2mapid) (unsigned short mapindex);
+ int16 (*mapname2mapid) (const char* name);
+ int (*mapname2ipport) (unsigned short name, uint32* ip, uint16* port);
+ int (*setipport) (unsigned short map, uint32 ip, uint16 port);
+ int (*eraseipport) (unsigned short map, uint32 ip, uint16 port);
+ int (*eraseallipport) (void);
+ void (*addiddb) (struct block_list *);
+ void (*deliddb) (struct block_list *bl);
+ /* */
+ struct map_session_data * (*nick2sd) (const char*);
+ struct mob_data * (*getmob_boss) (int16 m);
+ struct mob_data * (*id2boss) (int id);
+ // reload config file looking only for npcs
+ void (*reloadnpc) (bool clear);
+
+ int (*check_dir) (int s_dir,int t_dir);
+ uint8 (*calc_dir) (struct block_list *src,int16 x,int16 y);
+ int (*random_dir) (struct block_list *bl, short *x, short *y); // [Skotlex]
+
+ int (*cleanup_sub) (struct block_list *bl, va_list ap);
+
+ int (*delmap) (char* mapname);
+ void (*flags_init) (void);
+
+ bool (*iwall_set) (int16 m, int16 x, int16 y, int size, int8 dir, bool shootable, const char* wall_name);
+ void (*iwall_get) (struct map_session_data *sd);
+ void (*iwall_remove) (const char *wall_name);
+
+ int (*addmobtolist) (unsigned short m, struct spawn_data *spawn); // [Wizputer]
+ void (*spawnmobs) (int16 m); // [Wizputer]
+ void (*removemobs) (int16 m); // [Wizputer]
+ void (*do_reconnect_map) (void); //Invoked on map-char reconnection [Skotlex] Note used but still keeping it, just in case
+ void (*addmap2db) (struct map_data *m);
+ void (*removemapdb) (struct map_data *m);
+ void (*clean) (int i);
+
+ void (*do_shutdown) (void);
+} iMap_s;
+
+struct map_interface *iMap;
+
+void map_defaults(void);
#endif /* _MAP_H_ */
diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c
index 484da5641..b6865c8fd 100644
--- a/src/map/mapreg_sql.c
+++ b/src/map/mapreg_sql.c
@@ -140,25 +140,25 @@ static void script_load_mapreg(void) {
| varname | index | value |
+-------------------------+
*/
- SqlStmt* stmt = SqlStmt_Malloc(mmysql_handle);
+ SqlStmt* stmt = SQL->StmtMalloc(mmysql_handle);
char varname[32+1];
int index;
char value[255+1];
uint32 length;
- if ( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `varname`, `index`, `value` FROM `%s`", mapreg_table)
- || SQL_ERROR == SqlStmt_Execute(stmt)
+ if ( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `varname`, `index`, `value` FROM `%s`", mapreg_table)
+ || SQL_ERROR == SQL->StmtExecute(stmt)
) {
SqlStmt_ShowDebug(stmt);
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
return;
}
- SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &varname[0], sizeof(varname), &length, NULL);
- SqlStmt_BindColumn(stmt, 1, SQLDT_INT, &index, 0, NULL, NULL);
- SqlStmt_BindColumn(stmt, 2, SQLDT_STRING, &value[0], sizeof(value), NULL, NULL);
+ SQL->StmtBindColumn(stmt, 0, SQLDT_STRING, &varname[0], sizeof(varname), &length, NULL);
+ SQL->StmtBindColumn(stmt, 1, SQLDT_INT, &index, 0, NULL, NULL);
+ SQL->StmtBindColumn(stmt, 2, SQLDT_STRING, &value[0], sizeof(value), NULL, NULL);
- while ( SQL_SUCCESS == SqlStmt_NextRow(stmt) ) {
+ while ( SQL_SUCCESS == SQL->StmtNextRow(stmt) ) {
struct mapreg_save *m = NULL;
int s = add_str(varname);
int i = index;
@@ -187,7 +187,7 @@ static void script_load_mapreg(void) {
}
}
- SqlStmt_Free(stmt);
+ SQL->StmtFree(stmt);
mapreg_i_dirty = false;
mapreg_str_dirty = false;
@@ -302,8 +302,8 @@ void mapreg_init(void) {
script_load_mapreg();
- add_timer_func_list(script_autosave_mapreg, "script_autosave_mapreg");
- add_timer_interval(gettick() + MAPREG_AUTOSAVE_INTERVAL, script_autosave_mapreg, 0, 0, MAPREG_AUTOSAVE_INTERVAL);
+ iTimer->add_timer_func_list(script_autosave_mapreg, "script_autosave_mapreg");
+ iTimer->add_timer_interval(iTimer->gettick() + MAPREG_AUTOSAVE_INTERVAL, script_autosave_mapreg, 0, 0, MAPREG_AUTOSAVE_INTERVAL);
}
bool mapreg_config_read(const char* w1, const char* w2) {
diff --git a/src/map/mercenary.c b/src/map/mercenary.c
index 02fcea891..566f68409 100644
--- a/src/map/mercenary.c
+++ b/src/map/mercenary.c
@@ -93,8 +93,8 @@ int mercenary_get_lifetime(struct mercenary_data *md)
if( md == NULL || md->contract_timer == INVALID_TIMER )
return 0;
- td = get_timer(md->contract_timer);
- return (td != NULL) ? DIFF_TICK(td->tick, gettick()) : 0;
+ td = iTimer->get_timer(md->contract_timer);
+ return (td != NULL) ? DIFF_TICK(td->tick, iTimer->gettick()) : 0;
}
int mercenary_get_guild(struct mercenary_data *md)
@@ -222,7 +222,7 @@ static int merc_contract_end(int tid, unsigned int tick, int id, intptr_t data)
struct map_session_data *sd;
struct mercenary_data *md;
- if( (sd = map_id2sd(id)) == NULL )
+ if( (sd = iMap->id2sd(id)) == NULL )
return 1;
if( (md = sd->md) == NULL )
return 1;
@@ -269,14 +269,14 @@ void merc_contract_stop(struct mercenary_data *md)
{
nullpo_retv(md);
if( md->contract_timer != INVALID_TIMER )
- delete_timer(md->contract_timer, merc_contract_end);
+ iTimer->delete_timer(md->contract_timer, merc_contract_end);
md->contract_timer = INVALID_TIMER;
}
void merc_contract_init(struct mercenary_data *md)
{
if( md->contract_timer == INVALID_TIMER )
- md->contract_timer = add_timer(gettick() + md->mercenary.life_time, merc_contract_end, md->master->bl.id, 0);
+ md->contract_timer = iTimer->add_timer(iTimer->gettick() + md->mercenary.life_time, merc_contract_end, md->master->bl.id, 0);
md->regen.state.block = 0;
}
@@ -288,7 +288,7 @@ int merc_data_received(struct s_mercenary *merc, bool flag)
struct s_mercenary_db *db;
int i = merc_search_index(merc->class_);
- if( (sd = map_charid2sd(merc->char_id)) == NULL )
+ if( (sd = iMap->charid2sd(merc->char_id)) == NULL )
return 0;
if( !flag || i < 0 )
{ // Not created - loaded - DB info
@@ -319,7 +319,7 @@ int merc_data_received(struct s_mercenary *merc, bool flag)
md->bl.x = md->ud.to_x;
md->bl.y = md->ud.to_y;
- map_addiddb(&md->bl);
+ iMap->addiddb(&md->bl);
status_calc_mercenary(md,1);
md->contract_timer = INVALID_TIMER;
merc_contract_init(md);
@@ -336,7 +336,7 @@ int merc_data_received(struct s_mercenary *merc, bool flag)
if( md && md->bl.prev == NULL && sd->bl.prev != NULL )
{
- map_addblock(&md->bl);
+ iMap->addblock(&md->bl);
clif->spawn(&md->bl);
clif->mercenary_info(sd);
clif->mercenary_skillblock(sd);
@@ -361,7 +361,7 @@ int mercenary_dead(struct mercenary_data *md)
int mercenary_killbonus(struct mercenary_data *md)
{
- const enum sc_type scs[] = { SC_MERC_FLEEUP, SC_MERC_ATKUP, SC_MERC_HPUP, SC_MERC_SPUP, SC_MERC_HITUP };
+ const enum sc_type scs[] = { SC_MER_FLEE, SC_MER_ATK, SC_MER_HP, SC_MER_SP, SC_MER_HIT };
int index = rnd() % ARRAYLENGTH(scs);
sc_start(&md->bl, scs[index], 100, rnd() % 5, 600000);
@@ -456,7 +456,7 @@ static bool read_mercenarydb_sub(char* str[], int columns, int current)
int read_mercenarydb(void)
{
memset(mercenary_db,0,sizeof(mercenary_db));
- sv->readdb(db_path, "mercenary_db.txt", ',', 26, 26, MAX_MERCENARY_CLASS, &read_mercenarydb_sub);
+ sv->readdb(iMap->db_path, "mercenary_db.txt", ',', 26, 26, MAX_MERCENARY_CLASS, &read_mercenarydb_sub);
return 0;
}
@@ -494,7 +494,7 @@ static bool read_mercenary_skilldb_sub(char* str[], int columns, int current)
int read_mercenary_skilldb(void)
{
- sv->readdb(db_path, "mercenary_skill_db.txt", ',', 3, 3, -1, &read_mercenary_skilldb_sub);
+ sv->readdb(iMap->db_path, "mercenary_skill_db.txt", ',', 3, 3, -1, &read_mercenary_skilldb_sub);
return 0;
}
diff --git a/src/map/mob.c b/src/map/mob.c
index 57325ba1c..3f282bf7e 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -137,7 +137,7 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time)
nd->bl.id = md->tomb_nid = npc_get_new_npc_id();
- nd->ud.dir = md->ud.dir;
+ nd->dir = md->ud.dir;
nd->bl.m = md->bl.m;
nd->bl.x = md->bl.x;
nd->bl.y = md->bl.y;
@@ -157,11 +157,9 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time)
else
nd->u.tomb.killer_name[0] = '\0';
- map_addnpc(nd->bl.m, nd);
- map_addblock(&nd->bl);
+ iMap->addnpc(nd->bl.m, nd);
+ iMap->addblock(&nd->bl);
status_set_viewdata(&nd->bl, nd->class_);
- status_change_init(&nd->bl);
- unit_dataset(&nd->bl);
clif->spawn(&nd->bl);
}
@@ -169,14 +167,14 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time)
void mvptomb_destroy(struct mob_data *md) {
struct npc_data *nd;
- if ( (nd = map_id2nd(md->tomb_nid)) ) {
+ if ( (nd = iMap->id2nd(md->tomb_nid)) ) {
int16 m, i;
m = nd->bl.m;
clif->clearunit_area(&nd->bl,CLR_OUTSIGHT);
- map_delblock(&nd->bl);
+ iMap->delblock(&nd->bl);
ARR_FIND( 0, map[m].npc_num, i, map[m].npc[i] == nd );
if( !(i == map[m].npc_num) ) {
@@ -185,7 +183,7 @@ void mvptomb_destroy(struct mob_data *md) {
map[m].npc[map[m].npc_num] = NULL;
}
- map_deliddb(&nd->bl);
+ iMap->deliddb(&nd->bl);
aFree(nd);
}
@@ -262,8 +260,7 @@ int mob_parse_dataset(struct spawn_data *data)
/*==========================================
* Generates the basic mob data using the spawn_data provided.
*------------------------------------------*/
-struct mob_data* mob_spawn_dataset(struct spawn_data *data)
-{
+struct mob_data* mob_spawn_dataset(struct spawn_data *data) {
struct mob_data *md = (struct mob_data*)aCalloc(1, sizeof(struct mob_data));
md->bl.id= npc_get_new_npc_id();
md->bl.type = BL_MOB;
@@ -290,8 +287,8 @@ struct mob_data* mob_spawn_dataset(struct spawn_data *data)
status_set_viewdata(&md->bl, md->class_);
status_change_init(&md->bl);
unit_dataset(&md->bl);
-
- map_addiddb(&md->bl);
+
+ iMap->addiddb(&md->bl);
return md;
}
@@ -347,7 +344,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target)
*t_sd; // Mob Target
struct status_change_entry *sce;
struct mob_data *md;
- unsigned int tick = gettick();
+ unsigned int tick = iTimer->gettick();
char output[128];
if( !battle_config.ksprotection )
@@ -362,7 +359,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target)
if( !(sd = BL_CAST(BL_PC,s_bl)) )
return false; // Master is not PC
- t_bl = map_id2bl(md->target_id);
+ t_bl = iMap->id2bl(md->target_id);
if( !t_bl || (s_bl = battle->get_master(t_bl)) == NULL )
s_bl = t_bl;
@@ -389,7 +386,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target)
(sce->val2 == 3 && sce->val4 && sce->val4 != t_sd->status.guild_id)) )
break;
- if( (pl_sd = map_id2sd(sce->val1)) == NULL || pl_sd->bl.m != md->bl.m )
+ if( (pl_sd = iMap->id2sd(sce->val1)) == NULL || pl_sd->bl.m != md->bl.m )
break;
if( !pl_sd->state.noks )
@@ -445,11 +442,11 @@ struct mob_data *mob_once_spawn_sub(struct block_list *bl, int16 m, int16 x, int
// Locate spot next to player.
if (bl && (x < 0 || y < 0))
- map_search_freecell(bl, m, &x, &y, 1, 1, 0);
+ iMap->search_freecell(bl, m, &x, &y, 1, 1, 0);
// if none found, pick random position on map
- if (x <= 0 || y <= 0 || map_getcell(m,x,y,CELL_CHKNOREACH))
- map_search_freecell(NULL, m, &x, &y, -1, -1, 1);
+ if (x <= 0 || y <= 0 || iMap->getcell(m,x,y,CELL_CHKNOREACH))
+ iMap->search_freecell(NULL, m, &x, &y, -1, -1, 1);
data.x = x;
data.y = y;
@@ -497,7 +494,7 @@ int mob_once_spawn(struct map_session_data* sd, int16 m, int16 x, int16 y, const
memcpy(md->guardian_data->guild_name, g->name, NAME_LENGTH);
}
else if (gc->guild_id) //Guild not yet available, retry in 5.
- add_timer(gettick()+5000,mob_spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id);
+ iTimer->add_timer(iTimer->gettick()+5000,mob_spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id);
}
} // end addition [Valaris]
@@ -545,7 +542,7 @@ int mob_once_spawn_area(struct map_session_data* sd, int16 m, int16 x0, int16 y0
x = rnd()%(x1-x0+1)+x0;
y = rnd()%(y1-y0+1)+y0;
j++;
- } while (map_getcell(m,x,y,CELL_CHKNOPASS) && j < max);
+ } while (iMap->getcell(m,x,y,CELL_CHKNOPASS) && j < max);
if (j == max)
{// attempt to find an available cell failed
@@ -571,7 +568,7 @@ int mob_once_spawn_area(struct map_session_data* sd, int16 m, int16 x0, int16 y0
*------------------------------------------*/
static int mob_spawn_guardian_sub(int tid, unsigned int tick, int id, intptr_t data)
{ //Needed because the guild_data may not be available at guardian spawn time.
- struct block_list* bl = map_id2bl(id);
+ struct block_list* bl = iMap->id2bl(id);
struct mob_data* md;
struct guild* g;
int guardup_lv;
@@ -629,7 +626,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam
memset(&data, 0, sizeof(struct spawn_data));
data.num = 1;
- m=map_mapname2mapid(mapname);
+ m=iMap->mapname2mapid(mapname);
if(m<0)
{
@@ -655,7 +652,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam
return 0;
}
- if((x<=0 || y<=0) && !map_search_freecell(NULL, m, &x, &y, -1,-1, 1))
+ if((x<=0 || y<=0) && !iMap->search_freecell(NULL, m, &x, &y, -1,-1, 1))
{
ShowWarning("mob_spawn_guardian: Couldn't locate a spawn cell for guardian class %d (index %d) at castle map %s\n",class_, guardian, map[m].name);
return 0;
@@ -680,7 +677,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam
if( has_index && gc->guardian[guardian].id )
{ //Check if guardian already exists, refuse to spawn if so.
- struct mob_data *md2 = (TBL_MOB*)map_id2bl(gc->guardian[guardian].id);
+ struct mob_data *md2 = (TBL_MOB*)iMap->id2bl(gc->guardian[guardian].id);
if (md2 && md2->bl.type == BL_MOB &&
md2->guardian_data && md2->guardian_data->number == guardian)
{
@@ -715,7 +712,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam
memcpy (md->guardian_data->guild_name, g->name, NAME_LENGTH);
md->guardian_data->guardup_lv = guild->checkskill(g,GD_GUARDUP);
} else if (md->guardian_data->guild_id)
- add_timer(gettick()+5000,mob_spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id);
+ iTimer->add_timer(iTimer->gettick()+5000,mob_spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id);
mob_spawn(md);
return md->bl.id;
@@ -730,7 +727,7 @@ int mob_spawn_bg(const char* mapname, short x, short y, const char* mobname, int
struct spawn_data data;
int16 m;
- if( (m = map_mapname2mapid(mapname)) < 0 )
+ if( (m = iMap->mapname2mapid(mapname)) < 0 )
{
ShowWarning("mob_spawn_bg: Map [%s] not found.\n", mapname);
return 0;
@@ -746,7 +743,7 @@ int mob_spawn_bg(const char* mapname, short x, short y, const char* mobname, int
}
data.class_ = class_;
- if( (x <= 0 || y <= 0) && !map_search_freecell(NULL, m, &x, &y, -1,-1, 1) )
+ if( (x <= 0 || y <= 0) && !iMap->search_freecell(NULL, m, &x, &y, -1,-1, 1) )
{
ShowWarning("mob_spawn_bg: Couldn't locate a spawn cell for guardian class %d (bg_id %d) at map %s\n",class_, bg_id, map[m].name);
return 0;
@@ -827,7 +824,7 @@ int mob_linksearch(struct block_list *bl,va_list ap)
*------------------------------------------*/
int mob_delayspawn(int tid, unsigned int tick, int id, intptr_t data)
{
- struct block_list* bl = map_id2bl(id);
+ struct block_list* bl = iMap->id2bl(id);
struct mob_data* md = BL_CAST(BL_MOB, bl);
if( md )
@@ -879,8 +876,8 @@ int mob_setdelayspawn(struct mob_data *md)
spawntime = 5000;
if( md->spawn_timer != INVALID_TIMER )
- delete_timer(md->spawn_timer, mob_delayspawn);
- md->spawn_timer = add_timer(gettick()+spawntime, mob_delayspawn, md->bl.id, 0);
+ iTimer->delete_timer(md->spawn_timer, mob_delayspawn);
+ md->spawn_timer = iTimer->add_timer(iTimer->gettick()+spawntime, mob_delayspawn, md->bl.id, 0);
return 0;
}
@@ -901,7 +898,7 @@ int mob_count_sub(struct block_list *bl, va_list ap) {
int mob_spawn (struct mob_data *md)
{
int i=0;
- unsigned int tick = gettick();
+ unsigned int tick = iTimer->gettick();
int c =0;
md->last_thinktime = tick;
@@ -923,19 +920,19 @@ int mob_spawn (struct mob_data *md)
if( (md->bl.x == 0 && md->bl.y == 0) || md->spawn->xs || md->spawn->ys )
{ //Monster can be spawned on an area.
- if( !map_search_freecell(&md->bl, -1, &md->bl.x, &md->bl.y, md->spawn->xs, md->spawn->ys, battle_config.no_spawn_on_player?4:0) )
+ if( !iMap->search_freecell(&md->bl, -1, &md->bl.x, &md->bl.y, md->spawn->xs, md->spawn->ys, battle_config.no_spawn_on_player?4:0) )
{ // retry again later
if( md->spawn_timer != INVALID_TIMER )
- delete_timer(md->spawn_timer, mob_delayspawn);
- md->spawn_timer = add_timer(tick+5000,mob_delayspawn,md->bl.id,0);
+ iTimer->delete_timer(md->spawn_timer, mob_delayspawn);
+ md->spawn_timer = iTimer->add_timer(tick+5000,mob_delayspawn,md->bl.id,0);
return 1;
}
}
- else if( battle_config.no_spawn_on_player > 99 && map_foreachinrange(mob_count_sub, &md->bl, AREA_SIZE, BL_PC) )
+ else if( battle_config.no_spawn_on_player > 99 && iMap->foreachinrange(mob_count_sub, &md->bl, AREA_SIZE, BL_PC) )
{ // retry again later (players on sight)
if( md->spawn_timer != INVALID_TIMER )
- delete_timer(md->spawn_timer, mob_delayspawn);
- md->spawn_timer = add_timer(tick+5000,mob_delayspawn,md->bl.id,0);
+ iTimer->delete_timer(md->spawn_timer, mob_delayspawn);
+ md->spawn_timer = iTimer->add_timer(tick+5000,mob_delayspawn,md->bl.id,0);
return 1;
}
}
@@ -949,7 +946,7 @@ int mob_spawn (struct mob_data *md)
md->ud.target_to = 0;
if( md->spawn_timer != INVALID_TIMER )
{
- delete_timer(md->spawn_timer, mob_delayspawn);
+ iTimer->delete_timer(md->spawn_timer, mob_delayspawn);
md->spawn_timer = INVALID_TIMER;
}
@@ -982,7 +979,7 @@ int mob_spawn (struct mob_data *md)
if ( md->tomb_nid )
mvptomb_destroy(md);
- map_addblock(&md->bl);
+ iMap->addblock(&md->bl);
if( map[md->bl.m].users )
clif->spawn(&md->bl);
skill->unit_move(&md->bl,tick,1);
@@ -1209,7 +1206,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick)
{
struct block_list *bl;
- bl=map_id2bl(md->master_id);
+ bl=iMap->id2bl(md->master_id);
if (!bl || status_isdead(bl)) {
status_kill(&md->bl);
@@ -1245,7 +1242,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick)
{
short x = bl->x, y = bl->y;
mob_stop_attack(md);
- if(map_search_freecell(&md->bl, bl->m, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 1)
+ if(iMap->search_freecell(&md->bl, bl->m, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 1)
&& unit_walktoxy(&md->bl, x, y, 0))
return 1;
}
@@ -1264,9 +1261,9 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick)
if (ud) {
struct block_list *tbl=NULL;
if (ud->target && ud->state.attack_continue)
- tbl=map_id2bl(ud->target);
+ tbl=iMap->id2bl(ud->target);
else if (ud->skilltarget) {
- tbl = map_id2bl(ud->skilltarget);
+ tbl = iMap->id2bl(ud->skilltarget);
//Required check as skilltarget is not always an enemy. [Skotlex]
if (tbl && battle->check_target(&md->bl, tbl, BCT_ENEMY) <= 0)
tbl = NULL;
@@ -1351,7 +1348,7 @@ int mob_randomwalk(struct mob_data *md,unsigned int tick)
x+=md->bl.x;
y+=md->bl.y;
- if((map_getcell(md->bl.m,x,y,CELL_CHKPASS)) && unit_walktoxy(&md->bl,x,y,1)){
+ if((iMap->getcell(md->bl.m,x,y,CELL_CHKPASS)) && unit_walktoxy(&md->bl,x,y,1)){
break;
}
}
@@ -1388,11 +1385,11 @@ int mob_warpchase(struct mob_data *md, struct block_list *target)
return 0; //No need to do a warp chase.
if (md->ud.walktimer != INVALID_TIMER &&
- map_getcell(md->bl.m,md->ud.to_x,md->ud.to_y,CELL_CHKNPC))
+ iMap->getcell(md->bl.m,md->ud.to_x,md->ud.to_y,CELL_CHKNPC))
return 1; //Already walking to a warp.
//Search for warps within mob's viewing range.
- map_foreachinrange (mob_warpchase_sub, &md->bl,
+ iMap->foreachinrange (mob_warpchase_sub, &md->bl,
md->db->range2, BL_NPC, target, &warp, &distance);
if (warp && unit_walktobl(&md->bl, &warp->bl, 1, 1))
@@ -1440,7 +1437,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
if (md->target_id)
{ //Check validity of current target. [Skotlex]
- tbl = map_id2bl(md->target_id);
+ tbl = iMap->id2bl(md->target_id);
if (!tbl || tbl->m != md->bl.m ||
(md->ud.attacktimer == INVALID_TIMER && !status_check_skilluse(&md->bl, tbl, 0, 0)) ||
(md->ud.walktimer != INVALID_TIMER && !(battle_config.mob_ai&0x1) && !check_distance_bl(&md->bl, tbl, md->min_chase)) ||
@@ -1464,7 +1461,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
if( !battle->check_range(&md->bl, tbl, md->status.rhw.range)
&& ( //Can't attack back and can't reach back.
(!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0 && (battle_config.mob_ai&0x2 || (md->sc.data[SC_SPIDERWEB] && md->sc.data[SC_SPIDERWEB]->val1)
- || md->sc.data[SC_BITE] || md->sc.data[SC_VACUUM_EXTREME] || md->sc.data[SC_THORNSTRAP]
+ || md->sc.data[SC_WUGBITE] || md->sc.data[SC_VACUUM_EXTREME] || md->sc.data[SC_THORNS_TRAP]
|| md->sc.data[SC__MANHOLE])) // Not yet confirmed if boss will teleport once it can't reach target.
|| !mob_can_reach(md, tbl, md->min_chase, MSS_RUSH)
)
@@ -1477,7 +1474,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
}
}
else
- if( (abl = map_id2bl(md->attacked_id)) && (!tbl || mob_can_changetarget(md, abl, mode)) )
+ if( (abl = iMap->id2bl(md->attacked_id)) && (!tbl || mob_can_changetarget(md, abl, mode)) )
{
int dist;
if( md->bl.m != abl->m || abl->prev == NULL
@@ -1487,7 +1484,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
|| (!battle->check_range(&md->bl, abl, md->status.rhw.range) // Not on Melee Range and ...
&& ( // Reach check
(!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0 && (battle_config.mob_ai&0x2 || (md->sc.data[SC_SPIDERWEB] && md->sc.data[SC_SPIDERWEB]->val1)
- || md->sc.data[SC_BITE] || md->sc.data[SC_VACUUM_EXTREME] || md->sc.data[SC_THORNSTRAP]
+ || md->sc.data[SC_WUGBITE] || md->sc.data[SC_VACUUM_EXTREME] || md->sc.data[SC_THORNS_TRAP]
|| md->sc.data[SC__MANHOLE])) // Not yet confirmed if boss will teleport once it can't reach target.
|| !mob_can_reach(md, abl, dist+md->db->range3, MSS_RUSH)
)
@@ -1536,19 +1533,19 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
if (!tbl && mode&MD_LOOTER && md->lootitem && DIFF_TICK(tick, md->ud.canact_tick) > 0 &&
(md->lootitem_count < LOOTITEM_SIZE || battle_config.monster_loot_type != 1))
{ // Scan area for items to loot, avoid trying to loot if the mob is full and can't consume the items.
- map_foreachinrange (mob_ai_sub_hard_lootsearch, &md->bl, view_range, BL_ITEM, md, &tbl);
+ iMap->foreachinrange (mob_ai_sub_hard_lootsearch, &md->bl, view_range, BL_ITEM, md, &tbl);
}
if ((!tbl && mode&MD_AGGRESSIVE) || md->state.skillstate == MSS_FOLLOW)
{
- map_foreachinrange (mob_ai_sub_hard_activesearch, &md->bl, view_range, DEFAULT_ENEMY_TYPE(md), md, &tbl, mode);
+ iMap->foreachinrange (mob_ai_sub_hard_activesearch, &md->bl, view_range, DEFAULT_ENEMY_TYPE(md), md, &tbl, mode);
}
else
if (mode&MD_CHANGECHASE && (md->state.skillstate == MSS_RUSH || md->state.skillstate == MSS_FOLLOW))
{
int search_size;
search_size = view_range<md->status.rhw.range ? view_range:md->status.rhw.range;
- map_foreachinrange (mob_ai_sub_hard_changechase, &md->bl, search_size, DEFAULT_ENEMY_TYPE(md), md, &tbl);
+ iMap->foreachinrange (mob_ai_sub_hard_changechase, &md->bl, search_size, DEFAULT_ENEMY_TYPE(md), md, &tbl);
}
if (!tbl) { //No targets available.
@@ -1559,7 +1556,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
if( md->bg_id && mode&MD_CANATTACK ) {
if( md->ud.walktimer != INVALID_TIMER )
return true;/* we are already moving */
- map_foreachinrange (mob_ai_sub_hard_bg_ally, &md->bl, view_range, BL_PC, md, &tbl, mode);
+ iMap->foreachinrange (mob_ai_sub_hard_bg_ally, &md->bl, view_range, BL_PC, md, &tbl, mode);
if( tbl ) {
if( distance_blxy(&md->bl, tbl->x, tbl->y) <= 3 || unit_walktobl(&md->bl, tbl, 1, 1) )
return true;/* we're moving or close enough don't unlock the target. */
@@ -1619,7 +1616,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
unit_set_walkdelay(&md->bl, tick, md->status.amotion, 1);
}
//Clear item.
- map_clearflooritem (tbl);
+ iMap->clearflooritem (tbl);
mob_unlocktarget (md,tick);
return true;
}
@@ -1689,7 +1686,7 @@ static int mob_ai_sub_foreachclient(struct map_session_data *sd,va_list ap)
{
unsigned int tick;
tick=va_arg(ap,unsigned int);
- map_foreachinrange(mob_ai_sub_hard_timer,&sd->bl, AREA_SIZE+ACTIVE_AI_RANGE, BL_MOB,tick);
+ iMap->foreachinrange(mob_ai_sub_hard_timer,&sd->bl, AREA_SIZE+ACTIVE_AI_RANGE, BL_MOB,tick);
return 0;
}
@@ -1768,7 +1765,7 @@ static int mob_ai_sub_lazy(struct mob_data *md, va_list args)
*------------------------------------------*/
static int mob_ai_lazy(int tid, unsigned int tick, int id, intptr_t data)
{
- map_foreachmob(mob_ai_sub_lazy,tick);
+ iMap->map_foreachmob(mob_ai_sub_lazy,tick);
return 0;
}
@@ -1779,9 +1776,9 @@ static int mob_ai_hard(int tid, unsigned int tick, int id, intptr_t data)
{
if (battle_config.mob_ai&0x20)
- map_foreachmob(mob_ai_sub_lazy,tick);
+ iMap->map_foreachmob(mob_ai_sub_lazy,tick);
else
- map_foreachpc(mob_ai_sub_foreachclient,tick);
+ iMap->map_foreachpc(mob_ai_sub_foreachclient,tick);
return 0;
}
@@ -1820,7 +1817,7 @@ static int mob_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data
list=(struct item_drop_list *)data;
ditem = list->item;
while (ditem) {
- map_addflooritem(&ditem->item_data,ditem->item_data.amount,
+ iMap->addflooritem(&ditem->item_data,ditem->item_data.amount,
list->m,list->x,list->y,
list->first_charid,list->second_charid,list->third_charid,0);
ditem_prev = ditem;
@@ -1844,12 +1841,12 @@ static void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, str
//Logs items, dropped by mobs [Lupus]
logs->pick_mob(md, loot?LOG_TYPE_LOOT:LOG_TYPE_PICKDROP_MONSTER, -ditem->item_data.amount, &ditem->item_data, NULL);
- sd = map_charid2sd(dlist->first_charid);
- if( sd == NULL ) sd = map_charid2sd(dlist->second_charid);
- if( sd == NULL ) sd = map_charid2sd(dlist->third_charid);
+ sd = iMap->charid2sd(dlist->first_charid);
+ if( sd == NULL ) sd = iMap->charid2sd(dlist->second_charid);
+ if( sd == NULL ) sd = iMap->charid2sd(dlist->third_charid);
if( sd
- && (drop_rate <= sd->state.autoloot || pc_isautolooting(sd, ditem->item_data.nameid))
+ && (drop_rate <= sd->state.autoloot || pc->isautolooting(sd, ditem->item_data.nameid))
&& (battle_config.idle_no_autoloot == 0 || DIFF_TICK(last_tick, sd->idletime) < battle_config.idle_no_autoloot)
&& (battle_config.homunculus_autoloot?1:!flag)
#ifdef AUTOLOOT_DISTANCE
@@ -1857,7 +1854,7 @@ static void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, str
&& check_distance_blxy(&sd->bl, dlist->x, dlist->y, AUTOLOOT_DISTANCE)
#endif
) { //Autoloot.
- if (party_share_loot(party_search(sd->status.party_id),
+ if (party->share_loot(party->search(sd->status.party_id),
sd, &ditem->item_data, sd->status.char_id) == 0
) {
ers_free(item_drop_ers, ditem);
@@ -1870,7 +1867,7 @@ static void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, str
int mob_timer_delete(int tid, unsigned int tick, int id, intptr_t data)
{
- struct block_list* bl = map_id2bl(id);
+ struct block_list* bl = iMap->id2bl(id);
struct mob_data* md = BL_CAST(BL_MOB, bl);
if( md )
@@ -1911,13 +1908,13 @@ int mob_deleteslave(struct mob_data *md)
{
nullpo_ret(md);
- map_foreachinmap(mob_deleteslave_sub, md->bl.m, BL_MOB,md->bl.id);
+ iMap->foreachinmap(mob_deleteslave_sub, md->bl.m, BL_MOB,md->bl.id);
return 0;
}
// Mob respawning through KAIZEL or NPC_REBIRTH [Skotlex]
int mob_respawn(int tid, unsigned int tick, int id, intptr_t data)
{
- struct block_list *bl = map_id2bl(id);
+ struct block_list *bl = iMap->id2bl(id);
if(!bl) return 0;
status_revive(bl, (uint8)data, 0);
@@ -1981,7 +1978,7 @@ void mob_log_damage(struct mob_data *md, struct block_list *src, int damage)
struct mob_data* md2 = (TBL_MOB*)src;
if( md2->special_state.ai && md2->master_id )
{
- struct map_session_data* msd = map_id2sd(md2->master_id);
+ struct map_session_data* msd = iMap->id2sd(md2->master_id);
if( msd )
char_id = msd->status.char_id;
}
@@ -2057,7 +2054,7 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage) {
//Log damage
if (src)
mob_log_damage(md, src, damage);
- md->dmgtick = gettick();
+ md->dmgtick = iTimer->gettick();
}
if (battle_config.show_mob_info&3)
@@ -2071,7 +2068,7 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage) {
int i;
for(i = 0; i < DAMAGELOG_SIZE; i++){ // must show hp bar to all char who already hit the mob.
if( md->dmglog[i].id ) {
- struct map_session_data *sd = map_charid2sd(md->dmglog[i].id);
+ struct map_session_data *sd = iMap->charid2sd(md->dmglog[i].id);
if( sd && check_distance_bl(&md->bl, &sd->bl, AREA_SIZE) ) // check if in range
clif->monster_hp_bar(md,sd);
}
@@ -2081,7 +2078,7 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage) {
if( md->special_state.ai == 2 ) {//LOne WOlf explained that ANYONE can trigger the marine countdown skill. [Skotlex]
md->state.alchemist = 1;
- mobskill_use(md, gettick(), MSC_ALCHEMIST);
+ mobskill_use(md, iTimer->gettick(), MSC_ALCHEMIST);
}
}
@@ -2102,7 +2099,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
} pt[DAMAGELOG_SIZE];
int i, temp, count, m = md->bl.m, pnum = 0;
int dmgbltypes = 0; // bitfield of all bl types, that caused damage to the mob and are elligible for exp distribution
- unsigned int mvp_damage, tick = gettick();
+ unsigned int mvp_damage, tick = iTimer->gettick();
bool rebirth, homkillonly;
status = &md->status;
@@ -2122,7 +2119,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
mobskill_use(md,tick,-1);
}
- map_freeblock_lock();
+ iMap->freeblock_lock();
memset(pt,0,sizeof(pt));
@@ -2133,7 +2130,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
memset(tmpsd,0,sizeof(tmpsd));
for(i = 0, count = 0, mvp_damage = 0; i < DAMAGELOG_SIZE && md->dmglog[i].id; i++)
{
- struct map_session_data* tsd = map_charid2sd(md->dmglog[i].id);
+ struct map_session_data* tsd = iMap->charid2sd(md->dmglog[i].id);
if(tsd == NULL)
continue; // skip empty entries
@@ -2192,7 +2189,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
else
ARR_FIND(0, MAX_PC_FEELHATE, i, temp == sd->hate_mob[i] &&
(battle_config.allow_skill_without_day || sg_info[i].day_func()));
- if(i<MAX_PC_FEELHATE && (temp=pc_checkskill(sd,sg_info[i].bless_id)))
+ if(i<MAX_PC_FEELHATE && (temp=pc->checkskill(sd,sg_info[i].bless_id)))
bonus += (i==2?20:10)*temp;
}
if(battle_config.mobs_level_up && md->level > md->db->lv) // [Valaris]
@@ -2258,7 +2255,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
for( j = 0; j < pnum && pt[j].id != temp; j++ ); //Locate party.
if( j == pnum ){ //Possibly add party.
- pt[pnum].p = party_search(temp);
+ pt[pnum].p = party->search(temp);
if(pt[pnum].p && pt[pnum].p->party.exp) {
pt[pnum].id = temp;
pt[pnum].base_exp = base_exp;
@@ -2288,20 +2285,20 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
if(base_exp || job_exp) {
if( md->dmglog[i].flag != MDLF_PET || battle_config.pet_attack_exp_to_master ) {
#ifdef RENEWAL_EXP
- int rate = pc_level_penalty_mod(tmpsd[i], md, 1);
+ int rate = pc->level_penalty_mod(tmpsd[i], md, 1);
base_exp = (unsigned int)cap_value(base_exp * rate / 100, 1, UINT_MAX);
job_exp = (unsigned int)cap_value(job_exp * rate / 100, 1, UINT_MAX);
#endif
- pc_gainexp(tmpsd[i], &md->bl, base_exp, job_exp, false);
+ pc->gainexp(tmpsd[i], &md->bl, base_exp, job_exp, false);
}
}
if(zeny) // zeny from mobs [Valaris]
- pc_getzeny(tmpsd[i], zeny, LOG_TYPE_PICKDROP_MONSTER, NULL);
+ pc->getzeny(tmpsd[i], zeny, LOG_TYPE_PICKDROP_MONSTER, NULL);
}
}
for( i = 0; i < pnum; i++ ) //Party share.
- party_exp_share(pt[i].p, &md->bl, pt[i].base_exp,pt[i].job_exp,pt[i].zeny);
+ party->exp_share(pt[i].p, &md->bl, pt[i].base_exp,pt[i].job_exp,pt[i].zeny);
} //End EXP giving.
@@ -2316,9 +2313,9 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
struct item_data* it = NULL;
int drop_rate;
#ifdef RENEWAL_DROP
- int drop_modifier = mvp_sd ? pc_level_penalty_mod(mvp_sd, md, 2) :
- second_sd ? pc_level_penalty_mod(second_sd, md, 2):
- third_sd ? pc_level_penalty_mod(third_sd, md, 2) :
+ int drop_modifier = mvp_sd ? pc->level_penalty_mod(mvp_sd, md, 2) :
+ second_sd ? pc->level_penalty_mod(second_sd, md, 2):
+ third_sd ? pc->level_penalty_mod(third_sd, md, 2) :
100;/* no player was attached, we dont use any modifier (100 = rates are not touched) */
#endif
dlist->m = md->bl.m;
@@ -2333,7 +2330,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
{
if (md->db->dropitem[i].nameid <= 0)
continue;
- if ( !(it = itemdb_exists(md->db->dropitem[i].nameid)) )
+ if ( !(it = itemdb->exists(md->db->dropitem[i].nameid)) )
continue;
drop_rate = md->db->dropitem[i].p;
if (drop_rate <= 0) {
@@ -2363,9 +2360,9 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
(int)(md->level - sd->status.base_level) >= 20)
drop_rate = (int)(drop_rate*1.25); // pk_mode increase drops if 20 level difference [Valaris]
- // Increase drop rate if user has SC_ITEMBOOST
- if (sd && sd->sc.data[SC_ITEMBOOST]) // now rig the drop rate to never be over 90% unless it is originally >90%.
- drop_rate = max(drop_rate,cap_value((int)(0.5+drop_rate*(sd->sc.data[SC_ITEMBOOST]->val1)/100.),0,9000));
+ // Increase drop rate if user has SC_CASH_RECEIVEITEM
+ if (sd && sd->sc.data[SC_CASH_RECEIVEITEM]) // now rig the drop rate to never be over 90% unless it is originally >90%.
+ drop_rate = max(drop_rate,cap_value((int)(0.5+drop_rate*(sd->sc.data[SC_CASH_RECEIVEITEM]->val1)/100.),0,9000));
#ifdef RENEWAL_DROP
if( drop_modifier != 100 ) {
drop_rate = drop_rate * drop_modifier / 100;
@@ -2397,9 +2394,11 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
}
// Ore Discovery [Celest]
- if (sd == mvp_sd && pc_checkskill(sd,BS_FINDINGORE)>0 && battle_config.finding_ore_rate/10 >= rnd()%10000) {
- ditem = mob_setdropitem(itemdb_searchrandomid(IG_FINDINGORE), 1, NULL);
- mob_item_drop(md, dlist, ditem, 0, battle_config.finding_ore_rate/10, homkillonly);
+ if (sd == mvp_sd && pc->checkskill(sd,BS_FINDINGORE) > 0) {
+ if( (temp = itemdb->chain_item(itemdb->chain_cache[ECC_ORE],&i)) ) {
+ ditem = mob_setdropitem(temp, 1, NULL);
+ mob_item_drop(md, dlist, ditem, 0, i, homkillonly);
+ }
}
if(sd) {
@@ -2427,8 +2426,9 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
if (rnd()%10000 >= drop_rate)
continue;
- itemid = (sd->add_drop[i].id > 0) ? sd->add_drop[i].id : itemdb_searchrandomid(sd->add_drop[i].group);
- mob_item_drop(md, dlist, mob_setdropitem(itemid,1,NULL), 0, drop_rate, homkillonly);
+ itemid = (sd->add_drop[i].id > 0) ? sd->add_drop[i].id : itemdb->chain_item(sd->add_drop[i].group,&drop_rate);
+ if( itemid )
+ mob_item_drop(md, dlist, mob_setdropitem(itemid,1,NULL), 0, drop_rate, homkillonly);
}
}
@@ -2436,7 +2436,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
if( sd->bonus.get_zeny_num && rnd()%100 < sd->bonus.get_zeny_rate ) {
i = sd->bonus.get_zeny_num > 0 ? sd->bonus.get_zeny_num : -md->level * sd->bonus.get_zeny_num;
if (!i) i = 1;
- pc_getzeny(sd, 1+rnd()%i, LOG_TYPE_PICKDROP_MONSTER, NULL);
+ pc->getzeny(sd, 1+rnd()%i, LOG_TYPE_PICKDROP_MONSTER, NULL);
}
}
@@ -2446,7 +2446,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
mob_item_drop(md, dlist, mob_setlootitem(&md->lootitem[i]), 1, 10000, homkillonly);
}
if (dlist->item) //There are drop items.
- add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob_delay_item_drop, 0, (intptr_t)dlist);
+ iTimer->add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob_delay_item_drop, 0, (intptr_t)dlist);
else //No drops
ers_free(item_drop_list_ers, dlist);
} else if (md->lootitem && md->lootitem_count) { //Loot MUST drop!
@@ -2460,7 +2460,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
dlist->item = NULL;
for(i = 0; i < md->lootitem_count; i++)
mob_item_drop(md, dlist, mob_setlootitem(&md->lootitem[i]), 1, 10000, homkillonly);
- add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob_delay_item_drop, 0, (intptr_t)dlist);
+ iTimer->add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob_delay_item_drop, 0, (intptr_t)dlist);
}
if(mvp_sd && md->db->mexp > 0 && !md->special_state.ai) {
@@ -2482,7 +2482,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
clif->mvp_effect(mvp_sd);
clif->mvp_exp(mvp_sd,mexp);
- pc_gainexp(mvp_sd, &md->bl, mexp,0, false);
+ pc->gainexp(mvp_sd, &md->bl, mexp,0, false);
log_mvp[1] = mexp;
if( !(map[m].flag.nomvploot || type&1) ) {
@@ -2507,7 +2507,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
struct item_data *data;
if(mdrop_id[i] <= 0)
continue;
- if(! (data = itemdb_exists(mdrop_id[i])) )
+ if(! (data = itemdb->exists(mdrop_id[i])) )
continue;
temp = mdrop_p[i];
@@ -2530,9 +2530,9 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
intif_broadcast(message,strlen(message)+1,0);
}
- if((temp = pc_additem(mvp_sd,&item,1,LOG_TYPE_PICKDROP_PLAYER)) != 0) {
+ if((temp = pc->additem(mvp_sd,&item,1,LOG_TYPE_PICKDROP_PLAYER)) != 0) {
clif->additem(mvp_sd,0,0,temp);
- map_addflooritem(&item,1,mvp_sd->bl.m,mvp_sd->bl.x,mvp_sd->bl.y,mvp_sd->status.char_id,(second_sd?second_sd->status.char_id:0),(third_sd?third_sd->status.char_id:0),1);
+ iMap->addflooritem(&item,1,mvp_sd->bl.m,mvp_sd->bl.x,mvp_sd->bl.y,mvp_sd->status.char_id,(second_sd?second_sd->status.char_id:0),(third_sd?third_sd->status.char_id:0),1);
}
//Logs items, MVP prizes [Lupus]
@@ -2563,7 +2563,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
if( sd ) {
if( sd->mission_mobid == md->class_) { //TK_MISSION [Skotlex]
if( ++sd->mission_count >= 100 && (temp = mob_get_random_id(0, 0xE, sd->status.base_level)) ) {
- pc_addfame(sd, 1);
+ pc->addfame(sd, 1);
sd->mission_mobid = temp;
pc_setglobalreg(sd,"TK_MISSION_ID", temp);
sd->mission_count = 0;
@@ -2573,7 +2573,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
}
if( sd->status.party_id )
- map_foreachinrange(quest_update_objective_sub,&md->bl,AREA_SIZE,BL_PC,sd->status.party_id,md->class_);
+ iMap->foreachinrange(quest_update_objective_sub,&md->bl,AREA_SIZE,BL_PC,sd->status.party_id,md->class_);
else if( sd->avail_quests )
quest_update_objective(sd, md->class_);
@@ -2583,15 +2583,15 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
if( md->npc_event[0] && !md->state.npc_killmonster ) {
if( sd && battle_config.mob_npc_event_type ) {
- pc_setparam(sd, SP_KILLERRID, sd->bl.id);
+ pc->setparam(sd, SP_KILLERRID, sd->bl.id);
npc_event(sd,md->npc_event,0);
} else if( mvp_sd ) {
- pc_setparam(mvp_sd, SP_KILLERRID, sd?sd->bl.id:0);
+ pc->setparam(mvp_sd, SP_KILLERRID, sd?sd->bl.id:0);
npc_event(mvp_sd,md->npc_event,0);
} else
npc_event_do(md->npc_event);
} else if( mvp_sd && !md->state.npc_killmonster ) {
- pc_setparam(mvp_sd, SP_KILLEDRID, md->class_);
+ pc->setparam(mvp_sd, SP_KILLEDRID, md->class_);
npc_script_event(mvp_sd, NPCE_KILLNPC); // PCKillNPC [Lance]
}
@@ -2599,7 +2599,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
}
if(md->deletetimer != INVALID_TIMER) {
- delete_timer(md->deletetimer,mob_timer_delete);
+ iTimer->delete_timer(md->deletetimer,mob_timer_delete);
md->deletetimer = INVALID_TIMER;
}
/**
@@ -2608,7 +2608,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
if( md->can_summon )
mob_deleteslave(md);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
if( !rebirth ) {
@@ -2641,7 +2641,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
void mob_revive(struct mob_data *md, unsigned int hp)
{
- unsigned int tick = gettick();
+ unsigned int tick = iTimer->gettick();
md->state.skillstate = MSS_IDLE;
md->last_thinktime = tick;
md->next_walktime = tick+rnd()%50+5000;
@@ -2650,7 +2650,7 @@ void mob_revive(struct mob_data *md, unsigned int hp)
memset(md->dmglog, 0, sizeof(md->dmglog)); // Reset the damage done on the rebirthed monster, otherwise will grant full exp + damage done. [Valaris]
md->tdmg = 0;
if (!md->bl.prev)
- map_addblock(&md->bl);
+ iMap->addblock(&md->bl);
clif->spawn(&md->bl);
skill->unit_move(&md->bl,tick,1);
mobskill_use(md, tick, MSC_SPAWN);
@@ -2726,7 +2726,7 @@ int mob_random_class (int *value, size_t count)
*------------------------------------------*/
int mob_class_change (struct mob_data *md, int class_)
{
- unsigned int tick = gettick();
+ unsigned int tick = iTimer->gettick();
int i, c, hp_rate;
nullpo_ret(md);
@@ -2812,7 +2812,7 @@ int mob_warpslave_sub(struct block_list *bl,va_list ap)
if(md->master_id!=master->id)
return 0;
- map_search_freecell(master, 0, &x, &y, range, range, 0);
+ iMap->search_freecell(master, 0, &x, &y, range, range, 0);
unit_warp(&md->bl, master->m, x, y,CLR_RESPAWN);
return 1;
}
@@ -2827,7 +2827,7 @@ int mob_warpslave(struct block_list *bl, int range)
if (range < 1)
range = 1; //Min range needed to avoid crashes and stuff. [Skotlex]
- return map_foreachinmap(mob_warpslave_sub, bl->m, BL_MOB, bl, range);
+ return iMap->foreachinmap(mob_warpslave_sub, bl->m, BL_MOB, bl, range);
}
/*==========================================
@@ -2850,7 +2850,7 @@ int mob_countslave_sub(struct block_list *bl,va_list ap)
*------------------------------------------*/
int mob_countslave(struct block_list *bl)
{
- return map_foreachinmap(mob_countslave_sub, bl->m, BL_MOB,bl->id);
+ return iMap->foreachinmap(mob_countslave_sub, bl->m, BL_MOB,bl->id);
}
/*==========================================
@@ -2897,7 +2897,7 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,uint16 skill_id)
if (mobdb_checkid(data.class_) == 0)
continue;
- if (map_search_freecell(&md2->bl, 0, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 0)) {
+ if (iMap->search_freecell(&md2->bl, 0, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 0)) {
data.x = x;
data.y = y;
} else {
@@ -3006,7 +3006,7 @@ static struct block_list *mob_getfriendhprate(struct mob_data *md,int min_rate,i
if (md->special_state.ai) //Summoned creatures. [Skotlex]
type = BL_PC;
- map_foreachinrange(mob_getfriendhprate_sub, &md->bl, 8, type,md,min_rate,max_rate,&fr);
+ iMap->foreachinrange(mob_getfriendhprate_sub, &md->bl, 8, type,md,min_rate,max_rate,&fr);
return fr;
}
/*==========================================
@@ -3016,7 +3016,7 @@ struct block_list *mob_getmasterhpltmaxrate(struct mob_data *md,int rate)
{
if( md && md->master_id > 0 )
{
- struct block_list *bl = map_id2bl(md->master_id);
+ struct block_list *bl = iMap->id2bl(md->master_id);
if( bl && get_percentage(status_get_hp(bl), status_get_max_hp(bl)) < rate )
return bl;
}
@@ -3063,7 +3063,7 @@ struct mob_data *mob_getfriendstatus(struct mob_data *md,int cond1,int cond2)
struct mob_data* fr = NULL;
nullpo_ret(md);
- map_foreachinrange(mob_getfriendstatus_sub, &md->bl, 8,BL_MOB, md,cond1,cond2,&fr);
+ iMap->foreachinrange(mob_getfriendstatus_sub, &md->bl, 8,BL_MOB, md,cond1,cond2,&fr);
return fr;
}
@@ -3165,7 +3165,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
case MSC_MASTERHPLTMAXRATE:
flag = ((fbl = mob_getmasterhpltmaxrate(md, ms[i].cond2)) != NULL); break;
case MSC_MASTERATTACKED:
- flag = (md->master_id > 0 && (fbl=map_id2bl(md->master_id)) && unit_counttargeted(fbl) > 0); break;
+ flag = (md->master_id > 0 && (fbl=iMap->id2bl(md->master_id)) && unit_counttargeted(fbl) > 0); break;
case MSC_ALCHEMIST:
flag = (md->state.alchemist);
break;
@@ -3188,12 +3188,12 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
case MST_AROUND6:
case MST_AROUND7:
case MST_AROUND8:
- bl = map_id2bl(md->target_id);
+ bl = iMap->id2bl(md->target_id);
break;
case MST_MASTER:
bl = &md->bl;
if (md->master_id)
- bl = map_id2bl(md->master_id);
+ bl = iMap->id2bl(md->master_id);
if (bl) //Otherwise, fall through.
break;
case MST_FRIEND:
@@ -3212,14 +3212,14 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
j = ms[i].target >= MST_AROUND1?
(ms[i].target-MST_AROUND1) +1:
(ms[i].target-MST_AROUND5) +1;
- map_search_freecell(&md->bl, md->bl.m, &x, &y, j, j, 3);
+ iMap->search_freecell(&md->bl, md->bl.m, &x, &y, j, j, 3);
}
md->skill_idx = i;
- map_freeblock_lock();
+ iMap->freeblock_lock();
if( !battle->check_range(&md->bl,bl,skill->get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) ||
!unit_skilluse_pos2(&md->bl, x, y,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) )
{
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
continue;
}
} else {
@@ -3230,12 +3230,12 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
skill->get_range2(&md->bl, ms[i].skill_id, ms[i].skill_lv));
break;
case MST_TARGET:
- bl = map_id2bl(md->target_id);
+ bl = iMap->id2bl(md->target_id);
break;
case MST_MASTER:
bl = &md->bl;
if (md->master_id)
- bl = map_id2bl(md->master_id);
+ bl = iMap->id2bl(md->master_id);
if (bl) //Otherwise, fall through.
break;
case MST_FRIEND:
@@ -3253,11 +3253,11 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
if (!bl) continue;
md->skill_idx = i;
- map_freeblock_lock();
+ iMap->freeblock_lock();
if( !battle->check_range(&md->bl,bl,skill->get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) ||
!unit_skilluse_id2(&md->bl, bl->id,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) )
{
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
continue;
}
}
@@ -3277,7 +3277,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
md->skilldelay[j]=tick;
} else
md->skilldelay[i]=tick;
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 1;
}
//No skill was used.
@@ -3387,8 +3387,8 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons
//Go Backwards to give better priority to advanced skills.
for (i=0,j = MAX_SKILL_TREE-1;j>=0 && i< MAX_MOBSKILL ;j--) {
- int idx = skill_tree[pc_class2idx(sd->status.class_)][j].idx;
- skill_id = skill_tree[pc_class2idx(sd->status.class_)][j].id;
+ int idx = skill_tree[pc->class2idx(sd->status.class_)][j].idx;
+ skill_id = skill_tree[pc->class2idx(sd->status.class_)][j].id;
if (!skill_id || sd->status.skill[idx].lv < 1 ||
(skill_db[idx].inf2&(INF2_WEDDING_SKILL|INF2_GUILD_SKILL))
)
@@ -3525,8 +3525,8 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons
if (duration) //Auto Delete after a while.
{
if( md->deletetimer != INVALID_TIMER )
- delete_timer(md->deletetimer, mob_timer_delete);
- md->deletetimer = add_timer (gettick() + duration, mob_timer_delete, md->bl.id, 0);
+ iTimer->delete_timer(md->deletetimer, mob_timer_delete);
+ md->deletetimer = iTimer->add_timer (iTimer->gettick() + duration, mob_timer_delete, md->bl.id, 0);
}
}
@@ -3788,7 +3788,7 @@ static bool mob_parse_dbrow(char** str)
//calculate and store Max available drop chance of the MVP item
if (db->mvpitem[i].p) {
struct item_data *id;
- id = itemdb_search(db->mvpitem[i].nameid);
+ id = itemdb->search(db->mvpitem[i].nameid);
if (id->maxchance == -1 || (id->maxchance < db->mvpitem[i].p/10 + 1) ) {
//item has bigger drop chance or sold in shops
id->maxchance = db->mvpitem[i].p/10 + 1; //reduce MVP drop info to not spoil common drop rate
@@ -3806,7 +3806,7 @@ static bool mob_parse_dbrow(char** str)
db->dropitem[i].p = 0; //No drop.
continue;
}
- id = itemdb_search(db->dropitem[i].nameid);
+ id = itemdb->search(db->dropitem[i].nameid);
type = id->type;
rate = atoi(str[k+1]);
if( (class_ >= 1324 && class_ <= 1363) || (class_ >= 1938 && class_ <= 1946) )
@@ -3900,14 +3900,14 @@ static void mob_readdb(void)
if(fi > 0)
{
char path[256];
- sprintf(path, "%s/%s", db_path, filename[fi]);
+ sprintf(path, "%s/%s", iMap->db_path, filename[fi]);
if(!exists(path))
{
continue;
}
}
- sv->readdb(db_path, filename[fi], ',', 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, -1, &mob_readdb_sub);
+ sv->readdb(iMap->db_path, filename[fi], ',', 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, -1, &mob_readdb_sub);
}
}
@@ -3916,7 +3916,7 @@ static void mob_readdb(void)
*------------------------------------------*/
static int mob_read_sqldb(void)
{
- const char* mob_db_name[] = { mob_db_db, mob_db2_db };
+ const char* mob_db_name[] = { iMap->mob_db_db, iMap->mob_db2_db };
int fi;
for( fi = 0; fi < ARRAYLENGTH(mob_db_name); ++fi ) {
@@ -4024,7 +4024,7 @@ static int mob_read_randommonster(void)
for( i = 0; i < ARRAYLENGTH(mobfile) && i < MAX_RANDOMMONSTER; i++ ) {
unsigned int count = 0;
mob_db_data[0]->summonper[i] = 1002; // Default fallback value, in case the database does not provide one
- sprintf(line, "%s/%s", db_path, mobfile[i]);
+ sprintf(line, "%s/%s", iMap->db_path, mobfile[i]);
fp=fopen(line,"r");
if(fp==NULL){
ShowError("can't read %s\n",line);
@@ -4138,7 +4138,7 @@ static void mob_readchatdb(void)
char line[1024], path[256];
int i, tmp=0;
FILE *fp;
- sprintf(path, "%s/%s", db_path, arc);
+ sprintf(path, "%s/%s", iMap->db_path, arc);
fp=fopen(path, "r");
if(fp == NULL)
{
@@ -4464,14 +4464,14 @@ static void mob_readskilldb(void) {
if(fi > 0)
{
char path[256];
- sprintf(path, "%s/%s", db_path, filename[fi]);
+ sprintf(path, "%s/%s", iMap->db_path, filename[fi]);
if(!exists(path))
{
continue;
}
}
- sv->readdb(db_path, filename[fi], ',', 19, 19, -1, &mob_parse_row_mobskilldb);
+ sv->readdb(iMap->db_path, filename[fi], ',', 19, 19, -1, &mob_parse_row_mobskilldb);
}
}
@@ -4482,7 +4482,7 @@ static void mob_readskilldb(void) {
*/
static int mob_read_sqlskilldb(void)
{
- const char* mob_skill_db_name[] = { mob_skill_db_db, mob_skill_db2_db };
+ const char* mob_skill_db_name[] = { iMap->mob_skill_db_db, iMap->mob_skill_db2_db };
int fi;
if( battle_config.mob_skill_rate == 0 ) {
@@ -4563,7 +4563,7 @@ static bool mob_readdb_itemratio(char* str[], int columns, int current)
int nameid, ratio, i;
nameid = atoi(str[0]);
- if( itemdb_exists(nameid) == NULL )
+ if( itemdb->exists(nameid) == NULL )
{
ShowWarning("itemdb_read_itemratio: Invalid item id %d.\n", nameid);
return false;
@@ -4586,9 +4586,9 @@ static bool mob_readdb_itemratio(char* str[], int columns, int current)
*/
static void mob_load(void)
{
- sv->readdb(db_path, "mob_item_ratio.txt", ',', 2, 2+MAX_ITEMRATIO_MOBS, -1, &mob_readdb_itemratio); // must be read before mobdb
+ sv->readdb(iMap->db_path, "mob_item_ratio.txt", ',', 2, 2+MAX_ITEMRATIO_MOBS, -1, &mob_readdb_itemratio); // must be read before mobdb
mob_readchatdb();
- if (db_use_sqldbs)
+ if (iMap->db_use_sqldbs)
{
mob_read_sqldb();
mob_read_sqlskilldb();
@@ -4598,9 +4598,9 @@ static void mob_load(void)
mob_readdb();
mob_readskilldb();
}
- sv->readdb(db_path, "mob_avail.txt", ',', 2, 12, -1, &mob_readdb_mobavail);
+ sv->readdb(iMap->db_path, "mob_avail.txt", ',', 2, 12, -1, &mob_readdb_mobavail);
mob_read_randommonster();
- sv->readdb(db_path, DBPATH"mob_race2_db.txt", ',', 2, 20, -1, &mob_readdb_race2);
+ sv->readdb(iMap->db_path, DBPATH"mob_race2_db.txt", ',', 2, 20, -1, &mob_readdb_race2);
}
void mob_reload(void) {
@@ -4645,15 +4645,15 @@ int do_init_mob(void)
mob_load();
- add_timer_func_list(mob_delayspawn,"mob_delayspawn");
- add_timer_func_list(mob_delay_item_drop,"mob_delay_item_drop");
- add_timer_func_list(mob_ai_hard,"mob_ai_hard");
- add_timer_func_list(mob_ai_lazy,"mob_ai_lazy");
- add_timer_func_list(mob_timer_delete,"mob_timer_delete");
- add_timer_func_list(mob_spawn_guardian_sub,"mob_spawn_guardian_sub");
- add_timer_func_list(mob_respawn,"mob_respawn");
- add_timer_interval(gettick()+MIN_MOBTHINKTIME,mob_ai_hard,0,0,MIN_MOBTHINKTIME);
- add_timer_interval(gettick()+MIN_MOBTHINKTIME*10,mob_ai_lazy,0,0,MIN_MOBTHINKTIME*10);
+ iTimer->add_timer_func_list(mob_delayspawn,"mob_delayspawn");
+ iTimer->add_timer_func_list(mob_delay_item_drop,"mob_delay_item_drop");
+ iTimer->add_timer_func_list(mob_ai_hard,"mob_ai_hard");
+ iTimer->add_timer_func_list(mob_ai_lazy,"mob_ai_lazy");
+ iTimer->add_timer_func_list(mob_timer_delete,"mob_timer_delete");
+ iTimer->add_timer_func_list(mob_spawn_guardian_sub,"mob_spawn_guardian_sub");
+ iTimer->add_timer_func_list(mob_respawn,"mob_respawn");
+ iTimer->add_timer_interval(iTimer->gettick()+MIN_MOBTHINKTIME,mob_ai_hard,0,0,MIN_MOBTHINKTIME);
+ iTimer->add_timer_interval(iTimer->gettick()+MIN_MOBTHINKTIME*10,mob_ai_lazy,0,0,MIN_MOBTHINKTIME*10);
return 0;
}
diff --git a/src/map/npc.c b/src/map/npc.c
index 7d0d5c6e1..2dd02e88f 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -57,14 +57,14 @@ static int npc_cache_mob=0;
/// Returns a new npc id that isn't being used in id_db.
/// Fatal error if nothing is available.
int npc_get_new_npc_id(void) {
- if( npc_id >= START_NPC_NUM && !map_blid_exists(npc_id) )
+ if( npc_id >= START_NPC_NUM && !iMap->blid_exists(npc_id) )
return npc_id++;// available
else {// find next id
int base_id = npc_id;
while( base_id != ++npc_id ) {
if( npc_id < START_NPC_NUM )
npc_id = START_NPC_NUM;
- if( !map_blid_exists(npc_id) )
+ if( !iMap->blid_exists(npc_id) )
return npc_id++;// available
}
// full loop, nothing available
@@ -122,7 +122,7 @@ struct view_data* npc_get_viewdata(int class_)
static int npc_isnear_sub(struct block_list* bl, va_list args) {
struct npc_data *nd = (struct npc_data*)bl;
- if( nd->sc.option & (OPTION_HIDE|OPTION_INVISIBLE) )
+ if( nd->option & (OPTION_HIDE|OPTION_INVISIBLE) )
return 0;
return 1;
@@ -131,7 +131,7 @@ static int npc_isnear_sub(struct block_list* bl, va_list args) {
bool npc_isnear(struct block_list * bl) {
if( battle_config.min_npc_vendchat_distance > 0 &&
- map_foreachinrange(npc_isnear_sub,bl, battle_config.min_npc_vendchat_distance, BL_NPC) )
+ iMap->foreachinrange(npc_isnear_sub,bl, battle_config.min_npc_vendchat_distance, BL_NPC) )
return true;
return false;
@@ -175,7 +175,7 @@ int npc_enable_sub(struct block_list *bl, va_list ap)
{
TBL_PC *sd = (TBL_PC*)bl;
- if (nd->sc.option&OPTION_INVISIBLE)
+ if (nd->option&OPTION_INVISIBLE)
return 1;
if( npc_ontouch_event(sd,nd) > 0 && npc_ontouch2_event(sd,nd) > 0 )
@@ -197,27 +197,25 @@ int npc_enable(const char* name, int flag)
{
struct npc_data* nd = npc_name2id(name);
- if (nd==NULL)
- {
+ if ( nd == NULL ) {
ShowError("npc_enable: Attempted to %s a non-existing NPC '%s' (flag=%d).\n", (flag&3) ? "show" : "hide", name, flag);
return 0;
}
if (flag&1) {
- nd->sc.option&=~OPTION_INVISIBLE;
+ nd->option&=~OPTION_INVISIBLE;
clif->spawn(&nd->bl);
} else if (flag&2)
- nd->sc.option&=~OPTION_HIDE;
+ nd->option&=~OPTION_HIDE;
else if (flag&4)
- nd->sc.option|= OPTION_HIDE;
- else { //Can't change the view_data to invisible class because the view_data for all npcs is shared! [Skotlex]
- nd->sc.option|= OPTION_INVISIBLE;
+ nd->option|= OPTION_HIDE;
+ else { //Can't change the view_data to invisible class because the view_data for all npcs is shared! [Skotlex]
+ nd->option|= OPTION_INVISIBLE;
clif->clearunit_area(&nd->bl,CLR_OUTSIGHT); // Hack to trick maya purple card [Xazax]
}
- if (nd->class_ == WARP_CLASS || nd->class_ == FLAG_CLASS)
- { //Client won't display option changes for these classes [Toms]
- if (nd->sc.option&(OPTION_HIDE|OPTION_INVISIBLE))
+ if (nd->class_ == WARP_CLASS || nd->class_ == FLAG_CLASS) { //Client won't display option changes for these classes [Toms]
+ if (nd->option&(OPTION_HIDE|OPTION_INVISIBLE))
clif->clearunit_area(&nd->bl, CLR_OUTSIGHT);
else
clif->spawn(&nd->bl);
@@ -225,7 +223,7 @@ int npc_enable(const char* name, int flag)
clif->changeoption(&nd->bl);
if( flag&3 && (nd->u.scr.xs >= 0 || nd->u.scr.ys >= 0) ) //check if player standing on a OnTouchArea
- map_foreachinarea( npc_enable_sub, nd->bl.m, nd->bl.x-nd->u.scr.xs, nd->bl.y-nd->u.scr.ys, nd->bl.x+nd->u.scr.xs, nd->bl.y+nd->u.scr.ys, BL_PC, nd );
+ iMap->foreachinarea( npc_enable_sub, nd->bl.m, nd->bl.x-nd->u.scr.xs, nd->bl.y-nd->u.scr.ys, nd->bl.x+nd->u.scr.xs, nd->bl.y+nd->u.scr.ys, BL_PC, nd );
return 0;
}
@@ -247,7 +245,7 @@ struct npc_data* npc_name2id(const char* name)
int npc_rr_secure_timeout_timer(int tid, unsigned int tick, int id, intptr_t data) {
struct map_session_data* sd = NULL;
unsigned int timeout = NPC_SECURE_TIMEOUT_NEXT;
- if( (sd = map_id2sd(id)) == NULL || !sd->npc_id ) {
+ if( (sd = iMap->id2sd(id)) == NULL || !sd->npc_id ) {
if( sd ) sd->npc_idle_timer = INVALID_TIMER;
return 0;//Not logged in anymore OR no longer attached to a npc
}
@@ -270,14 +268,15 @@ int npc_rr_secure_timeout_timer(int tid, unsigned int tick, int id, intptr_t dat
sd->st->state = END;
sd->state.menu_or_input = 0;
sd->npc_menu = 0;
-
+ clif->scriptmes(sd, sd->npc_id, " ");
/**
* This guy's been idle for longer than allowed, close him.
**/
clif->scriptclose(sd,sd->npc_id);
+ clif->scriptclear(sd,sd->npc_id);
sd->npc_idle_timer = INVALID_TIMER;
} else //Create a new instance of ourselves to continue
- sd->npc_idle_timer = add_timer(gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc_rr_secure_timeout_timer,sd->bl.id,0);
+ sd->npc_idle_timer = iTimer->add_timer(iTimer->gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc_rr_secure_timeout_timer,sd->bl.id,0);
return 0;
}
#endif
@@ -289,8 +288,7 @@ int npc_event_dequeue(struct map_session_data* sd)
{
nullpo_ret(sd);
- if(sd->npc_id)
- { //Current script is aborted.
+ if(sd->npc_id) { //Current script is aborted.
if(sd->state.using_fake_npc){
clif->clearunit_single(sd->npc_id, CLR_OUTSIGHT, sd->fd);
sd->state.using_fake_npc = 0;
@@ -305,8 +303,7 @@ int npc_event_dequeue(struct map_session_data* sd)
if (!sd->eventqueue[0][0])
return 0; //Nothing to dequeue
- if (!pc_addeventtimer(sd,100,sd->eventqueue[0]))
- { //Failed to dequeue, couldn't set a timer.
+ if (!pc->addeventtimer(sd,100,sd->eventqueue[0])) { //Failed to dequeue, couldn't set a timer.
ShowWarning("npc_event_dequeue: event timer is full !\n");
return 0;
}
@@ -362,7 +359,7 @@ int npc_event_doall_sub(DBKey key, DBData *data, va_list ap)
if( p && strcmpi(name, p) == 0 /* && !ev->nd->src_id */ ) // Do not run on duplicates. [Paradox924X]
{
if(rid) // a player may only have 1 script running at the same time
- npc_event_sub(map_id2sd(rid),ev,key.str);
+ npc_event_sub(iMap->id2sd(rid),ev,key.str);
else
run_script(ev->nd->u.scr.script,ev->pos,rid,ev->nd->bl.id);
(*c)++;
@@ -385,8 +382,7 @@ static int npc_event_do_sub(DBKey key, DBData *data, va_list ap)
nullpo_ret(c = va_arg(ap, int *));
nullpo_ret(name = va_arg(ap, const char *));
- if( p && strcmpi(name, p) == 0 )
- {
+ if( p && strcmpi(name, p) == 0 ) {
run_script(ev->nd->u.scr.script,ev->pos,0,ev->nd->bl.id);
(*c)++;
}
@@ -483,7 +479,7 @@ void npc_event_do_oninit(void)
{
ShowStatus("Event '"CL_WHITE"OnInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs."CL_CLL"\n", npc_event_doall("OnInit"));
- add_timer_interval(gettick()+100,npc_event_do_clock,0,0,1000);
+ iTimer->add_timer_interval(iTimer->gettick()+100,npc_event_do_clock,0,0,1000);
}
/*==========================================
@@ -530,7 +526,7 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data)
{
int old_rid, old_timer;
unsigned int old_tick;
- struct npc_data* nd=(struct npc_data *)map_id2bl(id);
+ struct npc_data* nd=(struct npc_data *)iMap->id2bl(id);
struct npc_timerevent_list *te;
struct timer_event_data *ted = (struct timer_event_data*)data;
struct map_session_data *sd=NULL;
@@ -541,7 +537,7 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data)
return 0;
}
- if( ted->rid && !(sd = map_id2sd(ted->rid)) )
+ if( ted->rid && !(sd = iMap->id2sd(ted->rid)) )
{
ShowError("npc_timerevent: Attached player not found.\n");
ers_free(timer_event_ers, ted);
@@ -569,9 +565,9 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data)
next = nd->u.scr.timer_event[ ted->next ].timer - nd->u.scr.timer_event[ ted->next - 1 ].timer;
ted->time += next;
if( sd )
- sd->npc_timer_id = add_timer(tick+next,npc_timerevent,id,(intptr_t)ted);
+ sd->npc_timer_id = iTimer->add_timer(tick+next,npc_timerevent,id,(intptr_t)ted);
else
- nd->u.scr.timerid = add_timer(tick+next,npc_timerevent,id,(intptr_t)ted);
+ nd->u.scr.timerid = iTimer->add_timer(tick+next,npc_timerevent,id,(intptr_t)ted);
}
else
{
@@ -601,7 +597,7 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data)
int npc_timerevent_start(struct npc_data* nd, int rid)
{
int j;
- unsigned int tick = gettick();
+ unsigned int tick = iTimer->gettick();
struct map_session_data *sd = NULL; //Player to whom script is attached.
nullpo_ret(nd);
@@ -609,23 +605,19 @@ int npc_timerevent_start(struct npc_data* nd, int rid)
// Check if there is an OnTimer Event
ARR_FIND( 0, nd->u.scr.timeramount, j, nd->u.scr.timer_event[j].timer > nd->u.scr.timer );
- if( nd->u.scr.rid > 0 && !(sd = map_id2sd(nd->u.scr.rid)) )
+ if( nd->u.scr.rid > 0 && !(sd = iMap->id2sd(nd->u.scr.rid)) )
{ // Failed to attach timer to this player.
ShowError("npc_timerevent_start: Attached player not found!\n");
return 1;
}
-
// Check if timer is already started.
- if( sd )
- {
+ if( sd ) {
if( sd->npc_timer_id != INVALID_TIMER )
return 0;
- }
- else if( nd->u.scr.timerid != INVALID_TIMER || nd->u.scr.timertick )
+ } else if( nd->u.scr.timerid != INVALID_TIMER || nd->u.scr.timertick )
return 0;
- if (j < nd->u.scr.timeramount)
- {
+ if (j < nd->u.scr.timeramount) {
int next;
struct timer_event_data *ted;
// Arrange for the next event
@@ -636,18 +628,18 @@ int npc_timerevent_start(struct npc_data* nd, int rid)
if( sd )
{
ted->rid = sd->bl.id; // Attach only the player if attachplayerrid was used.
- sd->npc_timer_id = add_timer(tick+next,npc_timerevent,nd->bl.id,(intptr_t)ted);
+ sd->npc_timer_id = iTimer->add_timer(tick+next,npc_timerevent,nd->bl.id,(intptr_t)ted);
}
else
{
ted->rid = 0;
nd->u.scr.timertick = tick; // Set when timer is started
- nd->u.scr.timerid = add_timer(tick+next,npc_timerevent,nd->bl.id,(intptr_t)ted);
+ nd->u.scr.timerid = iTimer->add_timer(tick+next,npc_timerevent,nd->bl.id,(intptr_t)ted);
}
- }
- else if (!sd)
- {
+
+ } else if (!sd) {
nd->u.scr.timertick = tick;
+
}
return 0;
@@ -663,12 +655,11 @@ int npc_timerevent_stop(struct npc_data* nd)
nullpo_ret(nd);
- if( nd->u.scr.rid && !(sd = map_id2sd(nd->u.scr.rid)) )
+ if( nd->u.scr.rid && !(sd = iMap->id2sd(nd->u.scr.rid)) )
{
ShowError("npc_timerevent_stop: Attached player not found!\n");
return 1;
}
-
tid = sd?&sd->npc_timer_id:&nd->u.scr.timerid;
if( *tid == INVALID_TIMER && (sd || !nd->u.scr.timertick) ) // Nothing to stop
return 0;
@@ -676,16 +667,16 @@ int npc_timerevent_stop(struct npc_data* nd)
// Delete timer
if ( *tid != INVALID_TIMER )
{
- td = get_timer(*tid);
+ td = iTimer->get_timer(*tid);
if( td && td->data )
ers_free(timer_event_ers, (void*)td->data);
- delete_timer(*tid,npc_timerevent);
+ iTimer->delete_timer(*tid,npc_timerevent);
*tid = INVALID_TIMER;
}
if( !sd && nd->u.scr.timertick )
{
- nd->u.scr.timer += DIFF_TICK(gettick(),nd->u.scr.timertick); // Set 'timer' to the time that has passed since the beginning of the timers
+ nd->u.scr.timer += DIFF_TICK(iTimer->gettick(),nd->u.scr.timertick); // Set 'timer' to the time that has passed since the beginning of the timers
nd->u.scr.timertick = 0; // Set 'tick' to zero so that we know it's off.
}
@@ -703,16 +694,16 @@ void npc_timerevent_quit(struct map_session_data* sd)
// Check timer existance
if( sd->npc_timer_id == INVALID_TIMER )
return;
- if( !(td = get_timer(sd->npc_timer_id)) )
+ if( !(td = iTimer->get_timer(sd->npc_timer_id)) )
{
sd->npc_timer_id = INVALID_TIMER;
return;
}
// Delete timer
- nd = (struct npc_data *)map_id2bl(td->id);
+ nd = (struct npc_data *)iMap->id2bl(td->id);
ted = (struct timer_event_data*)td->data;
- delete_timer(sd->npc_timer_id, npc_timerevent);
+ iTimer->delete_timer(sd->npc_timer_id, npc_timerevent);
sd->npc_timer_id = INVALID_TIMER;
// Execute OnTimerQuit
@@ -739,7 +730,7 @@ void npc_timerevent_quit(struct map_session_data* sd)
old_timer = nd->u.scr.timer;
nd->u.scr.rid = sd->bl.id;
- nd->u.scr.timertick = gettick();
+ nd->u.scr.timertick = iTimer->gettick();
nd->u.scr.timer = ted->time;
//Execute label
@@ -767,7 +758,7 @@ int npc_gettimerevent_tick(struct npc_data* nd)
tick = nd->u.scr.timer; // The last time it's active(start, stop or event trigger)
if( nd->u.scr.timertick ) // It's a running timer
- tick += DIFF_TICK(gettick(), nd->u.scr.timertick);
+ tick += DIFF_TICK(iTimer->gettick(), nd->u.scr.timertick);
return tick;
}
@@ -789,7 +780,7 @@ int npc_settimerevent_tick(struct npc_data* nd, int newtimer)
nd->u.scr.rid = 0;
// Check if timer is started
- flag = (nd->u.scr.timerid != INVALID_TIMER);
+ flag = (nd->u.scr.timerid != INVALID_TIMER || nd->u.scr.timertick);
if( flag ) npc_timerevent_stop(nd);
nd->u.scr.timer = newtimer;
@@ -815,7 +806,7 @@ int npc_event_sub(struct map_session_data* sd, struct event_data* ev, const char
ShowWarning("npc_event: player's event queue is full, can't add event '%s' !\n", eventname);
return 1;
}
- if( ev->nd->sc.option&OPTION_INVISIBLE )
+ if( ev->nd->option&OPTION_INVISIBLE )
{
//Disabled npc, shouldn't trigger event.
npc_event_dequeue(sd);
@@ -835,22 +826,20 @@ int npc_event(struct map_session_data* sd, const char* eventname, int ontouch)
nullpo_ret(sd);
- if( ev == NULL || (nd = ev->nd) == NULL )
- {
+ if( ev == NULL || (nd = ev->nd) == NULL ) {
if( !ontouch )
ShowError("npc_event: event not found [%s]\n", eventname);
return ontouch;
}
- switch(ontouch)
- {
- case 1:
- nd->touching_id = sd->bl.id;
- sd->touching_id = nd->bl.id;
- break;
- case 2:
- sd->areanpc_id = nd->bl.id;
- break;
+ switch(ontouch) {
+ case 1:
+ nd->touching_id = sd->bl.id;
+ sd->touching_id = nd->bl.id;
+ break;
+ case 2:
+ sd->areanpc_id = nd->bl.id;
+ break;
}
return npc_event_sub(sd,ev,eventname);
@@ -866,7 +855,7 @@ int npc_touch_areanpc_sub(struct block_list *bl, va_list ap)
char *name;
nullpo_ret(bl);
- nullpo_ret((sd = map_id2sd(bl->id)));
+ nullpo_ret((sd = iMap->id2sd(bl->id)));
pc_id = va_arg(ap,int);
name = va_arg(ap,char*);
@@ -889,7 +878,7 @@ int npc_touch_areanpc_sub(struct block_list *bl, va_list ap)
*------------------------------------------*/
int npc_touchnext_areanpc(struct map_session_data* sd, bool leavemap)
{
- struct npc_data *nd = map_id2nd(sd->touching_id);
+ struct npc_data *nd = iMap->id2nd(sd->touching_id);
short xs, ys;
if( !nd || nd->touching_id != sd->bl.id )
@@ -907,7 +896,7 @@ int npc_touchnext_areanpc(struct map_session_data* sd, bool leavemap)
nd->touching_id = sd->touching_id = 0;
snprintf(name, ARRAYLENGTH(name), "%s::%s", nd->exname, script_config.ontouch_name);
- map_forcountinarea(npc_touch_areanpc_sub,nd->bl.m,nd->bl.x - xs,nd->bl.y - ys,nd->bl.x + xs,nd->bl.y + ys,1,BL_PC,sd->bl.id,name);
+ iMap->forcountinarea(npc_touch_areanpc_sub,nd->bl.m,nd->bl.x - xs,nd->bl.y - ys,nd->bl.x + xs,nd->bl.y + ys,1,BL_PC,sd->bl.id,name);
}
return 0;
}
@@ -928,9 +917,8 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y)
//if(sd->npc_id)
// return 1;
- for(i=0;i<map[m].npc_num;i++)
- {
- if (map[m].npc[i]->sc.option&OPTION_INVISIBLE) {
+ for(i=0;i<map[m].npc_num;i++) {
+ if (map[m].npc[i]->option&OPTION_INVISIBLE) {
f=0; // a npc was found, but it is disabled; don't print warning
continue;
}
@@ -961,7 +949,7 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y)
case WARP:
if( pc_ishiding(sd) || (sd->sc.count && sd->sc.data[SC_CAMOUFLAGE]) )
break; // hidden chars cannot use warps
- pc_setpos(sd,map[m].npc[i]->u.warp.mapindex,map[m].npc[i]->u.warp.x,map[m].npc[i]->u.warp.y,CLR_OUTSIGHT);
+ pc->setpos(sd,map[m].npc[i]->u.warp.mapindex,map[m].npc[i]->u.warp.x,map[m].npc[i]->u.warp.y,CLR_OUTSIGHT);
break;
case SCRIPT:
for (j = i; j < map[m].npc_num; j++) {
@@ -973,7 +961,7 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y)
(sd->bl.y >= (map[m].npc[j]->bl.y - map[m].npc[j]->u.warp.ys) && sd->bl.y <= (map[m].npc[j]->bl.y + map[m].npc[j]->u.warp.ys))) {
if( pc_ishiding(sd) || (sd->sc.count && sd->sc.data[SC_CAMOUFLAGE]) )
break; // hidden chars cannot use warps
- pc_setpos(sd,map[m].npc[j]->u.warp.mapindex,map[m].npc[j]->u.warp.x,map[m].npc[j]->u.warp.y,CLR_OUTSIGHT);
+ pc->setpos(sd,map[m].npc[j]->u.warp.mapindex,map[m].npc[j]->u.warp.x,map[m].npc[j]->u.warp.y,CLR_OUTSIGHT);
found_warp = 1;
break;
}
@@ -1008,13 +996,11 @@ int npc_touch_areanpc2(struct mob_data *md)
struct event_data* ev;
int xs, ys;
- for( i = 0; i < map[m].npc_num; i++ )
- {
- if( map[m].npc[i]->sc.option&OPTION_INVISIBLE )
+ for( i = 0; i < map[m].npc_num; i++ ) {
+ if( map[m].npc[i]->option&OPTION_INVISIBLE )
continue;
- switch( map[m].npc[i]->subtype )
- {
+ switch( map[m].npc[i]->subtype ) {
case WARP:
if( !( battle_config.mob_warp&1 ) )
continue;
@@ -1034,7 +1020,7 @@ int npc_touch_areanpc2(struct mob_data *md)
switch( map[m].npc[i]->subtype )
{
case WARP:
- xs = map_mapindex2mapid(map[m].npc[i]->u.warp.mapindex);
+ xs = iMap->mapindex2mapid(map[m].npc[i]->u.warp.mapindex);
if( m < 0 )
break; // Cannot Warp between map servers
if( unit_warp(&md->bl, xs, map[m].npc[i]->u.warp.x, map[m].npc[i]->u.warp.y, CLR_OUTSIGHT) == 0 )
@@ -1049,7 +1035,7 @@ int npc_touch_areanpc2(struct mob_data *md)
md->areanpc_id = map[m].npc[i]->bl.id;
id = md->bl.id; // Stores Unique ID
run_script(ev->nd->u.scr.script, ev->pos, md->bl.id, ev->nd->bl.id);
- if( map_id2md(id) == NULL ) return 1; // Not Warped, but killed
+ if( iMap->id2md(id) == NULL ) return 1; // Not Warped, but killed
break;
}
@@ -1080,34 +1066,32 @@ int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range)
i = 0;
for (ys = y0; ys <= y1 && !i; ys++) {
for(xs = x0; xs <= x1 && !i; xs++){
- if (map_getcell(m,xs,ys,CELL_CHKNPC))
+ if (iMap->getcell(m,xs,ys,CELL_CHKNPC))
i = 1;
}
}
if (!i) return 0; //No NPC_CELLs.
//Now check for the actual NPC on said range.
- for(i=0;i<map[m].npc_num;i++)
- {
- if (map[m].npc[i]->sc.option&OPTION_INVISIBLE)
+ for(i=0;i<map[m].npc_num;i++) {
+ if (map[m].npc[i]->option&OPTION_INVISIBLE)
continue;
- switch(map[m].npc[i]->subtype)
- {
- case WARP:
- if (!(flag&1))
- continue;
- xs=map[m].npc[i]->u.warp.xs;
- ys=map[m].npc[i]->u.warp.ys;
- break;
- case SCRIPT:
- if (!(flag&2))
+ switch(map[m].npc[i]->subtype) {
+ case WARP:
+ if (!(flag&1))
+ continue;
+ xs=map[m].npc[i]->u.warp.xs;
+ ys=map[m].npc[i]->u.warp.ys;
+ break;
+ case SCRIPT:
+ if (!(flag&2))
+ continue;
+ xs=map[m].npc[i]->u.scr.xs;
+ ys=map[m].npc[i]->u.scr.ys;
+ break;
+ default:
continue;
- xs=map[m].npc[i]->u.scr.xs;
- ys=map[m].npc[i]->u.scr.ys;
- break;
- default:
- continue;
}
if( x1 >= map[m].npc[i]->bl.x-xs && x0 <= map[m].npc[i]->bl.x+xs
@@ -1206,7 +1190,7 @@ int npc_click(struct map_session_data* sd, struct npc_data* nd)
if ((nd = npc_checknear(sd,&nd->bl)) == NULL)
return 1;
//Hidden/Disabled npc.
- if (nd->class_ < 0 || nd->sc.option&(OPTION_INVISIBLE|OPTION_HIDE))
+ if (nd->class_ < 0 || nd->option&(OPTION_INVISIBLE|OPTION_HIDE))
return 1;
switch(nd->subtype) {
@@ -1235,8 +1219,8 @@ int npc_scriptcont(struct map_session_data* sd, int id, bool closing)
nullpo_retr(1, sd);
if( id != sd->npc_id ){
- TBL_NPC* nd_sd=(TBL_NPC*)map_id2bl(sd->npc_id);
- TBL_NPC* nd=(TBL_NPC*)map_id2bl(id);
+ TBL_NPC* nd_sd=(TBL_NPC*)iMap->id2bl(sd->npc_id);
+ TBL_NPC* nd=(TBL_NPC*)iMap->id2bl(id);
ShowDebug("npc_scriptcont: %s (sd->npc_id=%d) is not %s (id=%d).\n",
nd_sd?(char*)nd_sd->name:"'Unknown NPC'", (int)sd->npc_id,
nd?(char*)nd->name:"'Unknown NPC'", (int)id);
@@ -1244,7 +1228,7 @@ int npc_scriptcont(struct map_session_data* sd, int id, bool closing)
}
if(id != fake_nd->bl.id) { // Not item script
- if ((npc_checknear(sd,map_id2bl(id))) == NULL){
+ if ((npc_checknear(sd,iMap->id2bl(id))) == NULL){
ShowWarning("npc_scriptcont: failed npc_checknear test.\n");
return 1;
}
@@ -1256,13 +1240,13 @@ int npc_scriptcont(struct map_session_data* sd, int id, bool closing)
/**
* Update the last NPC iteration
**/
- sd->npc_idle_tick = gettick();
+ sd->npc_idle_tick = iTimer->gettick();
#endif
/**
* WPE can get to this point with a progressbar; we deny it.
**/
- if( sd->progressbar.npc_id && DIFF_TICK(sd->progressbar.timeout,gettick()) > 0 )
+ if( sd->progressbar.npc_id && DIFF_TICK(sd->progressbar.timeout,iTimer->gettick()) > 0 )
return 1;
if( closing && sd->st->state == CLOSE )
@@ -1282,7 +1266,7 @@ int npc_buysellsel(struct map_session_data* sd, int id, int type)
nullpo_retr(1, sd);
- if ((nd = npc_checknear(sd,map_id2bl(id))) == NULL)
+ if ((nd = npc_checknear(sd,iMap->id2bl(id))) == NULL)
return 1;
if (nd->subtype!=SHOP) {
@@ -1291,7 +1275,7 @@ int npc_buysellsel(struct map_session_data* sd, int id, int type)
sd->npc_id=0;
return 1;
}
- if (nd->sc.option & OPTION_INVISIBLE) // can't buy if npc is not visible (hack?)
+ if (nd->option & OPTION_INVISIBLE) // can't buy if npc is not visible (hack?)
return 1;
if( nd->class_ < 0 && !sd->state.callshop )
{// not called through a script and is not a visible NPC so an invalid call
@@ -1315,7 +1299,7 @@ int npc_buysellsel(struct map_session_data* sd, int id, int type)
int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, unsigned short* item_list)
{
int i, j, nameid, amount, new_, w, vt;
- struct npc_data *nd = (struct npc_data *)map_id2bl(sd->npc_shopid);
+ struct npc_data *nd = (struct npc_data *)iMap->id2bl(sd->npc_shopid);
if( !nd || nd->subtype != CASHSHOP )
return 1;
@@ -1333,7 +1317,7 @@ int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, uns
nameid = item_list[i*2+1];
amount = item_list[i*2+0];
- if( !itemdb_exists(nameid) || amount <= 0 )
+ if( !itemdb->exists(nameid) || amount <= 0 )
return 5;
ARR_FIND(0,nd->u.shop.count,j,nd->u.shop.shop_item[j].nameid == nameid);
@@ -1346,7 +1330,7 @@ int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, uns
amount = item_list[i*2+0] = 1;
}
- switch( pc_checkadditem(sd,nameid,amount) )
+ switch( pc->checkadditem(sd,nameid,amount) )
{
case ADDITEM_NEW:
new_++;
@@ -1361,14 +1345,14 @@ int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, uns
if( w + sd->weight > sd->max_weight )
return 3;
- if( pc_inventoryblank(sd) < new_ )
+ if( pc->inventoryblank(sd) < new_ )
return 3;
if( points > vt ) points = vt;
// Payment Process ----------------------------------------------------
if( sd->kafraPoints < points || sd->cashPoints < (vt - points) )
return 6;
- pc_paycash(sd,vt,points);
+ pc->paycash(sd,vt,points);
// Delivery Process ----------------------------------------------------
for( i = 0; i < count; i++ )
@@ -1384,7 +1368,7 @@ int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, uns
{
item_tmp.nameid = nameid;
item_tmp.identify = 1;
- pc_additem(sd,&item_tmp,amount,LOG_TYPE_NPC);
+ pc->additem(sd,&item_tmp,amount,LOG_TYPE_NPC);
}
}
@@ -1422,7 +1406,7 @@ static int npc_buylist_sub(struct map_session_data* sd, int n, unsigned short* i
*------------------------------------------*/
int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int points)
{
- struct npc_data *nd = (struct npc_data *)map_id2bl(sd->npc_shopid);
+ struct npc_data *nd = (struct npc_data *)iMap->id2bl(sd->npc_shopid);
struct item_data *item;
int i, price, w;
@@ -1438,7 +1422,7 @@ int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int po
if( sd->state.trading )
return 4;
- if( (item = itemdb_exists(nameid)) == NULL )
+ if( (item = itemdb->exists(nameid)) == NULL )
return 5; // Invalid Item
ARR_FIND(0, nd->u.shop.count, i, nd->u.shop.shop_item[i].nameid == nameid);
@@ -1454,10 +1438,10 @@ int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int po
amount = 1;
}
- switch( pc_checkadditem(sd, nameid, amount) )
+ switch( pc->checkadditem(sd, nameid, amount) )
{
case ADDITEM_NEW:
- if( pc_inventoryblank(sd) == 0 )
+ if( pc->inventoryblank(sd) == 0 )
return 3;
break;
case ADDITEM_OVERAMOUNT:
@@ -1483,7 +1467,7 @@ int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int po
if( (sd->kafraPoints < points) || (sd->cashPoints < price - points) )
return 6;
- pc_paycash(sd, price, points);
+ pc->paycash(sd, price, points);
if( !pet_create_egg(sd, nameid) )
{
@@ -1492,7 +1476,7 @@ int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int po
item_tmp.nameid = nameid;
item_tmp.identify = 1;
- pc_additem(sd,&item_tmp, amount, LOG_TYPE_NPC);
+ pc->additem(sd,&item_tmp, amount, LOG_TYPE_NPC);
}
return 0;
@@ -1511,7 +1495,7 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list)
nullpo_retr(3, sd);
nullpo_retr(3, item_list);
- nd = npc_checknear(sd,map_id2bl(sd->npc_shopid));
+ nd = npc_checknear(sd,iMap->id2bl(sd->npc_shopid));
if( nd == NULL )
return 3;
if( nd->subtype != SHOP )
@@ -1537,7 +1521,7 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list)
nameid = item_list[i*2+1] = nd->u.shop.shop_item[j].nameid; //item_avail replacement
value = nd->u.shop.shop_item[j].value;
- if( !itemdb_exists(nameid) )
+ if( !itemdb->exists(nameid) )
return 3; // item no longer in itemdb
if( !itemdb_isstackable(nameid) && amount > 1 ) {
@@ -1552,7 +1536,7 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list)
continue;
}
- switch( pc_checkadditem(sd,nameid,amount) ) {
+ switch( pc->checkadditem(sd,nameid,amount) ) {
case ADDITEM_EXIST:
break;
@@ -1564,7 +1548,7 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list)
return 2;
}
- value = pc_modifybuyvalue(sd,value);
+ value = pc->modifybuyvalue(sd,value);
z += (double)value * amount;
w += itemdb_weight(nameid) * amount;
@@ -1577,10 +1561,10 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list)
return 1; // Not enough Zeny
if( w + sd->weight > sd->max_weight )
return 2; // Too heavy
- if( pc_inventoryblank(sd) < new_ )
+ if( pc->inventoryblank(sd) < new_ )
return 3; // Not enough space to store items
- pc_payzeny(sd,(int)z,LOG_TYPE_NPC, NULL);
+ pc->payzeny(sd,(int)z,LOG_TYPE_NPC, NULL);
for( i = 0; i < n; ++i ) {
int nameid = item_list[i*2+1];
@@ -1594,12 +1578,12 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list)
item_tmp.nameid = nameid;
item_tmp.identify = 1;
- pc_additem(sd,&item_tmp,amount,LOG_TYPE_NPC);
+ pc->additem(sd,&item_tmp,amount,LOG_TYPE_NPC);
}
}
// custom merchant shop exp bonus
- if( battle_config.shop_exp > 0 && z > 0 && (skill_t = pc_checkskill2(sd,idx)) > 0 ) {
+ if( battle_config.shop_exp > 0 && z > 0 && (skill_t = pc->checkskill2(sd,idx)) > 0 ) {
if( sd->status.skill[idx].flag >= SKILL_FLAG_REPLACED_LV_0 )
skill_t = sd->status.skill[idx].flag - SKILL_FLAG_REPLACED_LV_0;
@@ -1607,7 +1591,7 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list)
z = z * (double)skill_t * (double)battle_config.shop_exp/10000.;
if( z < 1 )
z = 1;
- pc_gainexp(sd,NULL,0,(int)z, false);
+ pc->gainexp(sd,NULL,0,(int)z, false);
}
}
@@ -1684,7 +1668,7 @@ int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list)
nullpo_retr(1, sd);
nullpo_retr(1, item_list);
- if( ( nd = npc_checknear(sd, map_id2bl(sd->npc_shopid)) ) == NULL || nd->subtype != SHOP ) {
+ if( ( nd = npc_checknear(sd, iMap->id2bl(sd->npc_shopid)) ) == NULL || nd->subtype != SHOP ) {
return 1;
}
@@ -1711,7 +1695,7 @@ int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list)
continue;
}
- value = pc_modifysellvalue(sd, sd->inventory_data[idx]->value_sell);
+ value = pc->modifysellvalue(sd, sd->inventory_data[idx]->value_sell);
z+= (double)value*amount;
}
@@ -1733,16 +1717,16 @@ int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list)
}
}
- pc_delitem(sd, idx, amount, 0, 6, LOG_TYPE_NPC);
+ pc->delitem(sd, idx, amount, 0, 6, LOG_TYPE_NPC);
}
if( z > MAX_ZENY )
z = MAX_ZENY;
- pc_getzeny(sd, (int)z, LOG_TYPE_NPC, NULL);
+ pc->getzeny(sd, (int)z, LOG_TYPE_NPC, NULL);
// custom merchant shop exp bonus
- if( battle_config.shop_exp > 0 && z > 0 && ( skill_t = pc_checkskill2(sd,idx) ) > 0) {
+ if( battle_config.shop_exp > 0 && z > 0 && ( skill_t = pc->checkskill2(sd,idx) ) > 0) {
if( sd->status.skill[idx].flag >= SKILL_FLAG_REPLACED_LV_0 )
skill_t = sd->status.skill[idx].flag - SKILL_FLAG_REPLACED_LV_0;
@@ -1750,7 +1734,7 @@ int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list)
z = z * (double)skill_t * (double)battle_config.shop_exp/10000.;
if( z < 1 )
z = 1;
- pc_gainexp(sd, NULL, 0, (int)z, false);
+ pc->gainexp(sd, NULL, 0, (int)z, false);
}
}
@@ -1759,8 +1743,7 @@ int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list)
//Atempt to remove an npc from a map
//This doesn't remove it from map_db
-int npc_remove_map(struct npc_data* nd)
-{
+int npc_remove_map(struct npc_data* nd) {
int16 m,i;
nullpo_retr(1, nd);
@@ -1769,7 +1752,7 @@ int npc_remove_map(struct npc_data* nd)
m = nd->bl.m;
clif->clearunit_area(&nd->bl,CLR_RESPAWN);
npc_unsetcells(nd);
- map_delblock(&nd->bl);
+ iMap->delblock(&nd->bl);
//Remove npc from map[].npc list. [Skotlex]
ARR_FIND( 0, map[m].npc_num, i, map[m].npc[i] == nd );
if( i == map[m].npc_num ) return 2; //failed to find it?
@@ -1810,7 +1793,7 @@ static int npc_unload_dup_sub(struct npc_data* nd, va_list args)
//Removes all npcs that are duplicates of the passed one. [Skotlex]
void npc_unload_duplicates(struct npc_data* nd)
{
- map_foreachnpc(npc_unload_dup_sub,nd->bl.id);
+ iMap->map_foreachnpc(npc_unload_dup_sub,nd->bl.id);
}
//Removes an npc from map and db.
@@ -1819,7 +1802,7 @@ int npc_unload(struct npc_data* nd, bool single) {
nullpo_ret(nd);
npc_remove_map(nd);
- map_deliddb(&nd->bl);
+ iMap->deliddb(&nd->bl);
if( single )
strdb_remove(npcname_db, nd->exname);
@@ -1855,14 +1838,14 @@ int npc_unload(struct npc_data* nd, bool single) {
for( bl = (struct block_list*)mapit->first(iter); mapit->exists(iter); bl = (struct block_list*)mapit->next(iter) ) {
struct map_session_data *sd = ((TBL_PC*)bl);
if( sd && sd->npc_timer_id != INVALID_TIMER ) {
- const struct TimerData *td = get_timer(sd->npc_timer_id);
+ const struct TimerData *td = iTimer->get_timer(sd->npc_timer_id);
if( td && td->id != nd->bl.id )
continue;
if( td && td->data )
ers_free(timer_event_ers, (void*)td->data);
- delete_timer(sd->npc_timer_id, npc_timerevent);
+ iTimer->delete_timer(sd->npc_timer_id, npc_timerevent);
sd->npc_timer_id = INVALID_TIMER;
}
}
@@ -1870,15 +1853,16 @@ int npc_unload(struct npc_data* nd, bool single) {
if (nd->u.scr.timerid != INVALID_TIMER) {
const struct TimerData *td;
- td = get_timer(nd->u.scr.timerid);
+ td = iTimer->get_timer(nd->u.scr.timerid);
if (td && td->data)
ers_free(timer_event_ers, (void*)td->data);
- delete_timer(nd->u.scr.timerid, npc_timerevent);
+ iTimer->delete_timer(nd->u.scr.timerid, npc_timerevent);
}
if (nd->u.scr.timer_event)
aFree(nd->u.scr.timer_event);
if (nd->src_id == 0) {
if(nd->u.scr.script) {
+ script_stop_instances(nd->bl.id);
script_free_code(nd->u.scr.script);
nd->u.scr.script = NULL;
}
@@ -1892,8 +1876,11 @@ int npc_unload(struct npc_data* nd, bool single) {
guild->flag_remove(nd);
}
- script_stop_sleeptimers(nd->bl.id);
-
+ if( nd->ud != &npc_base_ud ) {
+ aFree(nd->ud);
+ nd->ud = NULL;
+ }
+
aFree(nd);
return 0;
@@ -2060,14 +2047,13 @@ static void npc_parsename(struct npc_data* nd, const char* name, const char* sta
}
//Add then display an npc warp on map
-struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y)
-{
+struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y) {
int i, flag = 0;
struct npc_data *nd;
CREATE(nd, struct npc_data, 1);
nd->bl.id = npc_get_new_npc_id();
- map_addnpc(from_mapid, nd);
+ iMap->addnpc(from_mapid, nd);
nd->bl.prev = nd->bl.next = NULL;
nd->bl.m = from_mapid;
nd->bl.x = from_x;
@@ -2098,10 +2084,9 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short
nd->bl.type = BL_NPC;
nd->subtype = WARP;
npc_setcells(nd);
- map_addblock(&nd->bl);
+ iMap->addblock(&nd->bl);
status_set_viewdata(&nd->bl, nd->class_);
- status_change_init(&nd->bl);
- unit_dataset(&nd->bl);
+ nd->ud = &npc_base_ud;
if( map[nd->bl.m].users )
clif->spawn(&nd->bl);
strdb_put(npcname_db, nd->exname, nd);
@@ -2126,7 +2111,7 @@ static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const
return strchr(start,'\n');// skip and continue
}
- m = map_mapname2mapid(mapname);
+ m = iMap->mapname2mapid(mapname);
i = mapindex_name2id(to_mapname);
if( i == 0 )
{
@@ -2142,7 +2127,7 @@ static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const
CREATE(nd, struct npc_data, 1);
nd->bl.id = npc_get_new_npc_id();
- map_addnpc(m, nd);
+ iMap->addnpc(m, nd);
nd->bl.prev = nd->bl.next = NULL;
nd->bl.m = m;
nd->bl.x = x;
@@ -2164,10 +2149,9 @@ static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const
nd->bl.type = BL_NPC;
nd->subtype = WARP;
npc_setcells(nd);
- map_addblock(&nd->bl);
+ iMap->addblock(&nd->bl);
status_set_viewdata(&nd->bl, nd->class_);
- status_change_init(&nd->bl);
- unit_dataset(&nd->bl);
+ nd->ud = &npc_base_ud;
if( map[nd->bl.m].users )
clif->spawn(&nd->bl);
strdb_put(npcname_db, nd->exname, nd);
@@ -2198,7 +2182,7 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
return strchr(start,'\n');// skip and continue
}
- m = map_mapname2mapid(mapname);
+ m = iMap->mapname2mapid(mapname);
}
if( m != -1 && ( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) ) {
@@ -2222,7 +2206,7 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
break;
}
- if( (id = itemdb_exists(nameid)) == NULL )
+ if( (id = itemdb->exists(nameid)) == NULL )
{
ShowWarning("npc_parse_shop: Invalid sell item in file '%s', line '%d' (id '%d').\n", filepath, strline(buffer,start-buffer), nameid);
p = strchr(p+1,',');
@@ -2275,19 +2259,16 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
++npc_shop;
nd->bl.type = BL_NPC;
nd->subtype = type;
- if( m >= 0 )
- {// normal shop npc
- map_addnpc(m,nd);
- map_addblock(&nd->bl);
+ if( m >= 0 ) {// normal shop npc
+ iMap->addnpc(m,nd);
+ iMap->addblock(&nd->bl);
status_set_viewdata(&nd->bl, nd->class_);
- status_change_init(&nd->bl);
- unit_dataset(&nd->bl);
- nd->ud.dir = dir;
+ nd->ud = &npc_base_ud;
+ nd->dir = dir;
if( map[nd->bl.m].users )
clif->spawn(&nd->bl);
- } else
- {// 'floating' shop?
- map_addiddb(&nd->bl);
+ } else {// 'floating' shop?
+ iMap->addiddb(&nd->bl);
}
strdb_put(npcname_db, nd->exname, nd);
@@ -2429,7 +2410,7 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons
ShowError("npc_parse_script: Invalid placement format for a script in file '%s', line '%d'. Skipping the rest of file...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
return NULL;// unknown format, don't continue
}
- m = map_mapname2mapid(mapname);
+ m = iMap->mapname2mapid(mapname);
}
script_start = strstr(start,",{");
@@ -2485,25 +2466,20 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons
nd->bl.type = BL_NPC;
nd->subtype = SCRIPT;
- if( m >= 0 )
- {
- map_addnpc(m, nd);
- status_change_init(&nd->bl);
- unit_dataset(&nd->bl);
- nd->ud.dir = dir;
+ if( m >= 0 ) {
+ iMap->addnpc(m, nd);
+ nd->ud = &npc_base_ud;
+ nd->dir = dir;
npc_setcells(nd);
- map_addblock(&nd->bl);
- if( class_ >= 0 )
- {
+ iMap->addblock(&nd->bl);
+ if( class_ >= 0 ) {
status_set_viewdata(&nd->bl, nd->class_);
if( map[nd->bl.m].users )
clif->spawn(&nd->bl);
}
- }
- else
- {
- // we skip map_addnpc, but still add it to the list of ID's
- map_addiddb(&nd->bl);
+ } else {
+ // we skip iMap->addnpc, but still add it to the list of ID's
+ iMap->addiddb(&nd->bl);
}
strdb_put(npcname_db, nd->exname, nd);
@@ -2576,19 +2552,16 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
type = dnd->subtype;
// get placement
- if( (type==SHOP || type==CASHSHOP || type==SCRIPT) && strcmp(w1, "-") == 0 )
- {// floating shop/chashshop/script
+ if( (type==SHOP || type==CASHSHOP || type==SCRIPT) && strcmp(w1, "-") == 0 ) {// floating shop/chashshop/script
x = y = dir = 0;
m = -1;
- }
- else
- {
+ } else {
if( sscanf(w1, "%31[^,],%d,%d,%d", mapname, &x, &y, &dir) != 4 )// <map name>,<x>,<y>,<facing>
{
ShowError("npc_parse_duplicate: Invalid placement format for duplicate in file '%s', line '%d'. Skipping line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
return end;// next line, try to continue
}
- m = map_mapname2mapid(mapname);
+ m = iMap->mapname2mapid(mapname);
}
if( m != -1 && ( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) ) {
@@ -2599,8 +2572,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
if( type == WARP && sscanf(w4, "%d,%d", &xs, &ys) == 2 );// <spanx>,<spany>
else if( type == SCRIPT && sscanf(w4, "%d,%d,%d", &class_, &xs, &ys) == 3);// <sprite id>,<triggerX>,<triggerY>
else if( type != WARP ) class_ = atoi(w4);// <sprite id>
- else
- {
+ else {
ShowError("npc_parse_duplicate: Invalid span format for duplicate warp in file '%s', line '%d'. Skipping line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
return end;// next line, try to continue
}
@@ -2618,58 +2590,52 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
nd->src_id = src_id;
nd->bl.type = BL_NPC;
nd->subtype = (enum npc_subtype)type;
- switch( type )
- {
- case SCRIPT:
- ++npc_script;
- nd->u.scr.xs = xs;
- nd->u.scr.ys = ys;
- nd->u.scr.script = dnd->u.scr.script;
- nd->u.scr.label_list = dnd->u.scr.label_list;
- nd->u.scr.label_list_num = dnd->u.scr.label_list_num;
- break;
-
- case SHOP:
- case CASHSHOP:
- ++npc_shop;
- nd->u.shop.shop_item = dnd->u.shop.shop_item;
- nd->u.shop.count = dnd->u.shop.count;
- break;
-
- case WARP:
- ++npc_warp;
- if( !battle_config.warp_point_debug )
- nd->class_ = WARP_CLASS;
- else
- nd->class_ = WARP_DEBUG_CLASS;
- nd->u.warp.xs = xs;
- nd->u.warp.ys = ys;
- nd->u.warp.mapindex = dnd->u.warp.mapindex;
- nd->u.warp.x = dnd->u.warp.x;
- nd->u.warp.y = dnd->u.warp.y;
- break;
+ switch( type ) {
+ case SCRIPT:
+ ++npc_script;
+ nd->u.scr.xs = xs;
+ nd->u.scr.ys = ys;
+ nd->u.scr.script = dnd->u.scr.script;
+ nd->u.scr.label_list = dnd->u.scr.label_list;
+ nd->u.scr.label_list_num = dnd->u.scr.label_list_num;
+ break;
+
+ case SHOP:
+ case CASHSHOP:
+ ++npc_shop;
+ nd->u.shop.shop_item = dnd->u.shop.shop_item;
+ nd->u.shop.count = dnd->u.shop.count;
+ break;
+
+ case WARP:
+ ++npc_warp;
+ if( !battle_config.warp_point_debug )
+ nd->class_ = WARP_CLASS;
+ else
+ nd->class_ = WARP_DEBUG_CLASS;
+ nd->u.warp.xs = xs;
+ nd->u.warp.ys = ys;
+ nd->u.warp.mapindex = dnd->u.warp.mapindex;
+ nd->u.warp.x = dnd->u.warp.x;
+ nd->u.warp.y = dnd->u.warp.y;
+ break;
}
//Add the npc to its location
- if( m >= 0 )
- {
- map_addnpc(m, nd);
- status_change_init(&nd->bl);
- unit_dataset(&nd->bl);
- nd->ud.dir = dir;
+ if( m >= 0 ) {
+ iMap->addnpc(m, nd);
+ nd->ud = &npc_base_ud;
+ nd->dir = dir;
npc_setcells(nd);
- map_addblock(&nd->bl);
- if( class_ >= 0 )
- {
+ iMap->addblock(&nd->bl);
+ if( class_ >= 0 ) {
status_set_viewdata(&nd->bl, nd->class_);
if( map[nd->bl.m].users )
clif->spawn(&nd->bl);
}
- }
- else
- {
- // we skip map_addnpc, but still add it to the list of ID's
- map_addiddb(&nd->bl);
+ } else {
+ // we skip iMap->addnpc, but still add it to the list of ID's
+ iMap->addiddb(&nd->bl);
}
strdb_put(npcname_db, nd->exname, nd);
@@ -2694,32 +2660,28 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
int npc_duplicate4instance(struct npc_data *snd, int16 m) {
char newname[NAME_LENGTH];
- if( map[m].instance_id == 0 )
+ if( map[m].instance_id == -1 )
return 1;
snprintf(newname, ARRAYLENGTH(newname), "dup_%d_%d", map[m].instance_id, snd->bl.id);
- if( npc_name2id(newname) != NULL )
- { // Name already in use
+ if( npc_name2id(newname) != NULL ) { // Name already in use
ShowError("npc_duplicate4instance: the npcname (%s) is already in use while trying to duplicate npc %s in instance %d.\n", newname, snd->exname, map[m].instance_id);
return 1;
}
- if( snd->subtype == WARP )
- { // Adjust destination, if instanced
+ if( snd->subtype == WARP ) { // Adjust destination, if instanced
struct npc_data *wnd = NULL; // New NPC
- int dm = map_mapindex2mapid(snd->u.warp.mapindex), im;
+ int dm = iMap->mapindex2mapid(snd->u.warp.mapindex), im;
if( dm < 0 ) return 1;
- im = instance_mapid2imapid(dm, map[m].instance_id);
- if( im == -1 )
- {
+ if( ( im = instance->mapid2imapid(dm, map[m].instance_id) ) == -1 ) {
ShowError("npc_duplicate4instance: warp (%s) leading to instanced map (%s), but instance map is not attached to current instance.\n", map[dm].name, snd->exname);
return 1;
}
CREATE(wnd, struct npc_data, 1);
wnd->bl.id = npc_get_new_npc_id();
- map_addnpc(m, wnd);
+ iMap->addnpc(m, wnd);
wnd->bl.prev = wnd->bl.next = NULL;
wnd->bl.m = m;
wnd->bl.x = snd->bl.x;
@@ -2736,20 +2698,17 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) {
wnd->bl.type = BL_NPC;
wnd->subtype = WARP;
npc_setcells(wnd);
- map_addblock(&wnd->bl);
+ iMap->addblock(&wnd->bl);
status_set_viewdata(&wnd->bl, wnd->class_);
- status_change_init(&wnd->bl);
- unit_dataset(&wnd->bl);
+ wnd->ud = &npc_base_ud;
if( map[wnd->bl.m].users )
clif->spawn(&wnd->bl);
strdb_put(npcname_db, wnd->exname, wnd);
- }
- else
- {
+ } else {
static char w1[50], w2[50], w3[50], w4[50];
const char* stat_buf = "- call from instancing subsystem -\n";
- snprintf(w1, sizeof(w1), "%s,%d,%d,%d", map[m].name, snd->bl.x, snd->bl.y, snd->ud.dir);
+ snprintf(w1, sizeof(w1), "%s,%d,%d,%d", map[m].name, snd->bl.x, snd->bl.y, snd->dir);
snprintf(w2, sizeof(w2), "duplicate(%s)", snd->exname);
snprintf(w3, sizeof(w3), "%s::%s", snd->name, newname);
@@ -2765,39 +2724,36 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) {
}
//Set mapcell CELL_NPC to trigger event later
-void npc_setcells(struct npc_data* nd)
-{
+void npc_setcells(struct npc_data* nd) {
int16 m = nd->bl.m, x = nd->bl.x, y = nd->bl.y, xs, ys;
int i,j;
- switch(nd->subtype)
- {
- case WARP:
- xs = nd->u.warp.xs;
- ys = nd->u.warp.ys;
- break;
- case SCRIPT:
- xs = nd->u.scr.xs;
- ys = nd->u.scr.ys;
- break;
- default:
- return; // Other types doesn't have touch area
+ switch(nd->subtype) {
+ case WARP:
+ xs = nd->u.warp.xs;
+ ys = nd->u.warp.ys;
+ break;
+ case SCRIPT:
+ xs = nd->u.scr.xs;
+ ys = nd->u.scr.ys;
+ break;
+ default:
+ return; // Other types doesn't have touch area
}
- if (m < 0 || xs < 0 || ys < 0) //invalid range or map
+ if (m < 0 || xs < 0 || ys < 0 || map[m].cell == (struct mapcell *)0xdeadbeaf) //invalid range or map
return;
for (i = y-ys; i <= y+ys; i++) {
for (j = x-xs; j <= x+xs; j++) {
- if (map_getcell(m, j, i, CELL_CHKNOPASS))
+ if (iMap->getcell(m, j, i, CELL_CHKNOPASS))
continue;
- map_setcell(m, j, i, CELL_NPC, true);
+ map[m].setcell(m, j, i, CELL_NPC, true);
}
}
}
-int npc_unsetcells_sub(struct block_list* bl, va_list ap)
-{
+int npc_unsetcells_sub(struct block_list* bl, va_list ap) {
struct npc_data *nd = (struct npc_data*)bl;
int id = va_arg(ap,int);
if (nd->bl.id == id) return 0;
@@ -2805,8 +2761,7 @@ int npc_unsetcells_sub(struct block_list* bl, va_list ap)
return 1;
}
-void npc_unsetcells(struct npc_data* nd)
-{
+void npc_unsetcells(struct npc_data* nd) {
int16 m = nd->bl.m, x = nd->bl.x, y = nd->bl.y, xs, ys;
int i,j, x0, x1, y0, y1;
@@ -2818,23 +2773,23 @@ void npc_unsetcells(struct npc_data* nd)
ys = nd->u.scr.ys;
}
- if (m < 0 || xs < 0 || ys < 0)
+ if (m < 0 || xs < 0 || ys < 0 || map[m].cell == (struct mapcell *)0xdeadbeaf)
return;
//Locate max range on which we can locate npc cells
//FIXME: does this really do what it's supposed to do? [ultramage]
- for(x0 = x-xs; x0 > 0 && map_getcell(m, x0, y, CELL_CHKNPC); x0--);
- for(x1 = x+xs; x1 < map[m].xs-1 && map_getcell(m, x1, y, CELL_CHKNPC); x1++);
- for(y0 = y-ys; y0 > 0 && map_getcell(m, x, y0, CELL_CHKNPC); y0--);
- for(y1 = y+ys; y1 < map[m].ys-1 && map_getcell(m, x, y1, CELL_CHKNPC); y1++);
+ for(x0 = x-xs; x0 > 0 && iMap->getcell(m, x0, y, CELL_CHKNPC); x0--);
+ for(x1 = x+xs; x1 < map[m].xs-1 && iMap->getcell(m, x1, y, CELL_CHKNPC); x1++);
+ for(y0 = y-ys; y0 > 0 && iMap->getcell(m, x, y0, CELL_CHKNPC); y0--);
+ for(y1 = y+ys; y1 < map[m].ys-1 && iMap->getcell(m, x, y1, CELL_CHKNPC); y1++);
//Erase this npc's cells
for (i = y-ys; i <= y+ys; i++)
for (j = x-xs; j <= x+xs; j++)
- map_setcell(m, j, i, CELL_NPC, false);
+ map[m].setcell(m, j, i, CELL_NPC, false);
//Re-deploy NPC cells for other nearby npcs.
- map_foreachinarea( npc_unsetcells_sub, m, x0, y0, x1, y1, BL_NPC, nd->bl.id );
+ iMap->foreachinarea( npc_unsetcells_sub, m, x0, y0, x1, y1, BL_NPC, nd->bl.id );
}
void npc_movenpc(struct npc_data* nd, int16 x, int16 y)
@@ -2845,9 +2800,9 @@ void npc_movenpc(struct npc_data* nd, int16 x, int16 y)
x = cap_value(x, 0, map[m].xs-1);
y = cap_value(y, 0, map[m].ys-1);
- map_foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
- map_moveblock(&nd->bl, x, y, gettick());
- map_foreachinrange(clif->insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
+ iMap->foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
+ iMap->moveblock(&nd->bl, x, y, iTimer->gettick());
+ iMap->foreachinrange(clif->insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
}
/// Changes the display name of the npc.
@@ -2910,7 +2865,7 @@ int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const c
return 1;
}
- if( ev->nd->sc.option&OPTION_INVISIBLE ) { // Disabled npc, shouldn't trigger event.
+ if( ev->nd->option&OPTION_INVISIBLE ) { // Disabled npc, shouldn't trigger event.
npc_event_dequeue(sd);
return 2;
}
@@ -2994,8 +2949,7 @@ void npc_parse_mob2(struct spawn_data* mob)
{
int i;
- for( i = mob->active; i < mob->num; ++i )
- {
+ for( i = mob->active; i < mob->num; ++i ) {
struct mob_data* md = mob_spawn_dataset(mob);
md->spawn = mob;
md->spawn->active++;
@@ -3030,7 +2984,7 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c
ShowError("npc_parse_mob: Unknown map '%s' in file '%s', line '%d'.\n", mapname, filepath, strline(buffer,start-buffer));
return strchr(start,'\n');// skip and continue
}
- m = map_mapname2mapid(mapname);
+ m = iMap->mapname2mapid(mapname);
if( m < 0 )//Not loaded on this map-server instance.
return strchr(start,'\n');// skip and continue
mob.m = (unsigned short)m;
@@ -3150,19 +3104,17 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c
memcpy(data, &mob, sizeof(struct spawn_data));
// spawn / cache the new mobs
- if( battle_config.dynamic_mobs && map_addmobtolist(data->m, data) >= 0 )
- {
+ if( battle_config.dynamic_mobs && iMap->addmobtolist(data->m, data) >= 0 ) {
data->state.dynamic = true;
npc_cache_mob += data->num;
// check if target map has players
// (usually shouldn't occur when map server is just starting,
// but not the case when we do @reloadscript
- if( map[data->m].users > 0 )
+ if( map[data->m].users > 0 ) {
npc_parse_mob2(data);
- }
- else
- {
+ }
+ } else {
data->state.dynamic = false;
npc_parse_mob2(data);
npc_delay_mob += data->num;
@@ -3188,7 +3140,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char
ShowError("npc_parse_mapflag: Invalid mapflag definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
return strchr(start,'\n');// skip and continue
}
- m = map_mapname2mapid(mapname);
+ m = iMap->mapname2mapid(mapname);
if( m < 0 )
{
ShowWarning("npc_parse_mapflag: Unknown map in file '%s', line '%d' : %s\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", mapname, filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
@@ -3257,7 +3209,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char
ShowWarning("npc_parse_mapflag: You can't set PvP and BattleGround flags for the same map! Removing BattleGround flag from %s (file '%s', line '%d').\n", map[m].name, filepath, strline(buffer,start-buffer));
}
if( state && (zone = strdb_get(zone_db, MAP_ZONE_PVP_NAME)) && map[m].zone != zone ) {
- map_zone_change(m,zone,start,buffer,filepath);
+ iMap->zone_change(m,zone,start,buffer,filepath);
} else if ( !state ) {
map[m].zone = &map_zone_pk;
}
@@ -3273,7 +3225,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char
int drop_id = 0, drop_type = 0;
if (!strcmpi(drop_arg1, "random"))
drop_id = -1;
- else if (itemdb_exists((drop_id = atoi(drop_arg1))) == NULL)
+ else if (itemdb->exists((drop_id = atoi(drop_arg1))) == NULL)
drop_id = 0;
if (!strcmpi(drop_arg2, "inventory"))
drop_type = 1;
@@ -3282,16 +3234,11 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char
else if (!strcmpi(drop_arg2,"all"))
drop_type = 3;
- if (drop_id != 0){
- int i;
- for (i = 0; i < MAX_DROP_PER_MAP; i++) {
- if (map[m].drop_list[i].drop_id == 0){
- map[m].drop_list[i].drop_id = drop_id;
- map[m].drop_list[i].drop_type = drop_type;
- map[m].drop_list[i].drop_per = drop_per;
- break;
- }
- }
+ if (drop_id != 0) {
+ RECREATE(map[m].drop_list, struct map_drop_list, ++map[m].drop_list_count);
+ map[m].drop_list[map[m].drop_list_count-1].drop_id = drop_id;
+ map[m].drop_list[map[m].drop_list_count-1].drop_type = drop_type;
+ map[m].drop_list[map[m].drop_list_count-1].drop_per = drop_per;
map[m].flag.pvp_nightmaredrop = 1;
}
} else if (!state) //Disable
@@ -3312,7 +3259,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char
ShowWarning("npc_parse_mapflag: You can't set GvG and BattleGround flags for the same map! Removing BattleGround flag from %s (file '%s', line '%d').\n", map[m].name, filepath, strline(buffer,start-buffer));
}
if( state && (zone = strdb_get(zone_db, MAP_ZONE_GVG_NAME)) && map[m].zone != zone ) {
- map_zone_change(m,zone,start,buffer,filepath);
+ iMap->zone_change(m,zone,start,buffer,filepath);
}
}
else if (!strcmpi(w3,"gvg_noparty"))
@@ -3347,7 +3294,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char
}
if( state && (zone = strdb_get(zone_db, MAP_ZONE_BG_NAME)) && map[m].zone != zone ) {
- map_zone_change(m,zone,start,buffer,filepath);
+ iMap->zone_change(m,zone,start,buffer,filepath);
}
}
else if (!strcmpi(w3,"noexppenalty"))
@@ -3540,7 +3487,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char
if( !(zone = strdb_get(zone_db, w4)) ) {
ShowWarning("npc_parse_mapflag: Invalid zone '%s'! removing flag from %s (file '%s', line '%d').\n", w4, map[m].name, filepath, strline(buffer,start-buffer));
} else if( map[m].zone != zone ) {
- map_zone_change(m,zone,start,buffer,filepath);
+ iMap->zone_change(m,zone,start,buffer,filepath);
}
} else if ( !strcmpi(w3,"nomapchannelautojoin") ) {
map[m].flag.chsysnolocalaj = state;
@@ -3666,7 +3613,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit)
p = strchr(p,'\n');// next line
continue;
}
- m = map_mapname2mapid(mapname);
+ m = iMap->mapname2mapid(mapname);
if( m < 0 )
{// "mapname" is not assigned to this server, we must skip the script info...
if( strcasecmp(w2,"script") == 0 && count > 3 )
@@ -3851,7 +3798,7 @@ int npc_reload(void) {
if(battle_config.dynamic_mobs)
{// dynamic check by [random]
- for (m = 0; m < map_num; m++) {
+ for (m = 0; m < iMap->map_num; m++) {
for (i = 0; i < MAX_MOB_LIST_PER_MAP; i++) {
if (map[m].moblist[i] != NULL) {
aFree(map[m].moblist[i]);
@@ -3859,7 +3806,7 @@ int npc_reload(void) {
}
if( map[m].mob_delete_timer != INVALID_TIMER )
{ // Mobs were removed anyway,so delete the timer [Inkfish]
- delete_timer(map[m].mob_delete_timer, map_removemobs_timer);
+ iTimer->delete_timer(map[m].mob_delete_timer, iMap->removemobs_timer);
map[m].mob_delete_timer = INVALID_TIMER;
}
}
@@ -3875,7 +3822,7 @@ int npc_reload(void) {
npc_mob = npc_cache_mob = npc_delay_mob = 0;
// reset mapflags
- map_flags_init();
+ iMap->flags_init();
//TODO: the following code is copy-pasted from do_init_npc(); clean it up
// Reloading npcs now
@@ -3891,13 +3838,12 @@ int npc_reload(void) {
"\t-'"CL_WHITE"%d"CL_RESET"' Mobs Cached\n"
"\t-'"CL_WHITE"%d"CL_RESET"' Mobs Not Cached\n",
npc_id - npc_new_min, npc_warp, npc_shop, npc_script, npc_mob, npc_cache_mob, npc_delay_mob);
-
- do_final_instance();
-
- for( i = 0; i < ARRAYLENGTH(instance); ++i )
- instance_init(instance[i].instance_id);
+
+ for(i = 0; i < instance->instances; i++) {
+ instance->destroy(i);
+ }
- map_zone_init();
+ iMap->zone_init();
npc->motd = npc_name2id("HerculesMOTD"); /* [Ind/Hercules] */
@@ -3966,18 +3912,18 @@ static void npc_debug_warps_sub(struct npc_data* nd)
if (nd->bl.type != BL_NPC || nd->subtype != WARP || nd->bl.m < 0)
return;
- m = map_mapindex2mapid(nd->u.warp.mapindex);
+ m = iMap->mapindex2mapid(nd->u.warp.mapindex);
if (m < 0) return; //Warps to another map, nothing to do about it.
if (nd->u.warp.x == 0 && nd->u.warp.y == 0) return; // random warp
- if (map_getcell(m, nd->u.warp.x, nd->u.warp.y, CELL_CHKNPC)) {
+ if (iMap->getcell(m, nd->u.warp.x, nd->u.warp.y, CELL_CHKNPC)) {
ShowWarning("Warp %s at %s(%d,%d) warps directly on top of an area npc at %s(%d,%d)\n",
nd->name,
map[nd->bl.m].name, nd->bl.x, nd->bl.y,
map[m].name, nd->u.warp.x, nd->u.warp.y
);
}
- if (map_getcell(m, nd->u.warp.x, nd->u.warp.y, CELL_CHKNOPASS)) {
+ if (iMap->getcell(m, nd->u.warp.x, nd->u.warp.y, CELL_CHKNOPASS)) {
ShowWarning("Warp %s at %s(%d,%d) warps to a non-walkable tile at %s(%d,%d)\n",
nd->name,
map[nd->bl.m].name, nd->bl.x, nd->bl.y,
@@ -3989,7 +3935,7 @@ static void npc_debug_warps_sub(struct npc_data* nd)
static void npc_debug_warps(void)
{
int16 m, i;
- for (m = 0; m < map_num; m++)
+ for (m = 0; m < iMap->map_num; m++)
for (i = 0; i < map[m].npc_num; i++)
npc_debug_warps_sub(map[m].npc[i]);
}
@@ -4002,8 +3948,18 @@ int do_init_npc(void)
struct npc_src_list *file;
int i;
+ memset(&npc_base_ud, 0, sizeof( struct unit_data) );
+ npc_base_ud.bl = NULL;
+ npc_base_ud.walktimer = INVALID_TIMER;
+ npc_base_ud.skilltimer = INVALID_TIMER;
+ npc_base_ud.attacktimer = INVALID_TIMER;
+ npc_base_ud.attackabletime =
+ npc_base_ud.canact_tick =
+ npc_base_ud.canmove_tick = iTimer->gettick();
+
//Stock view data for normal npcs.
memset(&npc_viewdb, 0, sizeof(npc_viewdb));
+
npc_viewdb[0].class_ = INVISIBLE_CLASS; //Invisible class is stored here.
for( i = 1; i < MAX_NPC_CLASS; i++ )
npc_viewdb[i].class_ = i;
@@ -4030,8 +3986,8 @@ int do_init_npc(void)
"\t-'"CL_WHITE"%d"CL_RESET"' Mobs Cached\n"
"\t-'"CL_WHITE"%d"CL_RESET"' Mobs Not Cached\n",
npc_id - START_NPC_NUM, npc_warp, npc_shop, npc_script, npc_mob, npc_cache_mob, npc_delay_mob);
-
- map_zone_init();
+
+ iMap->zone_init();
npc->motd = npc_name2id("HerculesMOTD"); /* [Ind/Hercules] */
@@ -4043,8 +3999,8 @@ int do_init_npc(void)
if (battle_config.warp_point_debug)
npc_debug_warps();
- add_timer_func_list(npc_event_do_clock,"npc_event_do_clock");
- add_timer_func_list(npc_timerevent,"npc_timerevent");
+ iTimer->add_timer_func_list(npc_event_do_clock,"npc_event_do_clock");
+ iTimer->add_timer_func_list(npc_timerevent,"npc_timerevent");
// Init dummy NPC
fake_nd = (struct npc_data *)aCalloc(1,sizeof(struct npc_data));
@@ -4061,13 +4017,13 @@ int do_init_npc(void)
strdb_put(npcname_db, fake_nd->exname, fake_nd);
fake_nd->u.scr.timerid = INVALID_TIMER;
- map_addiddb(&fake_nd->bl);
+ iMap->addiddb(&fake_nd->bl);
// End of initialization
return 0;
}
void npc_defaults(void) {
npc = &npc_s;
-
+
npc->motd = NULL;
}
diff --git a/src/map/npc.h b/src/map/npc.h
index 8a8b14d6e..16e6fe74c 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -12,6 +12,7 @@ struct block_list;
struct npc_data;
struct view_data;
+struct unit_data npc_base_ud;
struct npc_timerevent_list {
int timer,pos;
@@ -26,9 +27,9 @@ struct npc_item_list {
struct npc_data {
struct block_list bl;
- struct unit_data ud; //Because they need to be able to move....
+ struct unit_data *ud;
struct view_data *vd;
- struct status_change sc; //They can't have status changes, but.. they want the visual opt values.
+ unsigned int option;
struct npc_data *master_nd;
short class_;
short speed;
@@ -37,12 +38,13 @@ struct npc_data {
int chat_id;
int touching_id;
unsigned int next_walktime;
-
+ uint8 dir;
+
unsigned size : 2;
struct status_data status;
- unsigned int level;
- unsigned int stat_point;
+ unsigned short level;
+ unsigned short stat_point;
void* chatdb; // pointer to a npc_parse struct (see npc_chat.c)
char* path;/* path dir */
diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c
index 81373bbb6..c7faa2df6 100644
--- a/src/map/npc_chat.c
+++ b/src/map/npc_chat.c
@@ -411,7 +411,7 @@ int buildin_defpattern(struct script_state* st)
int setid = script->conv_num(st,& (st->stack->stack_data[st->start+2]));
const char* pattern = script->conv_str(st,& (st->stack->stack_data[st->start+3]));
const char* label = script->conv_str(st,& (st->stack->stack_data[st->start+4]));
- struct npc_data* nd = (struct npc_data *)map_id2bl(st->oid);
+ struct npc_data* nd = (struct npc_data *)iMap->id2bl(st->oid);
npc_chat_def_pattern(nd, setid, pattern, label);
@@ -421,7 +421,7 @@ int buildin_defpattern(struct script_state* st)
int buildin_activatepset(struct script_state* st)
{
int setid = script->conv_num(st,& (st->stack->stack_data[st->start+2]));
- struct npc_data* nd = (struct npc_data *)map_id2bl(st->oid);
+ struct npc_data* nd = (struct npc_data *)iMap->id2bl(st->oid);
activate_pcreset(nd, setid);
@@ -431,7 +431,7 @@ int buildin_activatepset(struct script_state* st)
int buildin_deactivatepset(struct script_state* st)
{
int setid = script->conv_num(st,& (st->stack->stack_data[st->start+2]));
- struct npc_data* nd = (struct npc_data *)map_id2bl(st->oid);
+ struct npc_data* nd = (struct npc_data *)iMap->id2bl(st->oid);
deactivate_pcreset(nd, setid);
@@ -441,7 +441,7 @@ int buildin_deactivatepset(struct script_state* st)
int buildin_deletepset(struct script_state* st)
{
int setid = script->conv_num(st,& (st->stack->stack_data[st->start+2]));
- struct npc_data* nd = (struct npc_data *)map_id2bl(st->oid);
+ struct npc_data* nd = (struct npc_data *)iMap->id2bl(st->oid);
delete_pcreset(nd, setid);
diff --git a/src/map/packets.h b/src/map/packets.h
index 60ee8c7ca..f90c3b29d 100644
--- a/src/map/packets.h
+++ b/src/map/packets.h
@@ -10,6 +10,10 @@
#define packet(a,b,...)
#endif
+#ifndef packetKeys
+ #define packetKeys(a,b,c)
+#endif
+
/*
* packet syntax
* - packet(packet_id,length)
@@ -1869,6 +1873,10 @@ packet(0x020d,-1);
packet(0x0838,6,clif->pSolveCharName,2);
packet(0x0439,8,clif->pUseItem,2,4);
packet(0x08d2,10);
+ packet(0x08d7,28,clif->pBGQueueRegister,2);
+ packet(0x090a,26,clif->pBGQueueCheckState,2);
+ packet(0x08da,26,clif->pBGQueueRevokeReq,2);
+ packet(0x08e0,51,clif->pBGQueueBattleBeginAck,2);
#endif
//2011-11-02aRagexe
@@ -1918,7 +1926,7 @@ packet(0x020d,-1);
packet(0x0885,7,clif->pActionRequest,2,6);
packet(0x0889,10,clif->pUseSkillToId,2,4,6);
packet(0x0870,-1,clif->pItemListWindowSelected,2,4,8);
- packet(0x0926,18,clif->pPartyBookingRegisterReq,2,4,6);
+ packet(0x0365,18,clif->pPartyBookingRegisterReq,2,4,6);
packet(0x0815,-1,clif->pReqOpenBuyingStore,2,4,8,9,89);
packet(0x0817,2,clif->pReqCloseBuyingStore,0);
packet(0x0360,6,clif->pReqClickBuyingStore,2);
@@ -1960,7 +1968,11 @@ packet(0x020d,-1);
packet(0x0366,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10);
packet(0x0889,6,clif->pGetCharNameRequest,2);
packet(0x0884,6,clif->pSolveCharName,2);
+#ifndef PACKETVER_RE
+ packet(0x091D,18,clif->pPartyBookingRegisterReq,2,4,6);
+#else
packet(0x08E5,41,clif->pPartyBookingRegisterReq,2,4);
+#endif
packet(0x08E6,4);
packet(0x08E7,10,clif->pPartyBookingSearchReq,2);
packet(0x08E8,-1);
@@ -1970,9 +1982,11 @@ packet(0x020d,-1);
packet(0x08EC,73);
packet(0x08ED,43);
packet(0x08EE,6);
+#ifdef PARTY_RECRUIT
packet(0x08EF,6,clif->pDull,2); //bookingignorereq
- packet(0x08F0,6);
+ packet(0x08F0,6,clif->pDull,2);
packet(0x08F1,6,clif->pDull,2); //bookingjoinpartyreq
+#endif
packet(0x08F2,36);
packet(0x08F3,-1);
packet(0x08F4,6);
@@ -1981,11 +1995,13 @@ packet(0x020d,-1);
packet(0x08F7,3);
packet(0x08F8,7);
packet(0x08F9,6);
+#ifdef PARTY_RECRUIT
+ packet(0x08F9,6,clif->pDull,2);
+#endif
packet(0x08FA,6);
packet(0x08FB,6,clif->pDull,2); //bookingcanceljoinparty
packet(0x0907,5,clif->pMoveItem,2,4);
packet(0x0908,5);
- packet(0x08D7,28,clif->pDull,2,4); //battlegroundreg
packet(0x08CF,10);//Amulet spirits
packet(0x0977,14);//Monster HP Bar
#endif
@@ -2011,6 +2027,12 @@ packet(0x020d,-1);
packet(0x0916,26,clif->pGuildInvite2,2);
#endif
+#ifndef PACKETVER_RE
+#if PACKETVER >= 20120604
+ packet(0x0861,18,clif->pPartyBookingRegisterReq,2,4,6);
+#endif
+#endif
+
//2012-06-18aRagexeRE
#if PACKETVER >= 20120618
packet(0x0983,29);
@@ -2041,9 +2063,36 @@ packet(0x020d,-1);
packet(0x0886,2,clif->pReqCloseBuyingStore,0);
#endif
-//2012-07-16aRagExe (special thanks to Yommy!)
+//2012-07-16aRagExe (special thanks to Yommy/Frost!)
#if PACKETVER >= 20120716
+ packet(0x0879,18,clif->pPartyBookingRegisterReq,2,4,6);
+ packet(0x023B,26,clif->pFriendsListAdd,2);
+ packet(0x0361,5,clif->pHomMenu,2,4);
+ packet(0x0819,36,clif->pStoragePassword,0);
+ packet(0x0802,26,clif->pPartyInvite2,2);
+ packet(0x022D,19,clif->pWantToConnection,2,6,10,14,18);
+ packet(0x0369,7,clif->pActionRequest,2,6);
+ packet(0x083C,10,clif->pUseSkillToId,2,4,6);
+ packet(0x0439,8,clif->pUseItem,2,4);
+ packet(0x0281,-1,clif->pItemListWindowSelected,2,4,8);
+ packet(0x0815,-1,clif->pReqOpenBuyingStore,2,4,8,9,89);
+ packet(0x0817,2,clif->pReqCloseBuyingStore,0);
+ packet(0x0360,6,clif->pReqClickBuyingStore,2);
+ packet(0x0940,-1,clif->pReqTradeBuyingStore,2,4,8,12);
+ packet(0x0811,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15);
+ packet(0x0835,2,clif->pSearchStoreInfoNextPage,0);
+ packet(0x0838,12,clif->pSearchStoreInfoListItemClick,2,6,10);
+ packet(0x0437,5,clif->pWalkToXY,2);
+ packet(0x035F,6,clif->pTickSend,2);
+ packet(0x0202,5,clif->pChangeDir,2,4);
+ packet(0x07E4,6,clif->pTakeItem,2);
+ packet(0x0362,6,clif->pDropItem,2,4);
+ packet(0x07EC,8,clif->pMoveToKafra,2,4);
packet(0x0364,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);
#endif
//2013-03-20Ragexe (Judas + Yommy)
@@ -2083,6 +2132,7 @@ packet(0x020d,-1);
// New Packets
packet(0x0998,8,clif->pEquipItem,2,4);
packet(0x0447,2); // PACKET_CZ_BLOCKING_PLAY_CANCEL
+ packet(0x099f,24);
// New Packets End
#endif
@@ -2121,4 +2171,287 @@ 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
+
+//2013-05-29Ragexe (Shakto)
+#if PACKETVER >= 20130529
+ packet(0x0890,7,clif->pActionRequest,2,6);
+ packet(0x0438,10,clif->pUseSkillToId,2,4,6);
+ packet(0x0876,5,clif->pWalkToXY,2);
+ packet(0x0897,6,clif->pTickSend,2);
+ packet(0x0951,5,clif->pChangeDir,2,4);
+ packet(0x0895,6,clif->pTakeItem,2);
+ packet(0x08A7,6,clif->pDropItem,2,4);
+ packet(0x0938,8,clif->pMoveToKafra,2,4);
+ packet(0x0957,8,clif->pMoveFromKafra,2,4);
+ packet(0x0917,10,clif->pUseSkillToPos,2,4,6,8);
+ packet(0x085E,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10);
+ packet(0x0863,6,clif->pGetCharNameRequest,2);
+ packet(0x0937,6,clif->pSolveCharName,2);
+ packet(0x085A,12,clif->pSearchStoreInfoListItemClick,2,6,10);
+ packet(0x0941,2,clif->pSearchStoreInfoNextPage,0);
+ packet(0x0918,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15);
+ packet(0x0936,-1,clif->pReqTradeBuyingStore,2,4,8,12);
+ packet(0x0892,6,clif->pReqClickBuyingStore,2);
+ packet(0x0964,2,clif->pReqCloseBuyingStore,0);
+ packet(0x0869,-1,clif->pReqOpenBuyingStore,2,4,8,9,89);
+ packet(0x0874,41,clif->pPartyBookingRegisterReq,2,4);
+ // packet(0x088E,8); // CZ_JOIN_BATTLE_FIELD
+ packet(0x0958,-1,clif->pItemListWindowSelected,2,4,8);
+ packet(0x0919,19,clif->pWantToConnection,2,6,10,14,18);
+ packet(0x08A8,26,clif->pPartyInvite2,2);
+ // packet(0x0888,4); // CZ_GANGSI_RANK
+ packet(0x0877,26,clif->pFriendsListAdd,2);
+ packet(0x023B,5,clif->pHomMenu,2,4);
+ packet(0x0956,36,clif->pStoragePassword,0);
+#endif
+
+//2013-06-05Ragexe (Shakto)
+#if PACKETVER >= 20130605
+ 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(0x0202,5,clif->pChangeDir,2,4);
+ packet(0x07E4,6,clif->pTakeItem,2);
+ packet(0x0362,6,clif->pDropItem,2,4);
+ packet(0x07EC,8,clif->pMoveToKafra,2,4);
+ packet(0x0364,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(0x0365,41,clif->pPartyBookingRegisterReq,2,4);
+ // packet(0x0363,8); // CZ_JOIN_BATTLE_FIELD
+ packet(0x0281,-1,clif->pItemListWindowSelected,2,4,8);
+ packet(0x022D,19,clif->pWantToConnection,2,6,10,14,18);
+ packet(0x0802,26,clif->pPartyInvite2,2);
+ // packet(0x0436,4); // CZ_GANGSI_RANK
+ packet(0x023B,26,clif->pFriendsListAdd,2);
+ packet(0x0361,5,clif->pHomMenu,2,4);
+ packet(0x0883,36,clif->pStoragePassword,0);
+#endif
+
+/* PacketKeys: http://hercules.ws/board/topic/1105-hercules-wpe-free-june-14th-patch/ */
+#if PACKETVER >= 20110817
+ packetKeys(0x053D5CED,0x3DED6DED,0x6DED6DED); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20110824
+ packetKeys(0x35C91401,0x262A5556,0x28FA03AA); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20110831
+ packetKeys(0x3AD67ED0,0x44703C69,0x6F876809); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20110906
+ packetKeys(0x3AD67ED0,0x44703C69,0x6F876809); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20111005
+ packetKeys(0x291E6762,0x77CD391A,0x60AC2F16); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20111012
+ packetKeys(0x7F3C2D29,0x59B01DE6,0x1DBB44CA); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20111021
+ packetKeys(0x357D55DC,0x5A8D759F,0x245C30F5); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20111025
+ packetKeys(0x50AE1A63,0x3CE579B5,0x29C10406); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20111102
+ packetKeys(0x5324329D,0x5D545D52,0x06137269); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20111109
+ packetKeys(0x0B642BDA,0x6ECB1D1C,0x61C7454B); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20111122
+ packetKeys(0x3B550F07,0x1F666C7C,0x60304EF5); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20111207
+ packetKeys(0x2A610886,0x3E09165E,0x57C11888); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20111214
+ packetKeys(0x5151306B,0x7AE32886,0x53060628); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20111220
+ packetKeys(0x05D53871,0x7D0027B4,0x29975333); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20111228
+ packetKeys(0x0FF87E93,0x6CFF7860,0x3A3D1DEC); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120104
+ packetKeys(0x262034A1,0x674542A5,0x73A50BA5); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120111
+ packetKeys(0x2B412AFC,0x4FF94487,0x6705339D); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120120
+ packetKeys(0x504345D0,0x3D427B1B,0x794C2DCC); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120202
+ packetKeys(0x2CFC0A71,0x2BA91D8D,0x087E39E0); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120207
+ packetKeys(0x1D373F5D,0x5ACD604D,0x1C4D7C4D); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120214
+ packetKeys(0x7A255EFA,0x30977276,0x2D4A0448); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120229
+ packetKeys(0x520B4C64,0x2800407D,0x47651458); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120307
+ packetKeys(0x382A6DEF,0x5CBE7202,0x61F46637); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120314
+ packetKeys(0x689C1729,0x11812639,0x60F82967); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120321
+ packetKeys(0x21F9683F,0x710C5CA5,0x1FD910E9); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120328
+ packetKeys(0x75B8553B,0x37F20B12,0x385C2B40); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120404
+ packetKeys(0x0036310C,0x2DCD0BED,0x1EE62A78); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120410
+ packetKeys(0x01581359,0x452D6FFA,0x6AFB6E2E); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120418
+ packetKeys(0x01540E48,0x13041224,0x31247924); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120424
+ packetKeys(0x411D1DBB,0x4CBA4848,0x1A432FC4); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120509
+ packetKeys(0x16CF3301,0x1F472B9B,0x0B4A3CD2); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120515
+ packetKeys(0x4A715EF9,0x79103E4F,0x405C1238); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120525
+ packetKeys(0x70EB4CCB,0x0487713C,0x398D4B08); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120605
+ packetKeys(0x68CA3080,0x31B74BDD,0x505208F1); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120612
+ packetKeys(0x32E45D64,0x35643564,0x35643564); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120618
+ packetKeys(0x261F261F,0x261F261F,0x261F261F); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120702
+ packetKeys(0x25733B31,0x53486CFD,0x398649BD); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20120716
+ packetKeys(0x76052205,0x22052205,0x22052205); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20130320
+ packetKeys(0x3F094C49,0x55F86C1E,0x58AA359A); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20130514
+ packetKeys(0x75794A38,0x58A96BC1,0x296E6FB8); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20130522
+ packetKeys(0x6948050B,0x06511D9D,0x725D4DF1); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20130529
+ packetKeys(0x023A6C87,0x14BF1F1E,0x5CC70CC9); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20130605
+ packetKeys(0x646E08D9,0x5F153AB5,0x61B509B5); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20130612
+ packetKeys(0x6D166F66,0x3C000FCF,0x295B0FCB); /* Thanks to Shakto */
+#endif
+
+#if PACKETVER >= 20130618
+ packetKeys(0x434115DE,0x34A10FE9,0x6791428E); /* Thanks to Shakto */
+#endif
+
+
#endif /* _PACKETS_H_ */
diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h
index c873d3ad3..d77784dc5 100644
--- a/src/map/packets_struct.h
+++ b/src/map/packets_struct.h
@@ -72,6 +72,8 @@ enum packet_headers {
#else
authokType = 0x2eb,
#endif
+ script_clearType = 0x8d6,
+ package_item_announceType = 0x7fd,
#if PACKETVER < 4
unit_walkingType = 0x7b,
#elif PACKETVER < 7
@@ -87,6 +89,15 @@ enum packet_headers {
#else
unit_walkingType = 0x914,
#endif
+ bgqueue_ackType = 0x8d8,
+ bgqueue_notice_deleteType = 0x8db,
+ bgqueue_registerType = 0x8d7,
+ bgqueue_updateinfoType = 0x8d9,
+ bgqueue_checkstateType = 0x90a,
+ bgqueue_revokereqType = 0x8da,
+ bgqueue_battlebeginackType = 0x8e0,
+ bgqueue_notify_entryType = 0x8d9,
+ bgqueue_battlebegins = 0x8df,
#if PACKETVER > 20130000 /* not sure date */
dropflooritemType = 0x84b,
#else
@@ -391,6 +402,75 @@ struct packet_maptypeproperty2 {
} flag;
} __attribute__((packed));
+struct packet_bgqueue_ack {
+ short PacketType;
+ short type;
+ char bg_name[NAME_LENGTH];
+} __attribute__((packed));
+
+struct packet_bgqueue_notice_delete {
+ short PacketType;
+ short type;
+ char bg_name[NAME_LENGTH];
+} __attribute__((packed));
+
+struct packet_bgqueue_register {
+ short PacketType;
+ short type;
+ char bg_name[NAME_LENGTH];
+} __attribute__((packed));
+
+struct packet_bgqueue_update_info {
+ short PacketType;
+ char bg_name[NAME_LENGTH];
+ int position;
+} __attribute__((packed));
+
+struct packet_bgqueue_checkstate {
+ short PacketType;
+ char bg_name[NAME_LENGTH];
+} __attribute__((packed));
+
+struct packet_bgqueue_revoke_req {
+ short PacketType;
+ char bg_name[NAME_LENGTH];
+} __attribute__((packed));
+
+struct packet_bgqueue_battlebegin_ack {
+ short PacketType;
+ short result;
+ char bg_name[NAME_LENGTH];
+ char game_name[NAME_LENGTH];
+} __attribute__((packed));
+
+struct packet_bgqueue_notify_entry {
+ short PacketType;
+ char name[NAME_LENGTH];
+ int position;
+} __attribute__((packed));
+
+struct packet_bgqueue_battlebegins {
+ short PacketType;
+ char bg_name[NAME_LENGTH];
+ char game_name[NAME_LENGTH];
+} __attribute__((packed));
+
+struct packet_script_clear {
+ short PacketType;
+ unsigned int NpcID;
+} __attribute__((packed));
+/* made possible thanks to Yommy!! */
+struct packet_package_item_announce {
+ short PacketType;
+ short PacketLength;
+ unsigned char type;
+ unsigned short ItemID;
+ char len;
+ char Name[NAME_LENGTH];
+ char unknown;
+ unsigned short BoxItemID;
+} __attribute__((packed));
+
#pragma pack(pop)
#endif /* _PACKETS_STRUCT_H_ */
diff --git a/src/map/party.c b/src/map/party.c
index 8a632a8ef..306c68e3e 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -50,8 +50,6 @@ static void party_fill_member(struct party_member* member, struct map_session_da
member->online = 1;
member->leader = leader;
}
-
-
/// Get the member_id of a party member.
/// Return -1 if not in party.
int party_getmemberid(struct party_data* p, struct map_session_data* sd)
@@ -86,7 +84,7 @@ struct map_session_data* party_getavailablesd(struct party_data *p)
static TBL_PC* party_sd_check(int party_id, int account_id, int char_id)
{
- TBL_PC* sd = map_id2sd(account_id);
+ TBL_PC* sd = iMap->id2sd(account_id);
if (!(sd && sd->status.char_id == char_id))
return NULL;
@@ -101,14 +99,21 @@ static TBL_PC* party_sd_check(int party_id, int account_id, int char_id)
return sd;
}
-
+int party_db_final(DBKey key, DBData *data, va_list ap) {
+ struct party_data *p;
+
+ if( ( p = DB->data2ptr(data) ) && p->instance )
+ aFree(p->instance);
+
+ return 0;
+}
/*==========================================
* Destructor
* Called in map shutdown, cleanup var
*------------------------------------------*/
void do_final_party(void)
{
- party_db->destroy(party_db,NULL);
+ party_db->destroy(party_db,party_db_final);
party_booking_db->destroy(party_booking_db,NULL); // Party Booking [Spiria]
}
// Constructor, init vars
@@ -116,8 +121,8 @@ void do_init_party(void)
{
party_db = idb_alloc(DB_OPT_RELEASE_DATA);
party_booking_db = idb_alloc(DB_OPT_RELEASE_DATA); // Party Booking [Spiria]
- add_timer_func_list(party_send_xy_timer, "party_send_xy_timer");
- add_timer_interval(gettick()+battle_config.party_update_interval, party_send_xy_timer, 0, 0, battle_config.party_update_interval);
+ iTimer->add_timer_func_list(party_send_xy_timer, "party_send_xy_timer");
+ iTimer->add_timer_interval(iTimer->gettick()+battle_config.party_update_interval, party_send_xy_timer, 0, 0, battle_config.party_update_interval);
}
/// Party data lookup using party id.
@@ -175,7 +180,7 @@ int party_create(struct map_session_data *sd,char *name,int item,int item2)
void party_created(int account_id,int char_id,int fail,int party_id,char *name)
{
struct map_session_data *sd;
- sd=map_id2sd(account_id);
+ sd=iMap->id2sd(account_id);
if (!sd || sd->status.char_id != char_id || !sd->party_creating )
{ //Character logged off before creation ack?
@@ -204,11 +209,11 @@ int party_request_info(int party_id, int char_id)
/// Invoked (from char-server) when the party info is not found.
int party_recv_noinfo(int party_id, int char_id)
{
- party_broken(party_id);
+ party->broken(party_id);
if( char_id != 0 )// requester
{
struct map_session_data* sd;
- sd = map_charid2sd(char_id);
+ sd = iMap->charid2sd(char_id);
if( sd && sd->status.party_id == party_id )
sd->status.party_id = 0;
}
@@ -251,16 +256,14 @@ int party_recv_info(struct party* sp, int char_id)
int removed_count = 0;
int added[MAX_PARTY];// member_id in new data
int added_count = 0;
- int i;
+ int i,j;
int member_id;
nullpo_ret(sp);
p = (struct party_data*)idb_get(party_db, sp->party_id);
- if( p != NULL )// diff members
- {
- for( member_id = 0; member_id < MAX_PARTY; ++member_id )
- {
+ if( p != NULL ) {// diff members
+ for( member_id = 0; member_id < MAX_PARTY; ++member_id ) {
member = &p->party.member[member_id];
if( member->char_id == 0 )
continue;// empty
@@ -270,8 +273,7 @@ int party_recv_info(struct party* sp, int char_id)
if( i == MAX_PARTY )
removed[removed_count++] = member_id;
}
- for( member_id = 0; member_id < MAX_PARTY; ++member_id )
- {
+ for( member_id = 0; member_id < MAX_PARTY; ++member_id ) {
member = &sp->member[member_id];
if( member->char_id == 0 )
continue;// empty
@@ -281,36 +283,33 @@ int party_recv_info(struct party* sp, int char_id)
if( i == MAX_PARTY )
added[added_count++] = member_id;
}
- }
- else
- {
+ } else {
for( member_id = 0; member_id < MAX_PARTY; ++member_id )
if( sp->member[member_id].char_id != 0 )
added[added_count++] = member_id;
CREATE(p, struct party_data, 1);
+ p->instance = NULL;
+ p->instances = 0;
idb_put(party_db, sp->party_id, p);
}
- while( removed_count > 0 )// no longer in party
- {
+ while( removed_count > 0 ) {// no longer in party
member_id = removed[--removed_count];
sd = p->data[member_id].sd;
if( sd == NULL )
continue;// not online
- party_member_withdraw(sp->party_id, sd->status.account_id, sd->status.char_id);
+ party->member_withdraw(sp->party_id, sd->status.account_id, sd->status.char_id);
}
memcpy(&p->party, sp, sizeof(struct party));
memset(&p->state, 0, sizeof(p->state));
memset(&p->data, 0, sizeof(p->data));
- for( member_id = 0; member_id < MAX_PARTY; member_id++ )
- {
+ for( member_id = 0; member_id < MAX_PARTY; member_id++ ) {
member = &p->party.member[member_id];
if ( member->char_id == 0 )
continue;// empty
p->data[member_id].sd = party_sd_check(sp->party_id, member->account_id, member->char_id);
}
party_check_state(p);
- while( added_count > 0 )// new in party
- {
+ while( added_count > 0 ) { // new in party
member_id = added[--added_count];
sd = p->data[member_id].sd;
if( sd == NULL )
@@ -319,13 +318,19 @@ int party_recv_info(struct party* sp, int char_id)
clif->party_member_info(p,sd);
clif->party_option(p,sd,0x100);
clif->party_info(p,NULL);
- if( p->instance_id != 0 )
- clif->instance_join(sd->fd, p->instance_id);
+ for( j = 0; j < p->instances; j++ ) {
+ if( p->instance[j] >= 0 ) {
+ if( instances[p->instance[j]].idle_timer == INVALID_TIMER && instances[p->instance[j]].progress_timer == INVALID_TIMER )
+ continue;
+ clif->instance_join(sd->fd, p->instance[j]);
+ break;
+ }
+ }
}
if( char_id != 0 )// requester
{
- sd = map_charid2sd(char_id);
- if( sd && sd->status.party_id == sp->party_id && party_getmemberid(p,sd) == -1 )
+ sd = iMap->charid2sd(char_id);
+ if( sd && sd->status.party_id == sp->party_id && party->getmemberid(p,sd) == -1 )
sd->status.party_id = 0;// was not in the party
}
return 0;
@@ -338,7 +343,7 @@ int party_invite(struct map_session_data *sd,struct map_session_data *tsd)
nullpo_ret(sd);
- if( ( p = party_search(sd->status.party_id) ) == NULL )
+ if( ( p = party->search(sd->status.party_id) ) == NULL )
return 0;
// confirm if this player is a party leader
@@ -404,7 +409,7 @@ void party_reply_invite(struct map_session_data *sd,int party_id,int flag)
sd->party_invite_account = 0;
return;
}
- tsd = map_id2sd(sd->party_invite_account);
+ tsd = iMap->id2sd(sd->party_invite_account);
if( flag == 1 && !sd->party_creating && !sd->party_joining )
{// accepted and allowed
@@ -427,21 +432,25 @@ void party_reply_invite(struct map_session_data *sd,int party_id,int flag)
//- Player must be authed/active and belong to a party before calling this method
void party_member_joined(struct map_session_data *sd)
{
- struct party_data* p = party_search(sd->status.party_id);
+ struct party_data* p = party->search(sd->status.party_id);
int i;
- if (!p)
- {
- party_request_info(sd->status.party_id, sd->status.char_id);
+ if (!p) {
+ party->request_info(sd->status.party_id, sd->status.char_id);
return;
}
ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == sd->status.account_id && p->party.member[i].char_id == sd->status.char_id );
- if (i < MAX_PARTY)
- {
+ if (i < MAX_PARTY) {
+ int j;
p->data[i].sd = sd;
- if( p->instance_id )
- clif->instance_join(sd->fd,p->instance_id);
- }
- else
+ for( j = 0; j < p->instances; j++ ) {
+ if( p->instance[j] >= 0 ) {
+ if( instances[p->instance[j]].idle_timer == INVALID_TIMER && instances[p->instance[j]].progress_timer == INVALID_TIMER )
+ continue;
+ clif->instance_join(sd->fd, p->instance[j]);
+ break;
+ }
+ }
+ } else
sd->status.party_id = 0; //He does not belongs to the party really?
}
@@ -449,9 +458,9 @@ void party_member_joined(struct map_session_data *sd)
/// flag: 0-success, 1-failure
int party_member_added(int party_id,int account_id,int char_id, int flag)
{
- struct map_session_data *sd = map_id2sd(account_id),*sd2;
- struct party_data *p = party_search(party_id);
- int i;
+ struct map_session_data *sd = iMap->id2sd(account_id),*sd2;
+ struct party_data *p = party->search(party_id);
+ int i, j;
if(sd == NULL || sd->status.char_id != char_id || !sd->party_joining ) {
if (!flag) //Char logged off before being accepted into party.
@@ -459,7 +468,7 @@ int party_member_added(int party_id,int account_id,int char_id, int flag)
return 0;
}
- sd2 = map_id2sd(sd->party_invite_account);
+ sd2 = iMap->id2sd(sd->party_invite_account);
sd->party_joining = false;
sd->party_invite = 0;
@@ -496,9 +505,15 @@ int party_member_added(int party_id,int account_id,int char_id, int flag)
clif->party_xy(sd);
clif->charnameupdate(sd); //Update char name's display [Skotlex]
- if( p->instance_id )
- clif->instance_join(sd->fd, p->instance_id);
-
+ for( j = 0; j < p->instances; j++ ) {
+ if( p->instance[j] >= 0 ) {
+ if( instances[p->instance[j]].idle_timer == INVALID_TIMER && instances[p->instance[j]].progress_timer == INVALID_TIMER )
+ continue;
+ clif->instance_join(sd->fd, p->instance[j]);
+ break;
+ }
+ }
+
return 0;
}
@@ -508,7 +523,7 @@ int party_removemember(struct map_session_data* sd, int account_id, char* name)
struct party_data *p;
int i;
- p = party_search(sd->status.party_id);
+ p = party->search(sd->status.party_id);
if( p == NULL )
return 0;
@@ -533,7 +548,7 @@ int party_leave(struct map_session_data *sd)
struct party_data *p;
int i;
- p = party_search(sd->status.party_id);
+ p = party->search(sd->status.party_id);
if( p == NULL )
return 0;
@@ -548,15 +563,13 @@ int party_leave(struct map_session_data *sd)
/// Invoked (from char-server) when a party member leaves the party.
int party_member_withdraw(int party_id, int account_id, int char_id)
{
- struct map_session_data* sd = map_id2sd(account_id);
- struct party_data* p = party_search(party_id);
+ struct map_session_data* sd = iMap->id2sd(account_id);
+ struct party_data* p = party->search(party_id);
- if( p )
- {
+ if( p ) {
int i;
ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id );
- if( i < MAX_PARTY )
- {
+ if( i < MAX_PARTY ) {
clif->party_withdraw(p,sd,account_id,p->party.member[i].name,0x0);
memset(&p->party.member[i], 0, sizeof(p->party.member[0]));
memset(&p->data[i], 0, sizeof(p->data[0]));
@@ -565,13 +578,12 @@ int party_member_withdraw(int party_id, int account_id, int char_id)
}
}
- if( sd && sd->status.party_id == party_id && sd->status.char_id == char_id )
- {
+ if( sd && sd->status.party_id == party_id && sd->status.char_id == char_id ) {
sd->status.party_id = 0;
clif->charnameupdate(sd); //Update name display [Skotlex]
//TODO: hp bars should be cleared too
- if( p->instance_id )
- instance_check_kick(sd);
+ if( p->instances )
+ instance->check_kick(sd);
}
return 0;
@@ -581,22 +593,21 @@ int party_member_withdraw(int party_id, int account_id, int char_id)
int party_broken(int party_id)
{
struct party_data* p;
- int i;
+ int i, j;
- p = party_search(party_id);
+ p = party->search(party_id);
if( p == NULL )
return 0;
- if( p->instance_id )
- {
- instance[p->instance_id].party_id = 0;
- instance_destroy( p->instance_id );
+ for( j = 0; j < p->instances; j++ ) {
+ if( p->instance[j] >= 0 ) {
+ instance->destroy( p->instance[j] );
+ instances[p->instance[j]].owner_id = 0;
+ }
}
-
- for( i = 0; i < MAX_PARTY; i++ )
- {
- if( p->data[i].sd!=NULL )
- {
+
+ for( i = 0; i < MAX_PARTY; i++ ) {
+ if( p->data[i].sd!=NULL ) {
clif->party_withdraw(p,p->data[i].sd,p->party.member[i].account_id,p->party.member[i].name,0x10);
p->data[i].sd->status.party_id=0;
}
@@ -619,8 +630,8 @@ int party_changeoption(struct map_session_data *sd,int exp,int item)
int party_optionchanged(int party_id,int account_id,int exp,int item,int flag)
{
struct party_data *p;
- struct map_session_data *sd=map_id2sd(account_id);
- if( (p=party_search(party_id))==NULL)
+ struct map_session_data *sd=iMap->id2sd(account_id);
+ if( (p=party->search(party_id))==NULL)
return 0;
//Flag&1: Exp change denied. Flag&2: Item change denied.
@@ -653,7 +664,7 @@ bool party_changeleader(struct map_session_data *sd, struct map_session_data *ts
return false;
}
- if ((p = party_search(sd->status.party_id)) == NULL)
+ if ((p = party->search(sd->status.party_id)) == NULL)
return false;
ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
@@ -695,7 +706,7 @@ int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short m
struct party_data* p;
int i;
- p = party_search(party_id);
+ p = party->search(party_id);
if( p == NULL )
return 0;
@@ -726,7 +737,7 @@ void party_send_movemap(struct map_session_data *sd)
intif_party_changemap(sd,1);
- p=party_search(sd->status.party_id);
+ p=party->search(sd->status.party_id);
if (!p) return;
if(sd->state.connect_new) {
@@ -764,7 +775,7 @@ int party_send_logout(struct map_session_data *sd)
return 0;
intif_party_changemap(sd,0);
- p=party_search(sd->status.party_id);
+ p=party->search(sd->status.party_id);
if(!p) return 0;
ARR_FIND( 0, MAX_PARTY, i, p->data[i].sd == sd );
@@ -781,7 +792,7 @@ int party_send_message(struct map_session_data *sd,const char *mes,int len)
if(sd->status.party_id==0)
return 0;
intif_party_message(sd->status.party_id,sd->status.account_id,mes,len);
- party_recv_message(sd->status.party_id,sd->status.account_id,mes,len);
+ party->recv_message(sd->status.party_id,sd->status.account_id,mes,len);
// Chat logging type 'P' / Party Chat
logs->chat(LOG_CHAT_PARTY, sd->status.party_id, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, mes);
@@ -792,7 +803,7 @@ int party_send_message(struct map_session_data *sd,const char *mes,int len)
int party_recv_message(int party_id,int account_id,const char *mes,int len)
{
struct party_data *p;
- if( (p=party_search(party_id))==NULL)
+ if( (p=party->search(party_id))==NULL)
return 0;
clif->party_message(p,account_id,mes,len);
return 0;
@@ -804,7 +815,7 @@ int party_skill_check(struct map_session_data *sd, int party_id, uint16 skill_id
struct map_session_data *p_sd;
int i;
- if(!party_id || (p=party_search(party_id))==NULL)
+ if(!party_id || (p=party->search(party_id))==NULL)
return 0;
switch(skill_id) {
case TK_COUNTER: //Increase Triple Attack rate of Monks.
@@ -829,7 +840,7 @@ int party_skill_check(struct map_session_data *sd, int party_id, uint16 skill_id
switch(skill_id) {
case TK_COUNTER: //Increase Triple Attack rate of Monks.
if((p_sd->class_&MAPID_UPPERMASK) == MAPID_MONK
- && pc_checkskill(p_sd,MO_TRIPLEATTACK)) {
+ && pc->checkskill(p_sd,MO_TRIPLEATTACK)) {
sc_start4(&p_sd->bl,SC_SKILLRATE_UP,100,MO_TRIPLEATTACK,
50+50*skill_lv, //+100/150/200% rate
0,0,skill->get_time(SG_FRIEND, 1));
@@ -837,10 +848,10 @@ int party_skill_check(struct map_session_data *sd, int party_id, uint16 skill_id
break;
case MO_COMBOFINISH: //Increase Counter rate of Star Gladiators
if((p_sd->class_&MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR
- && sd->sc.data[SC_READYCOUNTER]
- && pc_checkskill(p_sd,SG_FRIEND)) {
+ && sd->sc.data[SC_COUNTERKICK_READY]
+ && pc->checkskill(p_sd,SG_FRIEND)) {
sc_start4(&p_sd->bl,SC_SKILLRATE_UP,100,TK_COUNTER,
- 50+50*pc_checkskill(p_sd,SG_FRIEND), //+100/150/200% rate
+ 50+50*pc->checkskill(p_sd,SG_FRIEND), //+100/150/200% rate
0,0,skill->get_time(SG_FRIEND, 1));
}
break;
@@ -945,15 +956,15 @@ int party_exp_share(struct party_data* p, struct block_list* src, unsigned int b
for (i = 0; i < c; i++) {
#ifdef RENEWAL_EXP
if( !(src && src->type == BL_MOB && ((TBL_MOB*)src)->db->mexp) ){
- int rate = pc_level_penalty_mod(sd[i], (TBL_MOB*)src, 1);
+ int rate = pc->level_penalty_mod(sd[i], (TBL_MOB*)src, 1);
base_exp = (unsigned int)cap_value(base_exp_bonus * rate / 100, 1, UINT_MAX);
job_exp = (unsigned int)cap_value(job_exp_bonus * rate / 100, 1, UINT_MAX);
}
#endif
- pc_gainexp(sd[i], src, base_exp, job_exp, false);
+ pc->gainexp(sd[i], src, base_exp, job_exp, false);
if (zeny) // zeny from mobs [Valaris]
- pc_getzeny(sd[i],zeny,LOG_TYPE_PICKDROP_MONSTER,NULL);
+ pc->getzeny(sd[i],zeny,LOG_TYPE_PICKDROP_MONSTER,NULL);
}
return 0;
}
@@ -978,7 +989,7 @@ int party_share_loot(struct party_data* p, struct map_session_data* sd, struct i
if( (psd = p->data[i].sd) == NULL || sd->bl.m != psd->bl.m || pc_isdead(psd) || (battle_config.idle_no_share && pc_isidle(psd)) )
continue;
- if (pc_additem(psd,item_data,item_data->amount,LOG_TYPE_PICKDROP_PLAYER))
+ if (pc->additem(psd,item_data,item_data->amount,LOG_TYPE_PICKDROP_PLAYER))
continue; //Chosen char can't pick up loot.
//Successful pick.
@@ -1000,7 +1011,7 @@ int party_share_loot(struct party_data* p, struct map_session_data* sd, struct i
}
while (count > 0) { //Pick a random member.
i = rnd()%count;
- if (pc_additem(psd[i],item_data,item_data->amount,LOG_TYPE_PICKDROP_PLAYER))
+ if (pc->additem(psd[i],item_data,item_data->amount,LOG_TYPE_PICKDROP_PLAYER))
{ //Discard this receiver.
psd[i] = psd[count-1];
count--;
@@ -1014,7 +1025,7 @@ int party_share_loot(struct party_data* p, struct map_session_data* sd, struct i
if (!target) {
target = sd; //Give it to the char that picked it up
- if ((i=pc_additem(sd,item_data,item_data->amount,LOG_TYPE_PICKDROP_PLAYER)))
+ if ((i=pc->additem(sd,item_data,item_data->amount,LOG_TYPE_PICKDROP_PLAYER)))
return i;
}
@@ -1033,7 +1044,7 @@ int party_send_dot_remove(struct map_session_data *sd)
// To use for Taekwon's "Fighting Chant"
// int c = 0;
-// party_foreachsamemap(party_sub_count, sd, 0, &c);
+// party_foreachsamemap(party->sub_count, sd, 0, &c);
int party_sub_count(struct block_list *bl, va_list ap)
{
struct map_session_data *sd = (TBL_PC *)bl;
@@ -1059,7 +1070,7 @@ int party_foreachsamemap(int (*func)(struct block_list*,va_list),struct map_sess
nullpo_ret(sd);
- if((p=party_search(sd->status.party_id))==NULL)
+ if((p=party->search(sd->status.party_id))==NULL)
return 0;
x0=sd->bl.x-range;
@@ -1080,7 +1091,7 @@ int party_foreachsamemap(int (*func)(struct block_list*,va_list),struct map_sess
list[blockcount++]=&psd->bl;
}
- map_freeblock_lock();
+ iMap->freeblock_lock();
for(i=0;i<blockcount;i++)
{
@@ -1090,7 +1101,7 @@ int party_foreachsamemap(int (*func)(struct block_list*,va_list),struct map_sess
va_end(ap);
}
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return total;
}
@@ -1107,10 +1118,16 @@ static struct party_booking_ad_info* create_party_booking_data(void)
return pb_ad;
}
+#ifndef PARTY_RECRUIT
void party_booking_register(struct map_session_data *sd, short level, short mapid, short* job)
+#else
+void party_booking_register(struct map_session_data *sd, short level, const char *notice)
+#endif
{
struct party_booking_ad_info *pb_ad;
- int i;
+#ifndef PARTY_RECRUIT
+ int i;
+#endif
pb_ad = (struct party_booking_ad_info*)idb_get(party_booking_db, sd->status.char_id);
@@ -1126,22 +1143,32 @@ void party_booking_register(struct map_session_data *sd, short level, short mapi
}
memcpy(pb_ad->charname,sd->status.name,NAME_LENGTH);
- pb_ad->starttime = (int)time(NULL);
- pb_ad->p_detail.level = level;
+ pb_ad->expiretime = (int)time(NULL);
+ pb_ad->p_detail.level = level;
+#ifndef PARTY_RECRUIT
pb_ad->p_detail.mapid = mapid;
for(i=0;i<PARTY_BOOKING_JOBS;i++)
if(job[i] != 0xFF)
pb_ad->p_detail.job[i] = job[i];
else pb_ad->p_detail.job[i] = -1;
+#else
+ safestrncpy(pb_ad->p_detail.notice, notice, PB_NOTICE_LENGTH);
+#endif
clif->PartyBookingRegisterAck(sd, 0);
clif->PartyBookingInsertNotify(sd, pb_ad); // Notice
}
+#ifndef PARTY_RECRUIT
void party_booking_update(struct map_session_data *sd, short* job)
+#else
+void party_booking_update(struct map_session_data *sd, const char *notice)
+#endif
{
+#ifndef PARTY_RECRUIT
int i;
+#endif
struct party_booking_ad_info *pb_ad;
pb_ad = (struct party_booking_ad_info*)idb_get(party_booking_db, sd->status.char_id);
@@ -1149,20 +1176,33 @@ void party_booking_update(struct map_session_data *sd, short* job)
if( pb_ad == NULL )
return;
- pb_ad->starttime = (int)time(NULL);// Update time.
+ pb_ad->expiretime = (int)time(NULL);// Update time.
+#ifndef PARTY_RECRUIT
for(i=0;i<PARTY_BOOKING_JOBS;i++)
if(job[i] != 0xFF)
pb_ad->p_detail.job[i] = job[i];
else pb_ad->p_detail.job[i] = -1;
+#else
+ if (notice != NULL) {
+ safestrncpy(pb_ad->p_detail.notice, notice, PB_NOTICE_LENGTH);
+ }
+#endif
clif->PartyBookingUpdateNotify(sd, pb_ad);
}
+#ifndef PARTY_RECRUIT
void party_booking_search(struct map_session_data *sd, short level, short mapid, short job, unsigned long lastindex, short resultcount)
+#else
+void party_booking_search(struct map_session_data *sd, short level, short mapid, unsigned long lastindex, short resultcount)
+#endif
{
struct party_booking_ad_info *pb_ad;
- int i, count=0;
+#ifndef PARTY_RECRUIT
+ int i;
+#endif
+ int count = 0;
struct party_booking_ad_info* result_list[PARTY_BOOKING_RESULTS];
bool more_result = false;
DBIterator* iter = db_iterator(party_booking_db);
@@ -1171,12 +1211,18 @@ void party_booking_search(struct map_session_data *sd, short level, short mapid,
for( pb_ad = dbi_first(iter); dbi_exists(iter); pb_ad = dbi_next(iter) )
{
+#ifndef PARTY_RECRUIT
if (pb_ad->index < lastindex || (level && (pb_ad->p_detail.level < level-15 || pb_ad->p_detail.level > level)))
continue;
+#else
+ if ((level && (pb_ad->p_detail.level < level-15 || pb_ad->p_detail.level > level)))
+ continue;
+#endif
if (count >= PARTY_BOOKING_RESULTS){
more_result = true;
break;
}
+#ifndef PARTY_RECRUIT
if (mapid == 0 && job == -1)
result_list[count] = pb_ad;
else if (mapid == 0) {
@@ -1187,6 +1233,9 @@ void party_booking_search(struct map_session_data *sd, short level, short mapid,
if (pb_ad->p_detail.mapid == mapid)
result_list[count] = pb_ad;
}
+#else
+ result_list[count] = pb_ad;
+#endif
if( result_list[count] )
{
count++;
@@ -1207,3 +1256,54 @@ bool party_booking_delete(struct map_session_data *sd)
}
return true;
}
+
+/*=====================================
+* Default Functions : party.h
+* Generated by HerculesInterfaceMaker
+* created by Susu
+*-------------------------------------*/
+void party_defaults(void) {
+ party = &party_s;
+
+ /* funcs */
+
+ party->do_init_party = do_init_party;
+ party->do_final_party = do_final_party;
+ party->search = party_search;
+ party->searchname = party_searchname;
+ party->getmemberid = party_getmemberid;
+ party->getavailablesd = party_getavailablesd;
+
+ party->create = party_create;
+ party->created = party_created;
+ party->request_info = party_request_info;
+ party->invite = party_invite;
+ party->member_joined = party_member_joined;
+ party->member_added = party_member_added;
+ party->leave = party_leave;
+ party->removemember = party_removemember;
+ party->member_withdraw = party_member_withdraw;
+ party->reply_invite = party_reply_invite;
+ party->recv_noinfo = party_recv_noinfo;
+ party->recv_info = party_recv_info;
+ party->recv_movemap = party_recv_movemap;
+ party->broken = party_broken;
+ party->optionchanged = party_optionchanged;
+ party->changeoption = party_changeoption;
+ party->changeleader = party_changeleader;
+ party->send_movemap = party_send_movemap;
+ party->send_levelup = party_send_levelup;
+ party->send_logout = party_send_logout;
+ party->send_message = party_send_message;
+ party->recv_message = party_recv_message;
+ party->skill_check = party_skill_check;
+ party->send_xy_clear = party_send_xy_clear;
+ party->exp_share = party_exp_share;
+ party->share_loot = party_share_loot;
+ party->send_dot_remove = party_send_dot_remove;
+ party->sub_count = party_sub_count;
+ party->booking_register = party_booking_register;
+ party->booking_update = party_booking_update;
+ party->booking_search = party_booking_search;
+ party->booking_delete = party_booking_delete;
+}
diff --git a/src/map/party.h b/src/map/party.h
index 12fe7a2bc..f215baa56 100644
--- a/src/map/party.h
+++ b/src/map/party.h
@@ -1,10 +1,9 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
-
#ifndef _PARTY_H_
#define _PARTY_H_
-
#include "../common/mmo.h" // struct party
+#include "../config/core.h"
struct block_list;
struct map_session_data;
struct party;
@@ -25,7 +24,8 @@ struct party_data {
struct party party;
struct party_member_data data[MAX_PARTY];
uint8 itemc; //For item distribution, position of last picker in party
- unsigned int instance_id;
+ short *instance;
+ unsigned short instances;
struct {
unsigned monk : 1; //There's at least one monk in party?
unsigned sg : 1; //There's at least one Star Gladiator in party?
@@ -34,6 +34,7 @@ struct party_data {
} state;
};
+#ifndef PARTY_RECRUIT
struct party_booking_detail {
short level;
short mapid;
@@ -43,53 +44,89 @@ struct party_booking_detail {
struct party_booking_ad_info {
unsigned long index;
char charname[NAME_LENGTH];
- long starttime;
+ long expiretime;
struct party_booking_detail p_detail;
};
+#else
+#define PB_NOTICE_LENGTH (36 + 1)
+struct party_booking_detail {
+ short level;
+ char notice[PB_NOTICE_LENGTH];
+};
+
+struct party_booking_ad_info {
+ unsigned long index;
+ long expiretime;
+ char charname[NAME_LENGTH];
+ struct party_booking_detail p_detail;
+};
+#endif
-void do_init_party(void);
-void do_final_party(void);
-struct party_data* party_search(int party_id);
-struct party_data* party_searchname(const char* str);
-int party_getmemberid(struct party_data* p, struct map_session_data* sd);
-struct map_session_data* party_getavailablesd(struct party_data *p);
-int party_create(struct map_session_data *sd,char *name, int item, int item2);
-void party_created(int account_id,int char_id,int fail,int party_id,char *name);
-int party_request_info(int party_id, int char_id);
-int party_invite(struct map_session_data *sd,struct map_session_data *tsd);
-void party_member_joined(struct map_session_data *sd);
-int party_member_added(int party_id,int account_id,int char_id,int flag);
-int party_leave(struct map_session_data *sd);
-int party_removemember(struct map_session_data *sd,int account_id,char *name);
-int party_member_withdraw(int party_id,int account_id,int char_id);
-void party_reply_invite(struct map_session_data *sd,int party_id,int flag);
-int party_recv_noinfo(int party_id, int char_id);
-int party_recv_info(struct party* sp, int char_id);
-int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short map,int online,int lv);
-int party_broken(int party_id);
-int party_optionchanged(int party_id,int account_id,int exp,int item,int flag);
-int party_changeoption(struct map_session_data *sd,int exp,int item);
-bool party_changeleader(struct map_session_data *sd, struct map_session_data *t_sd);
-void party_send_movemap(struct map_session_data *sd);
-void party_send_levelup(struct map_session_data *sd);
-int party_send_logout(struct map_session_data *sd);
-int party_send_message(struct map_session_data *sd,const char *mes,int len);
-int party_recv_message(int party_id,int account_id,const char *mes,int len);
-int party_skill_check(struct map_session_data *sd, int party_id, uint16 skill_id, uint16 skill_lv);
-int party_send_xy_clear(struct party_data *p);
-int party_exp_share(struct party_data *p,struct block_list *src,unsigned int base_exp,unsigned int job_exp,int zeny);
-int party_share_loot(struct party_data* p, struct map_session_data* sd, struct item* item_data, int first_charid);
-int party_send_dot_remove(struct map_session_data *sd);
-int party_sub_count(struct block_list *bl, va_list ap);
int party_foreachsamemap(int (*func)(struct block_list *,va_list),struct map_session_data *sd,int range,...);
/*==========================================
* Party Booking in KRO [Spiria]
*------------------------------------------*/
-void party_booking_register(struct map_session_data *sd, short level, short mapid, short* job);
-void party_booking_update(struct map_session_data *sd, short* job);
-void party_booking_search(struct map_session_data *sd, short level, short mapid, short job, unsigned long lastindex, short resultcount);
-bool party_booking_delete(struct map_session_data *sd);
+
+/*=====================================
+* Interface : party.h
+* Generated by HerculesInterfaceMaker
+* created by Susu
+*-------------------------------------*/
+struct party_interface {
+
+ /* funcs */
+
+ void (*do_init_party) (void);
+ void (*do_final_party) (void);
+ struct party_data* (*search) (int party_id);
+ struct party_data* (*searchname) (const char* str);
+ int (*getmemberid) (struct party_data* p, struct map_session_data* sd);
+ struct map_session_data* (*getavailablesd) (struct party_data *p);
+
+ int (*create) (struct map_session_data *sd,char *name, int item, int item2);
+ void (*created) (int account_id,int char_id,int fail,int party_id,char *name);
+ int (*request_info) (int party_id, int char_id);
+ int (*invite) (struct map_session_data *sd,struct map_session_data *tsd);
+ void (*member_joined) (struct map_session_data *sd);
+ int (*member_added) (int party_id,int account_id,int char_id,int flag);
+ int (*leave) (struct map_session_data *sd);
+ int (*removemember) (struct map_session_data *sd,int account_id,char *name);
+ int (*member_withdraw) (int party_id,int account_id,int char_id);
+ void (*reply_invite) (struct map_session_data *sd,int party_id,int flag);
+ int (*recv_noinfo) (int party_id, int char_id);
+ int (*recv_info) (struct party* sp, int char_id);
+ int (*recv_movemap) (int party_id,int account_id,int char_id, unsigned short map,int online,int lv);
+ int (*broken) (int party_id);
+ int (*optionchanged) (int party_id,int account_id,int exp,int item,int flag);
+ int (*changeoption) (struct map_session_data *sd,int exp,int item);
+ bool (*changeleader) (struct map_session_data *sd, struct map_session_data *t_sd);
+ void (*send_movemap) (struct map_session_data *sd);
+ void (*send_levelup) (struct map_session_data *sd);
+ int (*send_logout) (struct map_session_data *sd);
+ int (*send_message) (struct map_session_data *sd,const char *mes,int len);
+ int (*recv_message) (int party_id,int account_id,const char *mes,int len);
+ int (*skill_check) (struct map_session_data *sd, int party_id, uint16 skill_id, uint16 skill_lv);
+ int (*send_xy_clear) (struct party_data *p);
+ int (*exp_share) (struct party_data *p,struct block_list *src,unsigned int base_exp,unsigned int job_exp,int zeny);
+ int (*share_loot) (struct party_data* p, struct map_session_data* sd, struct item* item_data, int first_charid);
+ int (*send_dot_remove) (struct map_session_data *sd);
+ int (*sub_count) (struct block_list *bl, va_list ap);
+#ifndef PARTY_RECRUIT
+ void (*booking_register) (struct map_session_data *sd, short level, short mapid, short* job);
+ void (*booking_update) (struct map_session_data *sd, short* job);
+ void (*booking_search) (struct map_session_data *sd, short level, short mapid, short job, unsigned long lastindex, short resultcount);
+#else
+ void (*booking_register) (struct map_session_data *sd, short level, const char *notice);
+ void (*booking_update) (struct map_session_data *sd, const char *notice);
+ void (*booking_search) (struct map_session_data *sd, short level, short mapid, unsigned long lastindex, short resultcount);
+#endif
+ bool (*booking_delete) (struct map_session_data *sd);
+} party_s;
+
+struct party_interface *party;
+
+void party_defaults(void);
#endif /* _PARTY_H_ */
diff --git a/src/map/path.c b/src/map/path.c
index 3bbd8d20b..95895cb2a 100644
--- a/src/map/path.c
+++ b/src/map/path.c
@@ -167,12 +167,10 @@ int path_blownpos(int16 m,int16 x0,int16 y0,int16 dx,int16 dy,int count)
dy=(dy>0)?1:((dy<0)?-1:0);
}
- while( count > 0 && (dx != 0 || dy != 0) )
- {
- if( !map_getcellp(md,x0+dx,y0+dy,CELL_CHKPASS) )
- {// attempt partial movement
- int fx = ( dx != 0 && map_getcellp(md,x0+dx,y0,CELL_CHKPASS) );
- int fy = ( dy != 0 && map_getcellp(md,x0,y0+dy,CELL_CHKPASS) );
+ while( count > 0 && (dx != 0 || dy != 0) ) {
+ if( !md->getcellp(md,x0+dx,y0+dy,CELL_CHKPASS) ) {// attempt partial movement
+ int fx = ( dx != 0 && md->getcellp(md,x0+dx,y0,CELL_CHKPASS) );
+ int fy = ( dy != 0 && md->getcellp(md,x0,y0+dy,CELL_CHKPASS) );
if( fx && fy )
{
if(rnd()&1)
@@ -225,7 +223,7 @@ bool path_search_long(struct shootpath_data *spd,int16 m,int16 x0,int16 y0,int16
spd->x[0] = x0;
spd->y[0] = y0;
- if (map_getcellp(md,x1,y1,cell))
+ if (md->getcellp(md,x1,y1,cell))
return false;
if (dx > abs(dy)) {
@@ -238,7 +236,7 @@ bool path_search_long(struct shootpath_data *spd,int16 m,int16 x0,int16 y0,int16
while (x0 != x1 || y0 != y1)
{
- if (map_getcellp(md,x0,y0,cell))
+ if (md->getcellp(md,x0,y0,cell))
return false;
wx += dx;
wy += dy;
@@ -290,10 +288,10 @@ bool path_search(struct walkpath_data *wpd,int16 m,int16 x0,int16 y0,int16 x1,in
//Do not check starting cell as that would get you stuck.
if( x0 < 0 || x0 >= md->xs || y0 < 0 || y0 >= md->ys )
#else
- if( x0 < 0 || x0 >= md->xs || y0 < 0 || y0 >= md->ys /*|| map_getcellp(md,x0,y0,cell)*/ )
+ if( x0 < 0 || x0 >= md->xs || y0 < 0 || y0 >= md->ys /*|| md->getcellp(md,x0,y0,cell)*/ )
#endif
return false;
- if( x1 < 0 || x1 >= md->xs || y1 < 0 || y1 >= md->ys || map_getcellp(md,x1,y1,cell) )
+ if( x1 < 0 || x1 >= md->xs || y1 < 0 || y1 >= md->ys || md->getcellp(md,x1,y1,cell) )
return false;
// calculate (sgn(x1-x0), sgn(y1-y0))
@@ -317,7 +315,7 @@ bool path_search(struct walkpath_data *wpd,int16 m,int16 x0,int16 y0,int16 x1,in
if( dx == 0 && dy == 0 )
break; // success
- if( map_getcellp(md,x,y,cell) )
+ if( md->getcellp(md,x,y,cell) )
break; // obstacle = failure
}
@@ -365,29 +363,29 @@ bool path_search(struct walkpath_data *wpd,int16 m,int16 x0,int16 y0,int16 x1,in
// dc[2] : y--
// dc[3] : x++
- if(y < ys && !map_getcellp(md,x ,y+1,cell)) {
+ if(y < ys && !md->getcellp(md,x ,y+1,cell)) {
f |= 1; dc[0] = (y >= y1 ? 20 : 0);
e+=add_path(heap,tp,x ,y+1,dist,rp,cost+dc[0]); // (x, y+1)
}
- if(x > 0 && !map_getcellp(md,x-1,y ,cell)) {
+ if(x > 0 && !md->getcellp(md,x-1,y ,cell)) {
f |= 2; dc[1] = (x <= x1 ? 20 : 0);
e+=add_path(heap,tp,x-1,y ,dist,rp,cost+dc[1]); // (x-1, y )
}
- if(y > 0 && !map_getcellp(md,x ,y-1,cell)) {
+ if(y > 0 && !md->getcellp(md,x ,y-1,cell)) {
f |= 4; dc[2] = (y <= y1 ? 20 : 0);
e+=add_path(heap,tp,x ,y-1,dist,rp,cost+dc[2]); // (x , y-1)
}
- if(x < xs && !map_getcellp(md,x+1,y ,cell)) {
+ if(x < xs && !md->getcellp(md,x+1,y ,cell)) {
f |= 8; dc[3] = (x >= x1 ? 20 : 0);
e+=add_path(heap,tp,x+1,y ,dist,rp,cost+dc[3]); // (x+1, y )
}
- if( (f & (2+1)) == (2+1) && !map_getcellp(md,x-1,y+1,cell))
+ if( (f & (2+1)) == (2+1) && !md->getcellp(md,x-1,y+1,cell))
e+=add_path(heap,tp,x-1,y+1,dist+4,rp,cost+dc[1]+dc[0]-6); // (x-1, y+1)
- if( (f & (2+4)) == (2+4) && !map_getcellp(md,x-1,y-1,cell))
+ if( (f & (2+4)) == (2+4) && !md->getcellp(md,x-1,y-1,cell))
e+=add_path(heap,tp,x-1,y-1,dist+4,rp,cost+dc[1]+dc[2]-6); // (x-1, y-1)
- if( (f & (8+4)) == (8+4) && !map_getcellp(md,x+1,y-1,cell))
+ if( (f & (8+4)) == (8+4) && !md->getcellp(md,x+1,y-1,cell))
e+=add_path(heap,tp,x+1,y-1,dist+4,rp,cost+dc[3]+dc[2]-6); // (x+1, y-1)
- if( (f & (8+1)) == (8+1) && !map_getcellp(md,x+1,y+1,cell))
+ if( (f & (8+1)) == (8+1) && !md->getcellp(md,x+1,y+1,cell))
e+=add_path(heap,tp,x+1,y+1,dist+4,rp,cost+dc[3]+dc[0]-6); // (x+1, y+1)
tp[rp].flag=1;
if(e || heap[0]>=MAX_HEAP-5)
@@ -421,7 +419,7 @@ bool path_search(struct walkpath_data *wpd,int16 m,int16 x0,int16 y0,int16 x1,in
}
-//Distance functions, taken from http://www.flipcode.com/articles/article_fastdistance.shtml
+//Distance functions, taken from http://www.flpcode.com/articles/article_fastdistance.shtml
int check_distance(int dx, int dy, int distance)
{
#ifdef CIRCULAR_AREA
diff --git a/src/map/pc.c b/src/map/pc.c
index 55ce993b4..0d1a99175 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -12,6 +12,7 @@
#include "../common/strlib.h" // safestrncpy()
#include "../common/timer.h"
#include "../common/utils.h"
+#include "../common/conf.h"
#include "../common/mmo.h" //NAME_LENGTH
#include "atcommand.h" // get_atcommand_level()
@@ -33,7 +34,7 @@
#include "elemental.h"
#include "npc.h" // fake_nd
#include "pet.h" // pet_unlocktarget()
-#include "party.h" // party_search()
+#include "party.h" // party->search()
#include "guild.h" // guild->search(), guild_request_info()
#include "script.h" // script_config
#include "skill.h"
@@ -96,7 +97,7 @@ int pc_class2idx(int class_) {
return class_;
}
-inline int pc_get_group_level(struct map_session_data *sd) {
+int pc_get_group_level(struct map_session_data *sd) {
return sd->group_level;
}
@@ -104,7 +105,7 @@ static int pc_invincible_timer(int tid, unsigned int tick, int id, intptr_t data
{
struct map_session_data *sd;
- if( (sd=(struct map_session_data *)map_id2sd(id)) == NULL || sd->bl.type!=BL_PC )
+ if( (sd=(struct map_session_data *)iMap->id2sd(id)) == NULL || sd->bl.type!=BL_PC )
return 1;
if(sd->invincible_timer != tid){
@@ -123,8 +124,8 @@ void pc_setinvincibletimer(struct map_session_data* sd, int val) {
val += map[sd->bl.m].invincible_time_inc;
if( sd->invincible_timer != INVALID_TIMER )
- delete_timer(sd->invincible_timer,pc_invincible_timer);
- sd->invincible_timer = add_timer(gettick()+val,pc_invincible_timer,sd->bl.id,0);
+ iTimer->delete_timer(sd->invincible_timer,pc_invincible_timer);
+ sd->invincible_timer = iTimer->add_timer(iTimer->gettick()+val,pc_invincible_timer,sd->bl.id,0);
}
void pc_delinvincibletimer(struct map_session_data* sd)
@@ -133,9 +134,9 @@ void pc_delinvincibletimer(struct map_session_data* sd)
if( sd->invincible_timer != INVALID_TIMER )
{
- delete_timer(sd->invincible_timer,pc_invincible_timer);
+ iTimer->delete_timer(sd->invincible_timer,pc_invincible_timer);
sd->invincible_timer = INVALID_TIMER;
- skill->unit_move(&sd->bl,gettick(),1);
+ skill->unit_move(&sd->bl,iTimer->gettick(),1);
}
}
@@ -144,7 +145,7 @@ static int pc_spiritball_timer(int tid, unsigned int tick, int id, intptr_t data
struct map_session_data *sd;
int i;
- if( (sd=(struct map_session_data *)map_id2sd(id)) == NULL || sd->bl.type!=BL_PC )
+ if( (sd=(struct map_session_data *)iMap->id2sd(id)) == NULL || sd->bl.type!=BL_PC )
return 1;
if( sd->spiritball <= 0 )
@@ -184,15 +185,15 @@ int pc_addspiritball(struct map_session_data *sd,int interval,int max)
if( sd->spiritball && sd->spiritball >= max ) {
if(sd->spirit_timer[0] != INVALID_TIMER)
- delete_timer(sd->spirit_timer[0],pc_spiritball_timer);
+ iTimer->delete_timer(sd->spirit_timer[0],pc_spiritball_timer);
sd->spiritball--;
if( sd->spiritball != 0 )
memmove(sd->spirit_timer+0, sd->spirit_timer+1, (sd->spiritball)*sizeof(int));
sd->spirit_timer[sd->spiritball] = INVALID_TIMER;
}
- tid = add_timer(gettick()+interval, pc_spiritball_timer, sd->bl.id, 0);
- ARR_FIND(0, sd->spiritball, i, sd->spirit_timer[i] == INVALID_TIMER || DIFF_TICK(get_timer(tid)->tick, get_timer(sd->spirit_timer[i])->tick) < 0);
+ tid = iTimer->add_timer(iTimer->gettick()+interval, pc_spiritball_timer, sd->bl.id, 0);
+ ARR_FIND(0, sd->spiritball, i, sd->spirit_timer[i] == INVALID_TIMER || DIFF_TICK(iTimer->get_timer(tid)->tick, iTimer->get_timer(sd->spirit_timer[i])->tick) < 0);
if( i != sd->spiritball )
memmove(sd->spirit_timer+i+1, sd->spirit_timer+i, (sd->spiritball-i)*sizeof(int));
sd->spirit_timer[i] = tid;
@@ -226,7 +227,7 @@ int pc_delspiritball(struct map_session_data *sd,int count,int type)
for(i=0;i<count;i++) {
if(sd->spirit_timer[i] != INVALID_TIMER) {
- delete_timer(sd->spirit_timer[i],pc_spiritball_timer);
+ iTimer->delete_timer(sd->spirit_timer[i],pc_spiritball_timer);
sd->spirit_timer[i] = INVALID_TIMER;
}
}
@@ -302,7 +303,7 @@ int pc_banding(struct map_session_data *sd, uint16 skill_lv) {
// Get total HP of all Royal Guards in party.
for( j = 0; j < i; j++ )
{
- bsd = map_id2sd(b_sd[j]);
+ bsd = iMap->id2sd(b_sd[j]);
if( bsd != NULL )
hp += status_get_hp(&bsd->bl);
}
@@ -313,7 +314,7 @@ int pc_banding(struct map_session_data *sd, uint16 skill_lv) {
// If a Royal Guard have full HP, give more HP to others that haven't full HP.
for( j = 0; j < i; j++ )
{
- bsd = map_id2sd(b_sd[j]);
+ bsd = iMap->id2sd(b_sd[j]);
if( bsd != NULL && (tmp_hp = hp - status_get_max_hp(&bsd->bl)) > 0 )
{
extra_hp += tmp_hp;
@@ -326,7 +327,7 @@ int pc_banding(struct map_session_data *sd, uint16 skill_lv) {
for( j = 0; j < i; j++ )
{
- bsd = map_id2sd(b_sd[j]);
+ bsd = iMap->id2sd(b_sd[j]);
if( bsd != NULL )
{
status_set_hp(&bsd->bl,hp,0); // Set hp
@@ -415,7 +416,7 @@ int pc_setrestartvalue(struct map_session_data *sd,int type) {
*------------------------------------------*/
static int pc_inventory_rental_end(int tid, unsigned int tick, int id, intptr_t data)
{
- struct map_session_data *sd = map_id2sd(id);
+ struct map_session_data *sd = iMap->id2sd(id);
if( sd == NULL )
return 0;
if( tid != sd->rental_timer )
@@ -424,7 +425,7 @@ static int pc_inventory_rental_end(int tid, unsigned int tick, int id, intptr_t
return 0;
}
- pc_inventory_rentals(sd);
+ pc->inventory_rentals(sd);
return 1;
}
@@ -432,7 +433,7 @@ int pc_inventory_rental_clear(struct map_session_data *sd)
{
if( sd->rental_timer != INVALID_TIMER )
{
- delete_timer(sd->rental_timer, pc_inventory_rental_end);
+ iTimer->delete_timer(sd->rental_timer, pc_inventory_rental_end);
sd->rental_timer = INVALID_TIMER;
}
@@ -457,7 +458,7 @@ void pc_inventory_rentals(struct map_session_data *sd)
status_change_end(&sd->bl,SC_ALL_RIDING,INVALID_TIMER);
}
clif->rental_expired(sd->fd, i, sd->status.inventory[i].nameid);
- pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_OTHER);
+ pc->delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_OTHER);
} else {
expire_tick = (unsigned int)(sd->status.inventory[i].expire_time - time(NULL)) * 1000;
clif->rental_time(sd->fd, sd->status.inventory[i].nameid, (int)(expire_tick / 1000));
@@ -467,7 +468,7 @@ void pc_inventory_rentals(struct map_session_data *sd)
}
if( c > 0 ) // min(next_tick,3600000) 1 hour each timer to keep announcing to the owner, and to avoid a but with rental time > 15 days
- sd->rental_timer = add_timer(gettick() + min(next_tick,3600000), pc_inventory_rental_end, sd->bl.id, 0);
+ sd->rental_timer = iTimer->add_timer(iTimer->gettick() + min(next_tick,3600000), pc_inventory_rental_end, sd->bl.id, 0);
else
sd->rental_timer = INVALID_TIMER;
}
@@ -482,15 +483,15 @@ void pc_inventory_rental_add(struct map_session_data *sd, int seconds)
if( sd->rental_timer != INVALID_TIMER )
{
const struct TimerData * td;
- td = get_timer(sd->rental_timer);
- if( DIFF_TICK(td->tick, gettick()) > tick )
+ td = iTimer->get_timer(sd->rental_timer);
+ if( DIFF_TICK(td->tick, iTimer->gettick()) > tick )
{ // Update Timer as this one ends first than the current one
- pc_inventory_rental_clear(sd);
- sd->rental_timer = add_timer(gettick() + tick, pc_inventory_rental_end, sd->bl.id, 0);
+ pc->inventory_rental_clear(sd);
+ sd->rental_timer = iTimer->add_timer(iTimer->gettick() + tick, pc_inventory_rental_end, sd->bl.id, 0);
}
}
else
- sd->rental_timer = add_timer(gettick() + min(tick,3600000), pc_inventory_rental_end, sd->bl.id, 0);
+ sd->rental_timer = iTimer->add_timer(iTimer->gettick() + min(tick,3600000), pc_inventory_rental_end, sd->bl.id, 0);
}
/**
@@ -518,10 +519,9 @@ int pc_makesavestatus(struct map_session_data *sd)
#else
sd->status.option = sd->sc.option&(OPTION_INVISIBLE|OPTION_CART|OPTION_FALCON|OPTION_RIDING|OPTION_DRAGON|OPTION_WUG|OPTION_WUGRIDER|OPTION_MADOGEAR);
#endif
- if (sd->sc.data[SC_JAILED])
- { //When Jailed, do not move last point.
+ if (sd->sc.data[SC_JAILED]) { //When Jailed, do not move last point.
if(pc_isdead(sd)){
- pc_setrestartvalue(sd,0);
+ pc->setrestartvalue(sd,0);
} else {
sd->status.hp = sd->battle_status.hp;
sd->status.sp = sd->battle_status.sp;
@@ -533,7 +533,7 @@ int pc_makesavestatus(struct map_session_data *sd)
}
if(pc_isdead(sd)){
- pc_setrestartvalue(sd,0);
+ pc->setrestartvalue(sd,0);
memcpy(&sd->status.last_point,&sd->status.save_point,sizeof(sd->status.last_point));
} else {
sd->status.hp = sd->battle_status.hp;
@@ -543,13 +543,25 @@ int pc_makesavestatus(struct map_session_data *sd)
sd->status.last_point.y = sd->bl.y;
}
- if(map[sd->bl.m].flag.nosave){
+ if(map[sd->bl.m].flag.nosave || map[sd->bl.m].instance_id >= 0){
struct map_data *m=&map[sd->bl.m];
if(m->save.map)
memcpy(&sd->status.last_point,&m->save,sizeof(sd->status.last_point));
else
memcpy(&sd->status.last_point,&sd->status.save_point,sizeof(sd->status.last_point));
}
+ if( sd->status.last_point.map == 0 ) {
+ sd->status.last_point.map = 1;
+ sd->status.last_point.x = 0;
+ sd->status.last_point.y = 0;
+ }
+
+ if( sd->status.save_point.map == 0 ) {
+ sd->status.save_point.map = 1;
+ sd->status.save_point.x = 0;
+ sd->status.save_point.y = 0;
+ }
+
return 0;
}
@@ -570,7 +582,7 @@ int pc_setnewpc(struct map_session_data *sd, int account_id, int char_id, int lo
sd->client_tick = client_tick;
sd->state.active = 0; //to be set to 1 after player is fully authed and loaded.
sd->bl.type = BL_PC;
- sd->canlog_tick = gettick();
+ sd->canlog_tick = iTimer->gettick();
//Required to prevent homunculus copuing a base speed of 0.
sd->battle_status.speed = sd->base_status.speed = DEFAULT_WALK_SPEED;
return 0;
@@ -592,7 +604,7 @@ int pc_equippoint(struct map_session_data *sd,int n)
if(sd->inventory_data[n]->look == W_DAGGER ||
sd->inventory_data[n]->look == W_1HSWORD ||
sd->inventory_data[n]->look == W_1HAXE) {
- if(ep == EQP_HAND_R && (pc_checkskill(sd,AS_LEFT) > 0 || (sd->class_&MAPID_UPPERMASK) == MAPID_ASSASSIN ||
+ if(ep == EQP_HAND_R && (pc->checkskill(sd,AS_LEFT) > 0 || (sd->class_&MAPID_UPPERMASK) == MAPID_ASSASSIN ||
(sd->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO))//Kagerou and Oboro can dual wield daggers. [Rytech]
return EQP_ARMS;
}
@@ -607,7 +619,7 @@ int pc_setinventorydata(struct map_session_data *sd)
for(i=0;i<MAX_INVENTORY;i++) {
id = sd->status.inventory[i].nameid;
- sd->inventory_data[i] = id?itemdb_search(id):NULL;
+ sd->inventory_data[i] = id?itemdb->search(id):NULL;
}
return 0;
}
@@ -708,7 +720,7 @@ int pc_setequipindex(struct map_session_data *sd)
// if( item->card[MAX_SLOTS - 1] && s < MAX_SLOTS - 1 )
// s = MAX_SLOTS - 1;
//
-// ARR_FIND( 0, s, i, item->card[i] && (data = itemdb_exists(item->card[i])) != NULL && data->flag.no_equip&flag );
+// ARR_FIND( 0, s, i, item->card[i] && (data = itemdb->exists(item->card[i])) != NULL && data->flag.no_equip&flag );
// return( i < s ) ? 0 : 1;
//}
@@ -757,10 +769,10 @@ bool pc_can_Adopt(struct map_session_data *p1_sd, struct map_session_data *p2_sd
return false; // Both parents need to be in the same party
// Parents need to have their ring equipped
- if( !pc_isequipped(p1_sd, WEDDING_RING_M) && !pc_isequipped(p1_sd, WEDDING_RING_F) )
+ if( !pc->isequipped(p1_sd, WEDDING_RING_M) && !pc->isequipped(p1_sd, WEDDING_RING_F) )
return false;
- if( !pc_isequipped(p2_sd, WEDDING_RING_M) && !pc_isequipped(p2_sd, WEDDING_RING_F) )
+ if( !pc->isequipped(p2_sd, WEDDING_RING_M) && !pc->isequipped(p2_sd, WEDDING_RING_F) )
return false;
// Already adopted a baby
@@ -794,15 +806,15 @@ bool pc_adoption(struct map_session_data *p1_sd, struct map_session_data *p2_sd,
int job, joblevel;
unsigned int jobexp;
- if( !pc_can_Adopt(p1_sd, p2_sd, b_sd) )
+ if( !pc->can_Adopt(p1_sd, p2_sd, b_sd) )
return false;
// Preserve current job levels and progress
joblevel = b_sd->status.job_level;
jobexp = b_sd->status.job_exp;
- job = pc_mapid2jobid(b_sd->class_|JOBL_BABY, b_sd->status.sex);
- if( job != -1 && !pc_jobchange(b_sd, job, 0) )
+ job = pc->mapid2jobid(b_sd->class_|JOBL_BABY, b_sd->status.sex);
+ if( job != -1 && !pc->jobchange(b_sd, job, 0) )
{ // Success, proceed to configure parents and baby skills
p1_sd->status.child = b_sd->status.char_id;
p2_sd->status.child = b_sd->status.char_id;
@@ -816,12 +828,12 @@ bool pc_adoption(struct map_session_data *p1_sd, struct map_session_data *p2_sd,
clif->updatestatus(b_sd, SP_JOBEXP);
// Baby Skills
- pc_skill(b_sd, WE_BABY, 1, 0);
- pc_skill(b_sd, WE_CALLPARENT, 1, 0);
+ pc->skill(b_sd, WE_BABY, 1, 0);
+ pc->skill(b_sd, WE_CALLPARENT, 1, 0);
// Parents Skills
- pc_skill(p1_sd, WE_CALLBABY, 1, 0);
- pc_skill(p2_sd, WE_CALLBABY, 1, 0);
+ pc->skill(p1_sd, WE_CALLBABY, 1, 0);
+ pc->skill(p2_sd, WE_CALLBABY, 1, 0);
return true;
}
@@ -857,20 +869,20 @@ int pc_isequip(struct map_session_data *sd,int n)
if (sd->sc.count) {
- if(item->equip & EQP_ARMS && item->type == IT_WEAPON && sd->sc.data[SC_STRIPWEAPON]) // Also works with left-hand weapons [DracoRPG]
+ if(item->equip & EQP_ARMS && item->type == IT_WEAPON && sd->sc.data[SC_NOEQUIPWEAPON]) // Also works with left-hand weapons [DracoRPG]
return 0;
- if(item->equip & EQP_SHIELD && item->type == IT_ARMOR && sd->sc.data[SC_STRIPSHIELD])
+ if(item->equip & EQP_SHIELD && item->type == IT_ARMOR && sd->sc.data[SC_NOEQUIPSHIELD])
return 0;
- if(item->equip & EQP_ARMOR && sd->sc.data[SC_STRIPARMOR])
+ if(item->equip & EQP_ARMOR && sd->sc.data[SC_NOEQUIPARMOR])
return 0;
- if(item->equip & EQP_HEAD_TOP && sd->sc.data[SC_STRIPHELM])
+ if(item->equip & EQP_HEAD_TOP && sd->sc.data[SC_NOEQUIPHELM])
return 0;
- if(item->equip & EQP_ACC && sd->sc.data[SC__STRIPACCESSORY])
+ if(item->equip & EQP_ACC && sd->sc.data[SC__STRIPACCESSARY])
return 0;
if(item->equip && sd->sc.data[SC_KYOUGAKU])
return 0;
- if (sd->sc.data[SC_SPIRIT] && sd->sc.data[SC_SPIRIT]->val2 == SL_SUPERNOVICE) {
+ if (sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_SUPERNOVICE) {
//Spirit of Super Novice equip bonuses. [Skotlex]
if (sd->status.base_level > 90 && item->equip & EQP_HELM)
return 1; //Can equip all helms
@@ -905,10 +917,9 @@ int pc_isequip(struct map_session_data *sd,int n)
* No problem with the session id
* set the status that has been sent from char server
*------------------------------------------*/
-bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers)
-{
+bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers) {
int i;
- unsigned long tick = gettick();
+ unsigned long tick = iTimer->gettick();
uint32 ip = session[sd->fd]->client_addr;
sd->login_id2 = login_id2;
@@ -925,7 +936,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim
}
//Set the map-server used job id. [Skotlex]
- i = pc_jobid2mapid(sd->status.class_);
+ i = pc->jobid2mapid(sd->status.class_);
if (i == -1) { //Invalid class?
ShowError("pc_authok: Invalid class %d for player %s (%d:%d). Class was changed to novice.\n", sd->status.class_, sd->status.name, sd->status.account_id, sd->status.char_id);
sd->status.class_ = JOB_NOVICE;
@@ -975,6 +986,8 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim
sd->cansendmail_tick = tick;
sd->hchsysch_tick = tick;
+ sd->idletime = last_tick;
+
for(i = 0; i < MAX_SPIRITBALL; i++)
sd->spirit_timer[i] = INVALID_TIMER;
for(i = 0; i < ARRAYLENGTH(sd->autobonus); i++)
@@ -995,10 +1008,10 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim
if (!(battle_config.display_skill_fail&2))
sd->state.showdelay = 1;
- pc_setinventorydata(sd);
+ pc->setinventorydata(sd);
pc_setequipindex(sd);
- if( sd->status.option & OPTION_INVISIBLE && !pc_can_use_command(sd, "@hide") )
+ if( sd->status.option & OPTION_INVISIBLE && !pc->can_use_command(sd, "@hide") )
sd->status.option &=~ OPTION_INVISIBLE;
status_change_init(&sd->bl);
@@ -1014,6 +1027,19 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim
sd->disguise = -1;
+ sd->instance = NULL;
+ sd->instances = 0;
+
+ sd->bg_queue.arena = NULL;
+ sd->bg_queue.ready = 0;
+ sd->bg_queue.client_has_bg_data = 0;
+ sd->bg_queue.type = 0;
+
+ sd->queues = NULL;
+ sd->queues_count = 0;
+
+ sd->state.dialog = 0;
+
// Event Timers
for( i = 0; i < MAX_EVENTTIMER; i++ )
sd->eventtimer[i] = INVALID_TIMER;
@@ -1024,11 +1050,11 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim
sd->hate_mob[i] = -1;
//warp player
- if ((i=pc_setpos(sd,sd->status.last_point.map, sd->status.last_point.x, sd->status.last_point.y, CLR_OUTSIGHT)) != 0) {
+ if ((i=pc->setpos(sd,sd->status.last_point.map, sd->status.last_point.x, sd->status.last_point.y, CLR_OUTSIGHT)) != 0) {
ShowError ("Last_point_map %s - id %d not found (error code %d)\n", mapindex_id2name(sd->status.last_point.map), sd->status.last_point.map, i);
// try warping to a default map instead (church graveyard)
- if (pc_setpos(sd, mapindex_name2id(MAP_PRONTERA), 273, 354, CLR_OUTSIGHT) != 0) {
+ if (pc->setpos(sd, mapindex_name2id(MAP_PRONTERA), 273, 354, CLR_OUTSIGHT) != 0) {
// if we fail again
clif->authfail_fd(sd->fd, 0);
return false;
@@ -1069,13 +1095,13 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim
if (expiration_time != 0) { // don't display if it's unlimited or unknow value
char tmpstr[1024];
strftime(tmpstr, sizeof(tmpstr) - 1, msg_txt(501), localtime(&expiration_time)); // "Your account time limit is: %d-%m-%Y %H:%M:%S."
- clif->wis_message(sd->fd, wisp_server_name, tmpstr, strlen(tmpstr)+1);
+ clif->wis_message(sd->fd, iMap->wisp_server_name, tmpstr, strlen(tmpstr)+1);
}
/**
* Fixes login-without-aura glitch (the screen won't blink at this point, don't worry :P)
**/
- clif->changemap(sd,sd->mapindex,sd->bl.x,sd->bl.y);
+ clif->changemap(sd,sd->bl.m,sd->bl.x,sd->bl.y);
}
/**
@@ -1086,7 +1112,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim
/**
* Check if player have any item cooldowns on
**/
- pc_itemcd_do(sd,true);
+ pc->itemcd_do(sd,true);
/* [Ind/Hercules] */
sd->sc_display = NULL;
@@ -1160,7 +1186,7 @@ int pc_reg_received(struct map_session_data *sd)
for(i=0;i<MAX_PC_FEELHATE;i++) { //for now - someone need to make reading from txt/sql
if ((j = pc_readglobalreg(sd,sg_info[i].feel_var))!=0) {
sd->feel_map[i].index = j;
- sd->feel_map[i].m = map_mapindex2mapid(j);
+ sd->feel_map[i].m = iMap->mapindex2mapid(j);
} else {
sd->feel_map[i].index = 0;
sd->feel_map[i].m = -1;
@@ -1168,7 +1194,7 @@ int pc_reg_received(struct map_session_data *sd)
sd->hate_mob[i] = pc_readglobalreg(sd,sg_info[i].hate_var)-1;
}
- if ((i = pc_checkskill(sd,RG_PLAGIARISM)) > 0) {
+ if ((i = pc->checkskill(sd,RG_PLAGIARISM)) > 0) {
sd->cloneskill_id = pc_readglobalreg(sd,"CLONE_SKILL");
if (sd->cloneskill_id > 0 && (idx = skill->get_index(sd->cloneskill_id))) {
sd->status.skill[idx].id = sd->cloneskill_id;
@@ -1178,7 +1204,7 @@ int pc_reg_received(struct map_session_data *sd)
sd->status.skill[idx].flag = SKILL_FLAG_PLAGIARIZED;
}
}
- if ((i = pc_checkskill(sd,SC_REPRODUCE)) > 0) {
+ if ((i = pc->checkskill(sd,SC_REPRODUCE)) > 0) {
sd->reproduceskill_id = pc_readglobalreg(sd,"REPRODUCE_SKILL");
if( sd->reproduceskill_id > 0 && (idx = skill->get_index(sd->reproduceskill_id))) {
sd->status.skill[idx].id = sd->reproduceskill_id;
@@ -1194,7 +1220,7 @@ int pc_reg_received(struct map_session_data *sd)
sd->state.active = 1;
if (sd->status.party_id)
- party_member_joined(sd);
+ party->member_joined(sd);
if (sd->status.guild_id)
guild->member_joined(sd);
@@ -1210,12 +1236,12 @@ int pc_reg_received(struct map_session_data *sd)
if( sd->status.ele_id > 0 )
intif_elemental_request(sd->status.ele_id, sd->status.char_id);
- map_addiddb(&sd->bl);
- map_delnickdb(sd->status.char_id, sd->status.name);
+ iMap->addiddb(&sd->bl);
+ iMap->delnickdb(sd->status.char_id, sd->status.name);
if (!chrif_auth_finished(sd))
ShowError("pc_reg_received: Failed to properly remove player %d:%d from logging db!\n", sd->status.account_id, sd->status.char_id);
- pc_load_combo(sd);
+ pc->load_combo(sd);
status_calc_pc(sd,1);
chrif_scdata_request(sd->status.account_id, sd->status.char_id);
@@ -1228,7 +1254,7 @@ int pc_reg_received(struct map_session_data *sd)
clif->pLoadEndAck(sd->fd, sd);
}
- pc_inventory_rentals(sd);
+ pc->inventory_rentals(sd);
if( sd->sc.option & OPTION_INVISIBLE ) {
sd->vd.class_ = INVISIBLE_CLASS;
@@ -1237,7 +1263,7 @@ int pc_reg_received(struct map_session_data *sd)
map[sd->bl.m].users_pvp--;
if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) {// unregister the player for ranking
- delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
+ iTimer->delete_timer( sd->pvp_timer, pc->calc_pvprank_timer );
sd->pvp_timer = INVALID_TIMER;
}
clif->changeoption(&sd->bl);
@@ -1256,7 +1282,7 @@ static int pc_calc_skillpoint(struct map_session_data* sd)
nullpo_ret(sd);
for(i=1;i<MAX_SKILL;i++){
- if( (skill_lv = pc_checkskill2(sd,i)) > 0) {
+ if( (skill_lv = pc->checkskill2(sd,i)) > 0) {
inf2 = skill_db[i].inf2;
if((!(inf2&INF2_QUEST_SKILL) || battle_config.quest_skill_learn) &&
!(inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL)) //Do not count wedding/link skills. [Skotlex]
@@ -1282,14 +1308,14 @@ int pc_calc_skilltree(struct map_session_data *sd)
int c=0;
nullpo_ret(sd);
- i = pc_calc_skilltree_normalize_job(sd);
- c = pc_mapid2jobid(i, sd->status.sex);
+ i = pc->calc_skilltree_normalize_job(sd);
+ c = pc->mapid2jobid(i, sd->status.sex);
if( c == -1 )
{ //Unable to normalize job??
ShowError("pc_calc_skilltree: Unable to normalize job %d for character %s (%d:%d)\n", i, sd->status.name, sd->status.account_id, sd->status.char_id);
return 1;
}
- c = pc_class2idx(c);
+ c = pc->class2idx(c);
for( i = 0; i < MAX_SKILL; i++ ) {
if( sd->status.skill[i].flag != SKILL_FLAG_PLAGIARIZED && sd->status.skill[i].flag != SKILL_FLAG_PERM_GRANTED ) //Don't touch these
@@ -1315,7 +1341,7 @@ int pc_calc_skilltree(struct map_session_data *sd)
sd->status.skill[i].flag = SKILL_FLAG_PERMANENT;
}
- if( sd->sc.count && sd->sc.data[SC_SPIRIT] && sd->sc.data[SC_SPIRIT]->val2 == SL_BARDDANCER && skill_db[i].nameid >= DC_HUMMING && skill_db[i].nameid <= DC_SERVICEFORYOU )
+ if( sd->sc.count && sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_BARDDANCER && skill_db[i].nameid >= DC_HUMMING && skill_db[i].nameid <= DC_SERVICEFORYOU )
{ //Enable Bard/Dancer spirit linked skills.
if( sd->status.sex )
{ //Link dancer skills to bard.
@@ -1387,7 +1413,7 @@ int pc_calc_skilltree(struct map_session_data *sd)
else if (sd->status.skill[idx2].flag >= SKILL_FLAG_REPLACED_LV_0) //Real lerned level
k = sd->status.skill[idx2].flag - SKILL_FLAG_REPLACED_LV_0;
else
- k = pc_checkskill2(sd,idx2);
+ k = pc->checkskill2(sd,idx2);
if (k < skill_tree[c][i].need[j].lv) {
f = 0;
break;
@@ -1404,7 +1430,7 @@ int pc_calc_skilltree(struct map_session_data *sd)
if(!sd->status.skill[idx].lv && (
(inf2&INF2_QUEST_SKILL && !battle_config.quest_skill_learn) ||
inf2&INF2_WEDDING_SKILL ||
- (inf2&INF2_SPIRIT_SKILL && !sd->sc.data[SC_SPIRIT])
+ (inf2&INF2_SPIRIT_SKILL && !sd->sc.data[SC_SOULLINK])
))
continue; //Cannot be learned via normal means. Note this check DOES allows raising already known skills.
@@ -1420,7 +1446,7 @@ int pc_calc_skilltree(struct map_session_data *sd)
} while(flag);
//
- if( c > 0 && (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && sd->status.skill_point == 0 && pc_famerank(sd->status.char_id, MAPID_TAEKWON) )
+ if( c > 0 && (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && sd->status.skill_point == 0 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) )
{
/* Taekwon Ranger Bonus Skill Tree
============================================
@@ -1436,7 +1462,7 @@ int pc_calc_skilltree(struct map_session_data *sd)
if( sd->status.skill[idx].id == 0 ) {
sd->status.skill[idx].id = id;
sd->status.skill[idx].flag = SKILL_FLAG_TEMPORARY; // So it is not saved, and tagged as a "bonus" skill.
- } else if( id != NV_BASIC) {
+ } else if( id != NV_BASIC ) {
sd->status.skill[idx].flag = SKILL_FLAG_REPLACED_LV_0 + sd->status.skill[idx].lv; // Remember original level
}
@@ -1456,13 +1482,13 @@ static void pc_check_skilltree(struct map_session_data *sd, int skill_id)
if(battle_config.skillfree)
return; //Function serves no purpose if this is set
- i = pc_calc_skilltree_normalize_job(sd);
- c = pc_mapid2jobid(i, sd->status.sex);
+ i = pc->calc_skilltree_normalize_job(sd);
+ c = pc->mapid2jobid(i, sd->status.sex);
if (c == -1) { //Unable to normalize job??
ShowError("pc_check_skilltree: Unable to normalize job %d for character %s (%d:%d)\n", i, sd->status.name, sd->status.account_id, sd->status.char_id);
return;
}
- c = pc_class2idx(c);
+ c = pc->class2idx(c);
do {
flag = 0;
for( i = 0; i < MAX_SKILL_TREE && (id=skill_tree[c][i].id)>0; i++ ) {
@@ -1479,7 +1505,7 @@ static void pc_check_skilltree(struct map_session_data *sd, int skill_id)
else if( sd->status.skill[idx2].flag >= SKILL_FLAG_REPLACED_LV_0) //Real lerned level
k = sd->status.skill[idx2].flag - SKILL_FLAG_REPLACED_LV_0;
else
- k = pc_checkskill2(sd,idx2);
+ k = pc->checkskill2(sd,idx2);
if( k < skill_tree[c][i].need[j].lv ) {
f = 0;
break;
@@ -1495,7 +1521,7 @@ static void pc_check_skilltree(struct map_session_data *sd, int skill_id)
if( !sd->status.skill[idx].lv && (
(j&INF2_QUEST_SKILL && !battle_config.quest_skill_learn) ||
j&INF2_WEDDING_SKILL ||
- (j&INF2_SPIRIT_SKILL && !sd->sc.data[SC_SPIRIT])
+ (j&INF2_SPIRIT_SKILL && !sd->sc.data[SC_SOULLINK])
) )
continue; //Cannot be learned via normal means.
@@ -1534,7 +1560,7 @@ int pc_calc_skilltree_normalize_job(struct map_session_data *sd)
skill_point = pc_calc_skillpoint(sd);
- novice_skills = max_level[pc_class2idx(JOB_NOVICE)][1] - 1;
+ novice_skills = max_level[pc->class2idx(JOB_NOVICE)][1] - 1;
// limit 1st class and above to novice job levels
if(skill_point < novice_skills)
@@ -1551,7 +1577,7 @@ int pc_calc_skilltree_normalize_job(struct map_session_data *sd)
{
// if neither 2nd nor 3rd jobchange levels are known, we have to assume a default for 2nd
if (!sd->change_level_3rd)
- sd->change_level_2nd = max_level[pc_class2idx(pc_mapid2jobid(sd->class_&MAPID_UPPERMASK, sd->status.sex))][1];
+ sd->change_level_2nd = max_level[pc->class2idx(pc->mapid2jobid(sd->class_&MAPID_UPPERMASK, sd->status.sex))][1];
else
sd->change_level_2nd = 1 + skill_point + sd->status.skill_point
- (sd->status.job_level - 1)
@@ -1597,7 +1623,7 @@ int pc_calc_skilltree_normalize_job(struct map_session_data *sd)
*------------------------------------------
* 1: overweight 50%
* 2: overweight 90%
- * It's assumed that SC_WEIGHT50 and SC_WEIGHT90 are only started/stopped here.
+ * It's assumed that SC_WEIGHTOVER50 and SC_WEIGHTOVER90 are only started/stopped here.
*/
int pc_updateweightstatus(struct map_session_data *sd)
{
@@ -1606,7 +1632,7 @@ int pc_updateweightstatus(struct map_session_data *sd)
nullpo_retr(1, sd);
- old_overweight = (sd->sc.data[SC_WEIGHT90]) ? 2 : (sd->sc.data[SC_WEIGHT50]) ? 1 : 0;
+ old_overweight = (sd->sc.data[SC_WEIGHTOVER90]) ? 2 : (sd->sc.data[SC_WEIGHTOVER50]) ? 1 : 0;
new_overweight = (pc_is90overweight(sd)) ? 2 : (pc_is50overweight(sd)) ? 1 : 0;
if( old_overweight == new_overweight )
@@ -1614,15 +1640,15 @@ int pc_updateweightstatus(struct map_session_data *sd)
// stop old status change
if( old_overweight == 1 )
- status_change_end(&sd->bl, SC_WEIGHT50, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_WEIGHTOVER50, INVALID_TIMER);
else if( old_overweight == 2 )
- status_change_end(&sd->bl, SC_WEIGHT90, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_WEIGHTOVER90, INVALID_TIMER);
// start new status change
if( new_overweight == 1 )
- sc_start(&sd->bl, SC_WEIGHT50, 100, 0, 0);
+ sc_start(&sd->bl, SC_WEIGHTOVER50, 100, 0, 0);
else if( new_overweight == 2 )
- sc_start(&sd->bl, SC_WEIGHT90, 100, 0, 0);
+ sc_start(&sd->bl, SC_WEIGHTOVER90, 100, 0, 0);
// update overweight status
sd->regen.state.overweight = new_overweight;
@@ -1783,9 +1809,9 @@ static int pc_bonus_addeff_onskill(struct s_addeffectonskill* effect, int max, e
return 1;
}
-static int pc_bonus_item_drop(struct s_add_drop *drop, const short max, short id, short group, int race, int rate)
-{
+static int pc_bonus_item_drop(struct s_add_drop *drop, const short max, short id, short group, int race, int rate) {
int i;
+
//Apply config rate adjustment settings.
if (rate >= 0) { //Absolute drop.
if (battle_config.item_rate_adddrop != 100)
@@ -1890,7 +1916,7 @@ int pc_delautobonus(struct map_session_data* sd, struct s_autobonus *autobonus,c
}
else
{ // Logout / Unequipped an item with an activated bonus
- delete_timer(autobonus[i].active,pc_endautobonus);
+ iTimer->delete_timer(autobonus[i].active,pc->endautobonus);
autobonus[i].active = INVALID_TIMER;
}
}
@@ -1918,7 +1944,7 @@ int pc_exeautobonus(struct map_session_data *sd,struct s_autobonus *autobonus)
script_run_autobonus(autobonus->other_script,sd->bl.id,sd->equip_index[j]);
}
- autobonus->active = add_timer(gettick()+autobonus->duration, pc_endautobonus, sd->bl.id, (intptr_t)autobonus);
+ autobonus->active = iTimer->add_timer(iTimer->gettick()+autobonus->duration, pc->endautobonus, sd->bl.id, (intptr_t)autobonus);
sd->state.autobonus |= autobonus->pos;
status_calc_pc(sd,0);
@@ -1927,7 +1953,7 @@ int pc_exeautobonus(struct map_session_data *sd,struct s_autobonus *autobonus)
int pc_endautobonus(int tid, unsigned int tick, int id, intptr_t data)
{
- struct map_session_data *sd = map_id2sd(id);
+ struct map_session_data *sd = iMap->id2sd(id);
struct s_autobonus *autobonus = (struct s_autobonus *)data;
nullpo_ret(sd);
@@ -2047,12 +2073,13 @@ int pc_bonus(struct map_session_data *sd,int type,int val)
break;
case SP_BASE_ATK:
if(sd->state.lr_flag != 2) {
- //#ifdef RENEWAL
- // sd->bonus.eatk += val;
- //#else
+#ifdef RENEWAL
+ sd->bonus.eatk += val;
+ clif->updatestatus(sd,SP_ATK2);
+#else
bonus = status->batk + val;
status->batk = cap_value(bonus, 0, USHRT_MAX);
- //#endif
+#endif
}
break;
case SP_DEF1:
@@ -2408,7 +2435,7 @@ int pc_bonus(struct map_session_data *sd,int type,int val)
case SP_INTRAVISION: // Maya Purple Card effect allowing to see Hiding/Cloaking people [DracoRPG]
if(sd->state.lr_flag != 2) {
sd->special_state.intravision = 1;
- clif->status_change(&sd->bl, SI_INTRAVISION, 1, 0, 0, 0, 0);
+ clif->status_change(&sd->bl, SI_CLAIRVOYANCE, 1, 0, 0, 0, 0);
}
break;
case SP_NO_KNOCKBACK:
@@ -2611,6 +2638,10 @@ int pc_bonus(struct map_session_data *sd,int type,int val)
break;
#endif
+ case SP_ADD_MONSTER_DROP_CHAINITEM:
+ if (sd->state.lr_flag != 2)
+ pc_bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), 0, val, (1<<RC_BOSS)|(1<<RC_NONBOSS), 10000);
+ break;
default:
ShowWarning("pc_bonus: unknown type %d %d !\n",type,val);
break;
@@ -2628,593 +2659,589 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
nullpo_ret(sd);
switch(type){
- case SP_ADDELE:
- if(type2 >= ELE_MAX) {
- ShowError("pc_bonus2: SP_ADDELE: Invalid element %d\n", type2);
+ case SP_ADDELE:
+ if(type2 >= ELE_MAX) {
+ ShowError("pc_bonus2: SP_ADDELE: Invalid element %d\n", type2);
+ break;
+ }
+ if(!sd->state.lr_flag)
+ sd->right_weapon.addele[type2]+=val;
+ else if(sd->state.lr_flag == 1)
+ sd->left_weapon.addele[type2]+=val;
+ else if(sd->state.lr_flag == 2)
+ sd->arrow_addele[type2]+=val;
break;
- }
- if(!sd->state.lr_flag)
- sd->right_weapon.addele[type2]+=val;
- else if(sd->state.lr_flag == 1)
- sd->left_weapon.addele[type2]+=val;
- else if(sd->state.lr_flag == 2)
- sd->arrow_addele[type2]+=val;
- break;
- case SP_ADDRACE:
- if(!sd->state.lr_flag)
- sd->right_weapon.addrace[type2]+=val;
- else if(sd->state.lr_flag == 1)
- sd->left_weapon.addrace[type2]+=val;
- else if(sd->state.lr_flag == 2)
- sd->arrow_addrace[type2]+=val;
- break;
- case SP_ADDSIZE:
- if(!sd->state.lr_flag)
- sd->right_weapon.addsize[type2]+=val;
- else if(sd->state.lr_flag == 1)
- sd->left_weapon.addsize[type2]+=val;
- else if(sd->state.lr_flag == 2)
- sd->arrow_addsize[type2]+=val;
- break;
- case SP_SUBELE:
- if(type2 >= ELE_MAX) {
- ShowError("pc_bonus2: SP_SUBELE: Invalid element %d\n", type2);
+ case SP_ADDRACE:
+ if(!sd->state.lr_flag)
+ sd->right_weapon.addrace[type2]+=val;
+ else if(sd->state.lr_flag == 1)
+ sd->left_weapon.addrace[type2]+=val;
+ else if(sd->state.lr_flag == 2)
+ sd->arrow_addrace[type2]+=val;
break;
- }
- if(sd->state.lr_flag != 2)
- sd->subele[type2]+=val;
- break;
- case SP_SUBRACE:
- if(sd->state.lr_flag != 2)
- sd->subrace[type2]+=val;
- break;
- case SP_ADDEFF:
- if (type2 > SC_MAX) {
- ShowWarning("pc_bonus2 (Add Effect): %d is not supported.\n", type2);
+ case SP_ADDSIZE:
+ if(!sd->state.lr_flag)
+ sd->right_weapon.addsize[type2]+=val;
+ else if(sd->state.lr_flag == 1)
+ sd->left_weapon.addsize[type2]+=val;
+ else if(sd->state.lr_flag == 2)
+ sd->arrow_addsize[type2]+=val;
break;
- }
- pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2,
- sd->state.lr_flag!=2?val:0, sd->state.lr_flag==2?val:0, 0);
- break;
- case SP_ADDEFF2:
- if (type2 > SC_MAX) {
- ShowWarning("pc_bonus2 (Add Effect2): %d is not supported.\n", type2);
+ case SP_SUBELE:
+ if(type2 >= ELE_MAX) {
+ ShowError("pc_bonus2: SP_SUBELE: Invalid element %d\n", type2);
+ break;
+ }
+ if(sd->state.lr_flag != 2)
+ sd->subele[type2]+=val;
break;
- }
- pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2,
- sd->state.lr_flag!=2?val:0, sd->state.lr_flag==2?val:0, ATF_SELF);
- break;
- case SP_RESEFF:
- if (type2 < SC_COMMON_MIN || type2 > SC_COMMON_MAX) {
- ShowWarning("pc_bonus2 (Resist Effect): %d is not supported.\n", type2);
+ case SP_SUBRACE:
+ if(sd->state.lr_flag != 2)
+ sd->subrace[type2]+=val;
break;
- }
- if(sd->state.lr_flag == 2)
+ case SP_ADDEFF:
+ if (type2 > SC_MAX) {
+ ShowWarning("pc_bonus2 (Add Effect): %d is not supported.\n", type2);
+ break;
+ }
+ pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2,
+ sd->state.lr_flag!=2?val:0, sd->state.lr_flag==2?val:0, 0);
break;
- i = sd->reseff[type2-SC_COMMON_MIN]+val;
- sd->reseff[type2-SC_COMMON_MIN]= cap_value(i, 0, 10000);
- break;
- case SP_MAGIC_ADDELE:
- if(type2 >= ELE_MAX) {
- ShowError("pc_bonus2: SP_MAGIC_ADDELE: Invalid element %d\n", type2);
+ case SP_ADDEFF2:
+ if (type2 > SC_MAX) {
+ ShowWarning("pc_bonus2 (Add Effect2): %d is not supported.\n", type2);
+ break;
+ }
+ pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2,
+ sd->state.lr_flag!=2?val:0, sd->state.lr_flag==2?val:0, ATF_SELF);
break;
- }
- if(sd->state.lr_flag != 2)
- sd->magic_addele[type2]+=val;
- break;
- case SP_MAGIC_ADDRACE:
- if(sd->state.lr_flag != 2)
- sd->magic_addrace[type2]+=val;
- break;
- case SP_MAGIC_ADDSIZE:
- if(sd->state.lr_flag != 2)
- sd->magic_addsize[type2]+=val;
- break;
- case SP_MAGIC_ATK_ELE:
- if(sd->state.lr_flag != 2)
- sd->magic_atk_ele[type2]+=val;
- break;
- case SP_ADD_DAMAGE_CLASS:
- switch (sd->state.lr_flag) {
- case 0: //Right hand
- ARR_FIND(0, ARRAYLENGTH(sd->right_weapon.add_dmg), i, sd->right_weapon.add_dmg[i].rate == 0 || sd->right_weapon.add_dmg[i].class_ == type2);
- if (i == ARRAYLENGTH(sd->right_weapon.add_dmg))
- {
- ShowWarning("pc_bonus2: Reached max (%d) number of add Class dmg bonuses per character!\n", ARRAYLENGTH(sd->right_weapon.add_dmg));
+ case SP_RESEFF:
+ if (type2 < SC_COMMON_MIN || type2 > SC_COMMON_MAX) {
+ ShowWarning("pc_bonus2 (Resist Effect): %d is not supported.\n", type2);
+ break;
+ }
+ if(sd->state.lr_flag == 2)
+ break;
+ i = sd->reseff[type2-SC_COMMON_MIN]+val;
+ sd->reseff[type2-SC_COMMON_MIN]= cap_value(i, 0, 10000);
+ break;
+ case SP_MAGIC_ADDELE:
+ if(type2 >= ELE_MAX) {
+ ShowError("pc_bonus2: SP_MAGIC_ADDELE: Invalid element %d\n", type2);
break;
}
- sd->right_weapon.add_dmg[i].class_ = type2;
- sd->right_weapon.add_dmg[i].rate += val;
- if (!sd->right_weapon.add_dmg[i].rate) //Shift the rest of elements up.
- memmove(&sd->right_weapon.add_dmg[i], &sd->right_weapon.add_dmg[i+1], sizeof(sd->right_weapon.add_dmg) - (i+1)*sizeof(sd->right_weapon.add_dmg[0]));
+ if(sd->state.lr_flag != 2)
+ sd->magic_addele[type2]+=val;
break;
- case 1: //Left hand
- ARR_FIND(0, ARRAYLENGTH(sd->left_weapon.add_dmg), i, sd->left_weapon.add_dmg[i].rate == 0 || sd->left_weapon.add_dmg[i].class_ == type2);
- if (i == ARRAYLENGTH(sd->left_weapon.add_dmg))
+ case SP_MAGIC_ADDRACE:
+ if(sd->state.lr_flag != 2)
+ sd->magic_addrace[type2]+=val;
+ break;
+ case SP_MAGIC_ADDSIZE:
+ if(sd->state.lr_flag != 2)
+ sd->magic_addsize[type2]+=val;
+ break;
+ case SP_MAGIC_ATK_ELE:
+ if(sd->state.lr_flag != 2)
+ sd->magic_atk_ele[type2]+=val;
+ break;
+ case SP_ADD_DAMAGE_CLASS:
+ switch (sd->state.lr_flag) {
+ case 0: //Right hand
+ ARR_FIND(0, ARRAYLENGTH(sd->right_weapon.add_dmg), i, sd->right_weapon.add_dmg[i].rate == 0 || sd->right_weapon.add_dmg[i].class_ == type2);
+ if (i == ARRAYLENGTH(sd->right_weapon.add_dmg))
+ {
+ ShowWarning("pc_bonus2: Reached max (%d) number of add Class dmg bonuses per character!\n", ARRAYLENGTH(sd->right_weapon.add_dmg));
+ break;
+ }
+ sd->right_weapon.add_dmg[i].class_ = type2;
+ sd->right_weapon.add_dmg[i].rate += val;
+ if (!sd->right_weapon.add_dmg[i].rate) //Shift the rest of elements up.
+ memmove(&sd->right_weapon.add_dmg[i], &sd->right_weapon.add_dmg[i+1], sizeof(sd->right_weapon.add_dmg) - (i+1)*sizeof(sd->right_weapon.add_dmg[0]));
+ break;
+ case 1: //Left hand
+ ARR_FIND(0, ARRAYLENGTH(sd->left_weapon.add_dmg), i, sd->left_weapon.add_dmg[i].rate == 0 || sd->left_weapon.add_dmg[i].class_ == type2);
+ if (i == ARRAYLENGTH(sd->left_weapon.add_dmg))
+ {
+ ShowWarning("pc_bonus2: Reached max (%d) number of add Class dmg bonuses per character!\n", ARRAYLENGTH(sd->left_weapon.add_dmg));
+ break;
+ }
+ sd->left_weapon.add_dmg[i].class_ = type2;
+ sd->left_weapon.add_dmg[i].rate += val;
+ if (!sd->left_weapon.add_dmg[i].rate) //Shift the rest of elements up.
+ memmove(&sd->left_weapon.add_dmg[i], &sd->left_weapon.add_dmg[i+1], sizeof(sd->left_weapon.add_dmg) - (i+1)*sizeof(sd->left_weapon.add_dmg[0]));
+ break;
+ }
+ break;
+ case SP_ADD_MAGIC_DAMAGE_CLASS:
+ if(sd->state.lr_flag == 2)
+ break;
+ ARR_FIND(0, ARRAYLENGTH(sd->add_mdmg), i, sd->add_mdmg[i].rate == 0 || sd->add_mdmg[i].class_ == type2);
+ if (i == ARRAYLENGTH(sd->add_mdmg))
{
- ShowWarning("pc_bonus2: Reached max (%d) number of add Class dmg bonuses per character!\n", ARRAYLENGTH(sd->left_weapon.add_dmg));
+ ShowWarning("pc_bonus2: Reached max (%d) number of add Class magic dmg bonuses per character!\n", ARRAYLENGTH(sd->add_mdmg));
break;
}
- sd->left_weapon.add_dmg[i].class_ = type2;
- sd->left_weapon.add_dmg[i].rate += val;
- if (!sd->left_weapon.add_dmg[i].rate) //Shift the rest of elements up.
- memmove(&sd->left_weapon.add_dmg[i], &sd->left_weapon.add_dmg[i+1], sizeof(sd->left_weapon.add_dmg) - (i+1)*sizeof(sd->left_weapon.add_dmg[0]));
+ sd->add_mdmg[i].class_ = type2;
+ sd->add_mdmg[i].rate += val;
+ if (!sd->add_mdmg[i].rate) //Shift the rest of elements up.
+ memmove(&sd->add_mdmg[i], &sd->add_mdmg[i+1], sizeof(sd->add_mdmg) - (i+1)*sizeof(sd->add_mdmg[0]));
break;
- }
- break;
- case SP_ADD_MAGIC_DAMAGE_CLASS:
- if(sd->state.lr_flag == 2)
+ case SP_ADD_DEF_CLASS:
+ if(sd->state.lr_flag == 2)
+ break;
+ ARR_FIND(0, ARRAYLENGTH(sd->add_def), i, sd->add_def[i].rate == 0 || sd->add_def[i].class_ == type2);
+ if (i == ARRAYLENGTH(sd->add_def))
+ {
+ ShowWarning("pc_bonus2: Reached max (%d) number of add Class def bonuses per character!\n", ARRAYLENGTH(sd->add_def));
+ break;
+ }
+ sd->add_def[i].class_ = type2;
+ sd->add_def[i].rate += val;
+ if (!sd->add_def[i].rate) //Shift the rest of elements up.
+ memmove(&sd->add_def[i], &sd->add_def[i+1], sizeof(sd->add_def) - (i+1)*sizeof(sd->add_def[0]));
break;
- ARR_FIND(0, ARRAYLENGTH(sd->add_mdmg), i, sd->add_mdmg[i].rate == 0 || sd->add_mdmg[i].class_ == type2);
- if (i == ARRAYLENGTH(sd->add_mdmg))
- {
- ShowWarning("pc_bonus2: Reached max (%d) number of add Class magic dmg bonuses per character!\n", ARRAYLENGTH(sd->add_mdmg));
+ case SP_ADD_MDEF_CLASS:
+ if(sd->state.lr_flag == 2)
+ break;
+ ARR_FIND(0, ARRAYLENGTH(sd->add_mdef), i, sd->add_mdef[i].rate == 0 || sd->add_mdef[i].class_ == type2);
+ if (i == ARRAYLENGTH(sd->add_mdef))
+ {
+ ShowWarning("pc_bonus2: Reached max (%d) number of add Class mdef bonuses per character!\n", ARRAYLENGTH(sd->add_mdef));
+ break;
+ }
+ sd->add_mdef[i].class_ = type2;
+ sd->add_mdef[i].rate += val;
+ if (!sd->add_mdef[i].rate) //Shift the rest of elements up.
+ memmove(&sd->add_mdef[i], &sd->add_mdef[i+1], sizeof(sd->add_mdef) - (i+1)*sizeof(sd->add_mdef[0]));
break;
- }
- sd->add_mdmg[i].class_ = type2;
- sd->add_mdmg[i].rate += val;
- if (!sd->add_mdmg[i].rate) //Shift the rest of elements up.
- memmove(&sd->add_mdmg[i], &sd->add_mdmg[i+1], sizeof(sd->add_mdmg) - (i+1)*sizeof(sd->add_mdmg[0]));
- break;
- case SP_ADD_DEF_CLASS:
- if(sd->state.lr_flag == 2)
+ case SP_HP_DRAIN_RATE:
+ if(!sd->state.lr_flag) {
+ sd->right_weapon.hp_drain[RC_NONBOSS].rate += type2;
+ sd->right_weapon.hp_drain[RC_NONBOSS].per += val;
+ sd->right_weapon.hp_drain[RC_BOSS].rate += type2;
+ sd->right_weapon.hp_drain[RC_BOSS].per += val;
+ }
+ else if(sd->state.lr_flag == 1) {
+ sd->left_weapon.hp_drain[RC_NONBOSS].rate += type2;
+ sd->left_weapon.hp_drain[RC_NONBOSS].per += val;
+ sd->left_weapon.hp_drain[RC_BOSS].rate += type2;
+ sd->left_weapon.hp_drain[RC_BOSS].per += val;
+ }
break;
- ARR_FIND(0, ARRAYLENGTH(sd->add_def), i, sd->add_def[i].rate == 0 || sd->add_def[i].class_ == type2);
- if (i == ARRAYLENGTH(sd->add_def))
- {
- ShowWarning("pc_bonus2: Reached max (%d) number of add Class def bonuses per character!\n", ARRAYLENGTH(sd->add_def));
+ case SP_HP_DRAIN_VALUE:
+ if(!sd->state.lr_flag) {
+ sd->right_weapon.hp_drain[RC_NONBOSS].value += type2;
+ sd->right_weapon.hp_drain[RC_NONBOSS].type = val;
+ sd->right_weapon.hp_drain[RC_BOSS].value += type2;
+ sd->right_weapon.hp_drain[RC_BOSS].type = val;
+ }
+ else if(sd->state.lr_flag == 1) {
+ sd->left_weapon.hp_drain[RC_NONBOSS].value += type2;
+ sd->left_weapon.hp_drain[RC_NONBOSS].type = val;
+ sd->left_weapon.hp_drain[RC_BOSS].value += type2;
+ sd->left_weapon.hp_drain[RC_BOSS].type = val;
+ }
break;
- }
- sd->add_def[i].class_ = type2;
- sd->add_def[i].rate += val;
- if (!sd->add_def[i].rate) //Shift the rest of elements up.
- memmove(&sd->add_def[i], &sd->add_def[i+1], sizeof(sd->add_def) - (i+1)*sizeof(sd->add_def[0]));
- break;
- case SP_ADD_MDEF_CLASS:
- if(sd->state.lr_flag == 2)
+ case SP_SP_DRAIN_RATE:
+ if(!sd->state.lr_flag) {
+ sd->right_weapon.sp_drain[RC_NONBOSS].rate += type2;
+ sd->right_weapon.sp_drain[RC_NONBOSS].per += val;
+ sd->right_weapon.sp_drain[RC_BOSS].rate += type2;
+ sd->right_weapon.sp_drain[RC_BOSS].per += val;
+ }
+ else if(sd->state.lr_flag == 1) {
+ sd->left_weapon.sp_drain[RC_NONBOSS].rate += type2;
+ sd->left_weapon.sp_drain[RC_NONBOSS].per += val;
+ sd->left_weapon.sp_drain[RC_BOSS].rate += type2;
+ sd->left_weapon.sp_drain[RC_BOSS].per += val;
+ }
break;
- ARR_FIND(0, ARRAYLENGTH(sd->add_mdef), i, sd->add_mdef[i].rate == 0 || sd->add_mdef[i].class_ == type2);
- if (i == ARRAYLENGTH(sd->add_mdef))
- {
- ShowWarning("pc_bonus2: Reached max (%d) number of add Class mdef bonuses per character!\n", ARRAYLENGTH(sd->add_mdef));
+ case SP_SP_DRAIN_VALUE:
+ if(!sd->state.lr_flag) {
+ sd->right_weapon.sp_drain[RC_NONBOSS].value += type2;
+ sd->right_weapon.sp_drain[RC_NONBOSS].type = val;
+ sd->right_weapon.sp_drain[RC_BOSS].value += type2;
+ sd->right_weapon.sp_drain[RC_BOSS].type = val;
+ }
+ else if(sd->state.lr_flag == 1) {
+ sd->left_weapon.sp_drain[RC_NONBOSS].value += type2;
+ sd->left_weapon.sp_drain[RC_NONBOSS].type = val;
+ sd->left_weapon.sp_drain[RC_BOSS].value += type2;
+ sd->left_weapon.sp_drain[RC_BOSS].type = val;
+ }
break;
- }
- sd->add_mdef[i].class_ = type2;
- sd->add_mdef[i].rate += val;
- if (!sd->add_mdef[i].rate) //Shift the rest of elements up.
- memmove(&sd->add_mdef[i], &sd->add_mdef[i+1], sizeof(sd->add_mdef) - (i+1)*sizeof(sd->add_mdef[0]));
- break;
- case SP_HP_DRAIN_RATE:
- if(!sd->state.lr_flag) {
- sd->right_weapon.hp_drain[RC_NONBOSS].rate += type2;
- sd->right_weapon.hp_drain[RC_NONBOSS].per += val;
- sd->right_weapon.hp_drain[RC_BOSS].rate += type2;
- sd->right_weapon.hp_drain[RC_BOSS].per += val;
- }
- else if(sd->state.lr_flag == 1) {
- sd->left_weapon.hp_drain[RC_NONBOSS].rate += type2;
- sd->left_weapon.hp_drain[RC_NONBOSS].per += val;
- sd->left_weapon.hp_drain[RC_BOSS].rate += type2;
- sd->left_weapon.hp_drain[RC_BOSS].per += val;
- }
- break;
- case SP_HP_DRAIN_VALUE:
- if(!sd->state.lr_flag) {
- sd->right_weapon.hp_drain[RC_NONBOSS].value += type2;
- sd->right_weapon.hp_drain[RC_NONBOSS].type = val;
- sd->right_weapon.hp_drain[RC_BOSS].value += type2;
- sd->right_weapon.hp_drain[RC_BOSS].type = val;
- }
- else if(sd->state.lr_flag == 1) {
- sd->left_weapon.hp_drain[RC_NONBOSS].value += type2;
- sd->left_weapon.hp_drain[RC_NONBOSS].type = val;
- sd->left_weapon.hp_drain[RC_BOSS].value += type2;
- sd->left_weapon.hp_drain[RC_BOSS].type = val;
- }
- break;
- case SP_SP_DRAIN_RATE:
- if(!sd->state.lr_flag) {
- sd->right_weapon.sp_drain[RC_NONBOSS].rate += type2;
- sd->right_weapon.sp_drain[RC_NONBOSS].per += val;
- sd->right_weapon.sp_drain[RC_BOSS].rate += type2;
- sd->right_weapon.sp_drain[RC_BOSS].per += val;
- }
- else if(sd->state.lr_flag == 1) {
- sd->left_weapon.sp_drain[RC_NONBOSS].rate += type2;
- sd->left_weapon.sp_drain[RC_NONBOSS].per += val;
- sd->left_weapon.sp_drain[RC_BOSS].rate += type2;
- sd->left_weapon.sp_drain[RC_BOSS].per += val;
- }
- break;
- case SP_SP_DRAIN_VALUE:
- if(!sd->state.lr_flag) {
- sd->right_weapon.sp_drain[RC_NONBOSS].value += type2;
- sd->right_weapon.sp_drain[RC_NONBOSS].type = val;
- sd->right_weapon.sp_drain[RC_BOSS].value += type2;
- sd->right_weapon.sp_drain[RC_BOSS].type = val;
- }
- else if(sd->state.lr_flag == 1) {
- sd->left_weapon.sp_drain[RC_NONBOSS].value += type2;
- sd->left_weapon.sp_drain[RC_NONBOSS].type = val;
- sd->left_weapon.sp_drain[RC_BOSS].value += type2;
- sd->left_weapon.sp_drain[RC_BOSS].type = val;
- }
- break;
- case SP_SP_VANISH_RATE:
- if(sd->state.lr_flag != 2) {
- sd->bonus.sp_vanish_rate += type2;
- sd->bonus.sp_vanish_per += val;
- }
- break;
- case SP_GET_ZENY_NUM:
- if(sd->state.lr_flag != 2 && sd->bonus.get_zeny_rate < val) {
- sd->bonus.get_zeny_rate = val;
- sd->bonus.get_zeny_num = type2;
- }
- break;
- case SP_ADD_GET_ZENY_NUM:
- if(sd->state.lr_flag != 2) {
- sd->bonus.get_zeny_rate += val;
- sd->bonus.get_zeny_num += type2;
- }
- break;
- case SP_WEAPON_COMA_ELE:
- if(type2 >= ELE_MAX) {
- ShowError("pc_bonus2: SP_WEAPON_COMA_ELE: Invalid element %d\n", type2);
+ case SP_SP_VANISH_RATE:
+ if(sd->state.lr_flag != 2) {
+ sd->bonus.sp_vanish_rate += type2;
+ sd->bonus.sp_vanish_per += val;
+ }
break;
- }
- if(sd->state.lr_flag == 2)
+ case SP_GET_ZENY_NUM:
+ if(sd->state.lr_flag != 2 && sd->bonus.get_zeny_rate < val) {
+ sd->bonus.get_zeny_rate = val;
+ sd->bonus.get_zeny_num = type2;
+ }
break;
- sd->weapon_coma_ele[type2] += val;
- sd->special_state.bonus_coma = 1;
- break;
- case SP_WEAPON_COMA_RACE:
- if(sd->state.lr_flag == 2)
+ case SP_ADD_GET_ZENY_NUM:
+ if(sd->state.lr_flag != 2) {
+ sd->bonus.get_zeny_rate += val;
+ sd->bonus.get_zeny_num += type2;
+ }
break;
- sd->weapon_coma_race[type2] += val;
- sd->special_state.bonus_coma = 1;
- break;
- case SP_WEAPON_ATK:
- if(sd->state.lr_flag != 2)
- sd->weapon_atk[type2]+=val;
- break;
- case SP_WEAPON_ATK_RATE:
- if(sd->state.lr_flag != 2)
- sd->weapon_atk_rate[type2]+=val;
- break;
- case SP_CRITICAL_ADDRACE:
- if(sd->state.lr_flag != 2)
- sd->critaddrace[type2] += val*10;
- break;
- case SP_ADDEFF_WHENHIT:
- if (type2 > SC_MAX) {
- ShowWarning("pc_bonus2 (Add Effect when hit): %d is not supported.\n", type2);
+ case SP_WEAPON_COMA_ELE:
+ if(type2 >= ELE_MAX) {
+ ShowError("pc_bonus2: SP_WEAPON_COMA_ELE: Invalid element %d\n", type2);
+ break;
+ }
+ if(sd->state.lr_flag == 2)
+ break;
+ sd->weapon_coma_ele[type2] += val;
+ sd->special_state.bonus_coma = 1;
break;
- }
- if(sd->state.lr_flag != 2)
- pc_bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), (sc_type)type2, val, 0, 0);
- break;
- case SP_SKILL_ATK:
- if(sd->state.lr_flag == 2)
+ case SP_WEAPON_COMA_RACE:
+ if(sd->state.lr_flag == 2)
+ break;
+ sd->weapon_coma_race[type2] += val;
+ sd->special_state.bonus_coma = 1;
break;
- ARR_FIND(0, ARRAYLENGTH(sd->skillatk), i, sd->skillatk[i].id == 0 || sd->skillatk[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillatk))
- { //Better mention this so the array length can be updated. [Skotlex]
- ShowDebug("run_script: bonus2 bSkillAtk reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillatk), type2, val);
+ case SP_WEAPON_ATK:
+ if(sd->state.lr_flag != 2)
+ sd->weapon_atk[type2]+=val;
break;
- }
- if (sd->skillatk[i].id == type2)
- sd->skillatk[i].val += val;
- else {
- sd->skillatk[i].id = type2;
- sd->skillatk[i].val = val;
- }
- break;
- case SP_SKILL_HEAL:
- if(sd->state.lr_flag == 2)
+ case SP_WEAPON_ATK_RATE:
+ if(sd->state.lr_flag != 2)
+ sd->weapon_atk_rate[type2]+=val;
break;
- ARR_FIND(0, ARRAYLENGTH(sd->skillheal), i, sd->skillheal[i].id == 0 || sd->skillheal[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillheal))
- { // Better mention this so the array length can be updated. [Skotlex]
- ShowDebug("run_script: bonus2 bSkillHeal reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillheal), type2, val);
+ case SP_CRITICAL_ADDRACE:
+ if(sd->state.lr_flag != 2)
+ sd->critaddrace[type2] += val*10;
break;
- }
- if (sd->skillheal[i].id == type2)
- sd->skillheal[i].val += val;
- else {
- sd->skillheal[i].id = type2;
- sd->skillheal[i].val = val;
- }
- break;
- case SP_SKILL_HEAL2:
- if(sd->state.lr_flag == 2)
+ case SP_ADDEFF_WHENHIT:
+ if (type2 > SC_MAX) {
+ ShowWarning("pc_bonus2 (Add Effect when hit): %d is not supported.\n", type2);
+ break;
+ }
+ if(sd->state.lr_flag != 2)
+ pc_bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), (sc_type)type2, val, 0, 0);
break;
- ARR_FIND(0, ARRAYLENGTH(sd->skillheal2), i, sd->skillheal2[i].id == 0 || sd->skillheal2[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillheal2))
- { // Better mention this so the array length can be updated. [Skotlex]
- ShowDebug("run_script: bonus2 bSkillHeal2 reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillheal2), type2, val);
+ case SP_SKILL_ATK:
+ if(sd->state.lr_flag == 2)
+ break;
+ ARR_FIND(0, ARRAYLENGTH(sd->skillatk), i, sd->skillatk[i].id == 0 || sd->skillatk[i].id == type2);
+ if (i == ARRAYLENGTH(sd->skillatk))
+ { //Better mention this so the array length can be updated. [Skotlex]
+ ShowDebug("run_script: bonus2 bSkillAtk reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillatk), type2, val);
+ break;
+ }
+ if (sd->skillatk[i].id == type2)
+ sd->skillatk[i].val += val;
+ else {
+ sd->skillatk[i].id = type2;
+ sd->skillatk[i].val = val;
+ }
break;
- }
- if (sd->skillheal2[i].id == type2)
- sd->skillheal2[i].val += val;
- else {
- sd->skillheal2[i].id = type2;
- sd->skillheal2[i].val = val;
- }
- break;
- case SP_ADD_SKILL_BLOW:
- if(sd->state.lr_flag == 2)
+ case SP_SKILL_HEAL:
+ if(sd->state.lr_flag == 2)
+ break;
+ ARR_FIND(0, ARRAYLENGTH(sd->skillheal), i, sd->skillheal[i].id == 0 || sd->skillheal[i].id == type2);
+ if (i == ARRAYLENGTH(sd->skillheal))
+ { // Better mention this so the array length can be updated. [Skotlex]
+ ShowDebug("run_script: bonus2 bSkillHeal reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillheal), type2, val);
+ break;
+ }
+ if (sd->skillheal[i].id == type2)
+ sd->skillheal[i].val += val;
+ else {
+ sd->skillheal[i].id = type2;
+ sd->skillheal[i].val = val;
+ }
break;
- ARR_FIND(0, ARRAYLENGTH(sd->skillblown), i, sd->skillblown[i].id == 0 || sd->skillblown[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillblown))
- { //Better mention this so the array length can be updated. [Skotlex]
- ShowDebug("run_script: bonus2 bSkillBlown reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillblown), type2, val);
+ case SP_SKILL_HEAL2:
+ if(sd->state.lr_flag == 2)
+ break;
+ ARR_FIND(0, ARRAYLENGTH(sd->skillheal2), i, sd->skillheal2[i].id == 0 || sd->skillheal2[i].id == type2);
+ if (i == ARRAYLENGTH(sd->skillheal2))
+ { // Better mention this so the array length can be updated. [Skotlex]
+ ShowDebug("run_script: bonus2 bSkillHeal2 reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillheal2), type2, val);
+ break;
+ }
+ if (sd->skillheal2[i].id == type2)
+ sd->skillheal2[i].val += val;
+ else {
+ sd->skillheal2[i].id = type2;
+ sd->skillheal2[i].val = val;
+ }
break;
- }
- if(sd->skillblown[i].id == type2)
- sd->skillblown[i].val += val;
- else {
- sd->skillblown[i].id = type2;
- sd->skillblown[i].val = val;
- }
- break;
-#ifndef RENEWAL_CAST
- case SP_VARCASTRATE:
-#endif
- case SP_CASTRATE:
- if(sd->state.lr_flag == 2)
+ case SP_ADD_SKILL_BLOW:
+ if(sd->state.lr_flag == 2)
+ break;
+ ARR_FIND(0, ARRAYLENGTH(sd->skillblown), i, sd->skillblown[i].id == 0 || sd->skillblown[i].id == type2);
+ if (i == ARRAYLENGTH(sd->skillblown))
+ { //Better mention this so the array length can be updated. [Skotlex]
+ ShowDebug("run_script: bonus2 bSkillBlown reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillblown), type2, val);
+ break;
+ }
+ if(sd->skillblown[i].id == type2)
+ sd->skillblown[i].val += val;
+ else {
+ sd->skillblown[i].id = type2;
+ sd->skillblown[i].val = val;
+ }
break;
- ARR_FIND(0, ARRAYLENGTH(sd->skillcast), i, sd->skillcast[i].id == 0 || sd->skillcast[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillcast))
- { //Better mention this so the array length can be updated. [Skotlex]
- ShowDebug("run_script: bonus2 %s reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n",
+ #ifndef RENEWAL_CAST
+ case SP_VARCASTRATE:
+ #endif
+ case SP_CASTRATE:
+ if(sd->state.lr_flag == 2)
+ break;
+ ARR_FIND(0, ARRAYLENGTH(sd->skillcast), i, sd->skillcast[i].id == 0 || sd->skillcast[i].id == type2);
+ if (i == ARRAYLENGTH(sd->skillcast))
+ { //Better mention this so the array length can be updated. [Skotlex]
+ ShowDebug("run_script: bonus2 %s reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n",
-#ifndef RENEWAL_CAST
- "bCastRate",
-#else
- "bVariableCastrate",
-#endif
+ #ifndef RENEWAL_CAST
+ "bCastRate",
+ #else
+ "bVariableCastrate",
+ #endif
- ARRAYLENGTH(sd->skillcast), type2, val);
+ ARRAYLENGTH(sd->skillcast), type2, val);
+ break;
+ }
+ if(sd->skillcast[i].id == type2)
+ sd->skillcast[i].val += val;
+ else {
+ sd->skillcast[i].id = type2;
+ sd->skillcast[i].val = val;
+ }
break;
- }
- if(sd->skillcast[i].id == type2)
- sd->skillcast[i].val += val;
- else {
- sd->skillcast[i].id = type2;
- sd->skillcast[i].val = val;
- }
- break;
- case SP_FIXCASTRATE:
- if(sd->state.lr_flag == 2)
- break;
+ case SP_FIXCASTRATE:
+ if(sd->state.lr_flag == 2)
+ break;
- ARR_FIND(0, ARRAYLENGTH(sd->skillfixcastrate), i, sd->skillfixcastrate[i].id == 0 || sd->skillfixcastrate[i].id == type2);
+ ARR_FIND(0, ARRAYLENGTH(sd->skillfixcastrate), i, sd->skillfixcastrate[i].id == 0 || sd->skillfixcastrate[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillfixcastrate))
+ if (i == ARRAYLENGTH(sd->skillfixcastrate))
- {
+ {
- ShowDebug("run_script: bonus2 bFixedCastrate reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillfixcastrate), type2, val);
- break;
- }
+ ShowDebug("run_script: bonus2 bFixedCastrate reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillfixcastrate), type2, val);
+ break;
+ }
- if(sd->skillfixcastrate[i].id == type2)
- sd->skillfixcastrate[i].val += val;
+ if(sd->skillfixcastrate[i].id == type2)
+ sd->skillfixcastrate[i].val += val;
- else {
- sd->skillfixcastrate[i].id = type2;
- sd->skillfixcastrate[i].val = val;
- }
+ else {
+ sd->skillfixcastrate[i].id = type2;
+ sd->skillfixcastrate[i].val = val;
+ }
- break;
+ break;
- case SP_HP_LOSS_RATE:
- if(sd->state.lr_flag != 2) {
- sd->hp_loss.value = type2;
- sd->hp_loss.rate = val;
- }
- break;
- case SP_HP_REGEN_RATE:
- if(sd->state.lr_flag != 2) {
- sd->hp_regen.value = type2;
- sd->hp_regen.rate = val;
- }
- break;
- case SP_ADDRACE2:
- if (!(type2 > RC2_NONE && type2 < RC2_MAX))
+ case SP_HP_LOSS_RATE:
+ if(sd->state.lr_flag != 2) {
+ sd->hp_loss.value = type2;
+ sd->hp_loss.rate = val;
+ }
break;
- if(sd->state.lr_flag != 2)
- sd->right_weapon.addrace2[type2] += val;
- else
- sd->left_weapon.addrace2[type2] += val;
- break;
- case SP_SUBSIZE:
- if(sd->state.lr_flag != 2)
- sd->subsize[type2]+=val;
- break;
- case SP_SUBRACE2:
- if (!(type2 > RC2_NONE && type2 < RC2_MAX))
+ case SP_HP_REGEN_RATE:
+ if(sd->state.lr_flag != 2) {
+ sd->hp_regen.value = type2;
+ sd->hp_regen.rate = val;
+ }
break;
- if(sd->state.lr_flag != 2)
- sd->subrace2[type2]+=val;
- break;
- case SP_ADD_ITEM_HEAL_RATE:
- if(sd->state.lr_flag == 2)
+ case SP_ADDRACE2:
+ if (!(type2 > RC2_NONE && type2 < RC2_MAX))
+ break;
+ if(sd->state.lr_flag != 2)
+ sd->right_weapon.addrace2[type2] += val;
+ else
+ sd->left_weapon.addrace2[type2] += val;
break;
- if (type2 < MAX_ITEMGROUP) { //Group bonus
- sd->itemgrouphealrate[type2] += val;
+ case SP_SUBSIZE:
+ if(sd->state.lr_flag != 2)
+ sd->subsize[type2]+=val;
break;
- }
- //Standard item bonus.
- for(i=0; i < ARRAYLENGTH(sd->itemhealrate) && sd->itemhealrate[i].nameid && sd->itemhealrate[i].nameid != type2; i++);
- if(i == ARRAYLENGTH(sd->itemhealrate)) {
- ShowWarning("pc_bonus2: Reached max (%d) number of item heal bonuses per character!\n", ARRAYLENGTH(sd->itemhealrate));
+ case SP_SUBRACE2:
+ if (!(type2 > RC2_NONE && type2 < RC2_MAX))
+ break;
+ if(sd->state.lr_flag != 2)
+ sd->subrace2[type2]+=val;
break;
- }
- sd->itemhealrate[i].nameid = type2;
- sd->itemhealrate[i].rate += val;
- break;
- case SP_EXP_ADDRACE:
- if(sd->state.lr_flag != 2)
- sd->expaddrace[type2]+=val;
- break;
- case SP_SP_GAIN_RACE:
- if(sd->state.lr_flag != 2)
- sd->sp_gain_race[type2]+=val;
- break;
- case SP_ADD_MONSTER_DROP_ITEM:
- if (sd->state.lr_flag != 2)
- pc_bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), type2, 0, (1<<RC_BOSS)|(1<<RC_NONBOSS), val);
- break;
- case SP_ADD_MONSTER_DROP_ITEMGROUP:
- if (sd->state.lr_flag != 2)
- pc_bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), 0, type2, (1<<RC_BOSS)|(1<<RC_NONBOSS), val);
- break;
- case SP_SP_LOSS_RATE:
- if(sd->state.lr_flag != 2) {
- sd->sp_loss.value = type2;
- sd->sp_loss.rate = val;
- }
- break;
- case SP_SP_REGEN_RATE:
- if(sd->state.lr_flag != 2) {
- sd->sp_regen.value = type2;
- sd->sp_regen.rate = val;
- }
- break;
- case SP_HP_DRAIN_VALUE_RACE:
- if(!sd->state.lr_flag) {
- sd->right_weapon.hp_drain[type2].value += val;
- }
- else if(sd->state.lr_flag == 1) {
- sd->left_weapon.hp_drain[type2].value += val;
- }
- break;
- case SP_SP_DRAIN_VALUE_RACE:
- if(!sd->state.lr_flag) {
- sd->right_weapon.sp_drain[type2].value += val;
- }
- else if(sd->state.lr_flag == 1) {
- sd->left_weapon.sp_drain[type2].value += val;
- }
- break;
- case SP_IGNORE_MDEF_RATE:
- if(sd->state.lr_flag != 2)
- sd->ignore_mdef[type2] += val;
- break;
- case SP_IGNORE_DEF_RATE:
- if(sd->state.lr_flag != 2)
- sd->ignore_def[type2] += val;
- break;
- case SP_SP_GAIN_RACE_ATTACK:
- if(sd->state.lr_flag != 2)
- sd->sp_gain_race_attack[type2] = cap_value(sd->sp_gain_race_attack[type2] + val, 0, INT16_MAX);
- break;
- case SP_HP_GAIN_RACE_ATTACK:
- if(sd->state.lr_flag != 2)
- sd->hp_gain_race_attack[type2] = cap_value(sd->hp_gain_race_attack[type2] + val, 0, INT16_MAX);
- break;
- case SP_SKILL_USE_SP_RATE: //bonus2 bSkillUseSPrate,n,x;
- if(sd->state.lr_flag == 2)
+ case SP_ADD_ITEM_HEAL_RATE:
+ if(sd->state.lr_flag == 2)
+ break;
+ //Standard item bonus.
+ for(i=0; i < ARRAYLENGTH(sd->itemhealrate) && sd->itemhealrate[i].nameid && sd->itemhealrate[i].nameid != type2; i++);
+ if(i == ARRAYLENGTH(sd->itemhealrate)) {
+ ShowWarning("pc_bonus2: Reached max (%d) number of item heal bonuses per character!\n", ARRAYLENGTH(sd->itemhealrate));
+ break;
+ }
+ sd->itemhealrate[i].nameid = type2;
+ sd->itemhealrate[i].rate += val;
break;
- ARR_FIND(0, ARRAYLENGTH(sd->skillusesprate), i, sd->skillusesprate[i].id == 0 || sd->skillusesprate[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillusesprate)) {
- ShowDebug("run_script: bonus2 bSkillUseSPrate reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillusesprate), type2, val);
+ case SP_EXP_ADDRACE:
+ if(sd->state.lr_flag != 2)
+ sd->expaddrace[type2]+=val;
break;
- }
- if (sd->skillusesprate[i].id == type2)
- sd->skillusesprate[i].val += val;
- else {
- sd->skillusesprate[i].id = type2;
- sd->skillusesprate[i].val = val;
- }
- break;
- case SP_SKILL_COOLDOWN:
- if(sd->state.lr_flag == 2)
+ case SP_SP_GAIN_RACE:
+ if(sd->state.lr_flag != 2)
+ sd->sp_gain_race[type2]+=val;
break;
- ARR_FIND(0, ARRAYLENGTH(sd->skillcooldown), i, sd->skillcooldown[i].id == 0 || sd->skillcooldown[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillcooldown))
- {
- ShowDebug("run_script: bonus2 bSkillCoolDown reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillcooldown), type2, val);
+ case SP_ADD_MONSTER_DROP_ITEM:
+ if (sd->state.lr_flag != 2)
+ pc_bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), type2, 0, (1<<RC_BOSS)|(1<<RC_NONBOSS), val);
break;
- }
- if (sd->skillcooldown[i].id == type2)
- sd->skillcooldown[i].val += val;
- else {
- sd->skillcooldown[i].id = type2;
- sd->skillcooldown[i].val = val;
- }
- break;
- case SP_SKILL_FIXEDCAST:
- if(sd->state.lr_flag == 2)
+ case SP_SP_LOSS_RATE:
+ if(sd->state.lr_flag != 2) {
+ sd->sp_loss.value = type2;
+ sd->sp_loss.rate = val;
+ }
break;
- ARR_FIND(0, ARRAYLENGTH(sd->skillfixcast), i, sd->skillfixcast[i].id == 0 || sd->skillfixcast[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillfixcast))
- {
- ShowDebug("run_script: bonus2 bSkillFixedCast reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillfixcast), type2, val);
+ case SP_SP_REGEN_RATE:
+ if(sd->state.lr_flag != 2) {
+ sd->sp_regen.value = type2;
+ sd->sp_regen.rate = val;
+ }
break;
- }
- if (sd->skillfixcast[i].id == type2)
- sd->skillfixcast[i].val += val;
- else {
- sd->skillfixcast[i].id = type2;
- sd->skillfixcast[i].val = val;
- }
- break;
- case SP_SKILL_VARIABLECAST:
- if(sd->state.lr_flag == 2)
+ case SP_HP_DRAIN_VALUE_RACE:
+ if(!sd->state.lr_flag) {
+ sd->right_weapon.hp_drain[type2].value += val;
+ }
+ else if(sd->state.lr_flag == 1) {
+ sd->left_weapon.hp_drain[type2].value += val;
+ }
break;
- ARR_FIND(0, ARRAYLENGTH(sd->skillvarcast), i, sd->skillvarcast[i].id == 0 || sd->skillvarcast[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillvarcast))
- {
- ShowDebug("run_script: bonus2 bSkillVariableCast reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillvarcast), type2, val);
+ case SP_SP_DRAIN_VALUE_RACE:
+ if(!sd->state.lr_flag) {
+ sd->right_weapon.sp_drain[type2].value += val;
+ }
+ else if(sd->state.lr_flag == 1) {
+ sd->left_weapon.sp_drain[type2].value += val;
+ }
break;
- }
- if (sd->skillvarcast[i].id == type2)
- sd->skillvarcast[i].val += val;
- else {
- sd->skillvarcast[i].id = type2;
- sd->skillvarcast[i].val = val;
- }
- break;
-#ifdef RENEWAL_CAST
- case SP_VARCASTRATE:
- if(sd->state.lr_flag == 2)
+ case SP_IGNORE_MDEF_RATE:
+ if(sd->state.lr_flag != 2)
+ sd->ignore_mdef[type2] += val;
break;
- ARR_FIND(0, ARRAYLENGTH(sd->skillcast), i, sd->skillcast[i].id == 0 || sd->skillcast[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillcast))
- {
- ShowDebug("run_script: bonus2 bVariableCastrate reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n",ARRAYLENGTH(sd->skillcast), type2, val);
+ case SP_IGNORE_DEF_RATE:
+ if(sd->state.lr_flag != 2)
+ sd->ignore_def[type2] += val;
break;
- }
- if(sd->skillcast[i].id == type2)
- sd->skillcast[i].val -= val;
- else {
- sd->skillcast[i].id = type2;
- sd->skillcast[i].val -= val;
- }
- break;
-#endif
- case SP_SKILL_USE_SP: //bonus2 bSkillUseSP,n,x;
- if(sd->state.lr_flag == 2)
+ case SP_SP_GAIN_RACE_ATTACK:
+ if(sd->state.lr_flag != 2)
+ sd->sp_gain_race_attack[type2] = cap_value(sd->sp_gain_race_attack[type2] + val, 0, INT16_MAX);
break;
- ARR_FIND(0, ARRAYLENGTH(sd->skillusesp), i, sd->skillusesp[i].id == 0 || sd->skillusesp[i].id == type2);
- if (i == ARRAYLENGTH(sd->skillusesp)) {
- ShowDebug("run_script: bonus2 bSkillUseSP reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillusesp), type2, val);
+ case SP_HP_GAIN_RACE_ATTACK:
+ if(sd->state.lr_flag != 2)
+ sd->hp_gain_race_attack[type2] = cap_value(sd->hp_gain_race_attack[type2] + val, 0, INT16_MAX);
+ break;
+ case SP_SKILL_USE_SP_RATE: //bonus2 bSkillUseSPrate,n,x;
+ if(sd->state.lr_flag == 2)
+ break;
+ ARR_FIND(0, ARRAYLENGTH(sd->skillusesprate), i, sd->skillusesprate[i].id == 0 || sd->skillusesprate[i].id == type2);
+ if (i == ARRAYLENGTH(sd->skillusesprate)) {
+ ShowDebug("run_script: bonus2 bSkillUseSPrate reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillusesprate), type2, val);
+ break;
+ }
+ if (sd->skillusesprate[i].id == type2)
+ sd->skillusesprate[i].val += val;
+ else {
+ sd->skillusesprate[i].id = type2;
+ sd->skillusesprate[i].val = val;
+ }
+ break;
+ case SP_SKILL_COOLDOWN:
+ if(sd->state.lr_flag == 2)
+ break;
+ ARR_FIND(0, ARRAYLENGTH(sd->skillcooldown), i, sd->skillcooldown[i].id == 0 || sd->skillcooldown[i].id == type2);
+ if (i == ARRAYLENGTH(sd->skillcooldown))
+ {
+ ShowDebug("run_script: bonus2 bSkillCoolDown reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillcooldown), type2, val);
+ break;
+ }
+ if (sd->skillcooldown[i].id == type2)
+ sd->skillcooldown[i].val += val;
+ else {
+ sd->skillcooldown[i].id = type2;
+ sd->skillcooldown[i].val = val;
+ }
+ break;
+ case SP_SKILL_FIXEDCAST:
+ if(sd->state.lr_flag == 2)
+ break;
+ ARR_FIND(0, ARRAYLENGTH(sd->skillfixcast), i, sd->skillfixcast[i].id == 0 || sd->skillfixcast[i].id == type2);
+ if (i == ARRAYLENGTH(sd->skillfixcast))
+ {
+ ShowDebug("run_script: bonus2 bSkillFixedCast reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillfixcast), type2, val);
+ break;
+ }
+ if (sd->skillfixcast[i].id == type2)
+ sd->skillfixcast[i].val += val;
+ else {
+ sd->skillfixcast[i].id = type2;
+ sd->skillfixcast[i].val = val;
+ }
+ break;
+ case SP_SKILL_VARIABLECAST:
+ if(sd->state.lr_flag == 2)
+ break;
+ ARR_FIND(0, ARRAYLENGTH(sd->skillvarcast), i, sd->skillvarcast[i].id == 0 || sd->skillvarcast[i].id == type2);
+ if (i == ARRAYLENGTH(sd->skillvarcast))
+ {
+ ShowDebug("run_script: bonus2 bSkillVariableCast reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillvarcast), type2, val);
+ break;
+ }
+ if (sd->skillvarcast[i].id == type2)
+ sd->skillvarcast[i].val += val;
+ else {
+ sd->skillvarcast[i].id = type2;
+ sd->skillvarcast[i].val = val;
+ }
+ break;
+ #ifdef RENEWAL_CAST
+ case SP_VARCASTRATE:
+ if(sd->state.lr_flag == 2)
+ break;
+ ARR_FIND(0, ARRAYLENGTH(sd->skillcast), i, sd->skillcast[i].id == 0 || sd->skillcast[i].id == type2);
+ if (i == ARRAYLENGTH(sd->skillcast))
+ {
+ ShowDebug("run_script: bonus2 bVariableCastrate reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n",ARRAYLENGTH(sd->skillcast), type2, val);
+ break;
+ }
+ if(sd->skillcast[i].id == type2)
+ sd->skillcast[i].val -= val;
+ else {
+ sd->skillcast[i].id = type2;
+ sd->skillcast[i].val -= val;
+ }
+ break;
+ #endif
+ case SP_SKILL_USE_SP: //bonus2 bSkillUseSP,n,x;
+ if(sd->state.lr_flag == 2)
+ break;
+ ARR_FIND(0, ARRAYLENGTH(sd->skillusesp), i, sd->skillusesp[i].id == 0 || sd->skillusesp[i].id == type2);
+ if (i == ARRAYLENGTH(sd->skillusesp)) {
+ ShowDebug("run_script: bonus2 bSkillUseSP reached it's limit (%d skills per character), bonus skill %d (+%d%%) lost.\n", ARRAYLENGTH(sd->skillusesp), type2, val);
+ break;
+ }
+ if (sd->skillusesp[i].id == type2)
+ sd->skillusesp[i].val += val;
+ else {
+ sd->skillusesp[i].id = type2;
+ sd->skillusesp[i].val = val;
+ }
+ break;
+ case SP_ADD_MONSTER_DROP_CHAINITEM:
+ if (sd->state.lr_flag != 2)
+ pc_bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), 0, val, 1<<type2, 10000);
+ break;
+ default:
+ ShowWarning("pc_bonus2: unknown type %d %d %d!\n",type,type2,val);
break;
- }
- if (sd->skillusesp[i].id == type2)
- sd->skillusesp[i].val += val;
- else {
- sd->skillusesp[i].id = type2;
- sd->skillusesp[i].val = val;
- }
- break;
- default:
- ShowWarning("pc_bonus2: unknown type %d %d %d!\n",type,type2,val);
- break;
}
return 0;
}
@@ -3224,124 +3251,119 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
nullpo_ret(sd);
switch(type){
- case SP_ADD_MONSTER_DROP_ITEM:
- if(sd->state.lr_flag != 2)
- pc_bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), type2, 0, 1<<type3, val);
- break;
- case SP_ADD_CLASS_DROP_ITEM:
- if(sd->state.lr_flag != 2)
- pc_bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), type2, 0, -type3, val);
- break;
- case SP_AUTOSPELL:
- if(sd->state.lr_flag != 2)
- {
- int target = skill->get_inf(type2); //Support or Self (non-auto-target) skills should pick self.
- target = target&INF_SUPPORT_SKILL || (target&INF_SELF_SKILL && !(skill->get_inf2(type2)&INF2_NO_TARGET_SELF));
- pc_bonus_autospell(sd->autospell, ARRAYLENGTH(sd->autospell),
- target?-type2:type2, type3, val, 0, current_equip_card_id);
- }
- break;
- case SP_AUTOSPELL_WHENHIT:
- if(sd->state.lr_flag != 2)
- {
- int target = skill->get_inf(type2); //Support or Self (non-auto-target) skills should pick self.
- target = target&INF_SUPPORT_SKILL || (target&INF_SELF_SKILL && !(skill->get_inf2(type2)&INF2_NO_TARGET_SELF));
- pc_bonus_autospell(sd->autospell2, ARRAYLENGTH(sd->autospell2),
- target?-type2:type2, type3, val, BF_NORMAL|BF_SKILL, current_equip_card_id);
- }
- break;
- case SP_SP_DRAIN_RATE:
- if(!sd->state.lr_flag) {
- sd->right_weapon.sp_drain[RC_NONBOSS].rate += type2;
- sd->right_weapon.sp_drain[RC_NONBOSS].per += type3;
- sd->right_weapon.sp_drain[RC_NONBOSS].type = val;
- sd->right_weapon.sp_drain[RC_BOSS].rate += type2;
- sd->right_weapon.sp_drain[RC_BOSS].per += type3;
- sd->right_weapon.sp_drain[RC_BOSS].type = val;
-
- }
- else if(sd->state.lr_flag == 1) {
- sd->left_weapon.sp_drain[RC_NONBOSS].rate += type2;
- sd->left_weapon.sp_drain[RC_NONBOSS].per += type3;
- sd->left_weapon.sp_drain[RC_NONBOSS].type = val;
- sd->left_weapon.sp_drain[RC_BOSS].rate += type2;
- sd->left_weapon.sp_drain[RC_BOSS].per += type3;
- sd->left_weapon.sp_drain[RC_BOSS].type = val;
- }
- break;
- case SP_HP_DRAIN_RATE_RACE:
- if(!sd->state.lr_flag) {
- sd->right_weapon.hp_drain[type2].rate += type3;
- sd->right_weapon.hp_drain[type2].per += val;
- }
- else if(sd->state.lr_flag == 1) {
- sd->left_weapon.hp_drain[type2].rate += type3;
- sd->left_weapon.hp_drain[type2].per += val;
- }
- break;
- case SP_SP_DRAIN_RATE_RACE:
- if(!sd->state.lr_flag) {
- sd->right_weapon.sp_drain[type2].rate += type3;
- sd->right_weapon.sp_drain[type2].per += val;
- }
- else if(sd->state.lr_flag == 1) {
- sd->left_weapon.sp_drain[type2].rate += type3;
- sd->left_weapon.sp_drain[type2].per += val;
- }
- break;
- case SP_ADD_MONSTER_DROP_ITEMGROUP:
- if (sd->state.lr_flag != 2)
- pc_bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), 0, type2, 1<<type3, val);
- break;
+ case SP_ADD_MONSTER_DROP_ITEM:
+ if(sd->state.lr_flag != 2)
+ pc_bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), type2, 0, 1<<type3, val);
+ break;
+ case SP_ADD_CLASS_DROP_ITEM:
+ if(sd->state.lr_flag != 2)
+ pc_bonus_item_drop(sd->add_drop, ARRAYLENGTH(sd->add_drop), type2, 0, -type3, val);
+ break;
+ case SP_AUTOSPELL:
+ if(sd->state.lr_flag != 2)
+ {
+ int target = skill->get_inf(type2); //Support or Self (non-auto-target) skills should pick self.
+ target = target&INF_SUPPORT_SKILL || (target&INF_SELF_SKILL && !(skill->get_inf2(type2)&INF2_NO_TARGET_SELF));
+ pc_bonus_autospell(sd->autospell, ARRAYLENGTH(sd->autospell),
+ target?-type2:type2, type3, val, 0, current_equip_card_id);
+ }
+ break;
+ case SP_AUTOSPELL_WHENHIT:
+ if(sd->state.lr_flag != 2)
+ {
+ int target = skill->get_inf(type2); //Support or Self (non-auto-target) skills should pick self.
+ target = target&INF_SUPPORT_SKILL || (target&INF_SELF_SKILL && !(skill->get_inf2(type2)&INF2_NO_TARGET_SELF));
+ pc_bonus_autospell(sd->autospell2, ARRAYLENGTH(sd->autospell2),
+ target?-type2:type2, type3, val, BF_NORMAL|BF_SKILL, current_equip_card_id);
+ }
+ break;
+ case SP_SP_DRAIN_RATE:
+ if(!sd->state.lr_flag) {
+ sd->right_weapon.sp_drain[RC_NONBOSS].rate += type2;
+ sd->right_weapon.sp_drain[RC_NONBOSS].per += type3;
+ sd->right_weapon.sp_drain[RC_NONBOSS].type = val;
+ sd->right_weapon.sp_drain[RC_BOSS].rate += type2;
+ sd->right_weapon.sp_drain[RC_BOSS].per += type3;
+ sd->right_weapon.sp_drain[RC_BOSS].type = val;
- case SP_ADDEFF:
- if (type2 > SC_MAX) {
- ShowWarning("pc_bonus3 (Add Effect): %d is not supported.\n", type2);
+ }
+ else if(sd->state.lr_flag == 1) {
+ sd->left_weapon.sp_drain[RC_NONBOSS].rate += type2;
+ sd->left_weapon.sp_drain[RC_NONBOSS].per += type3;
+ sd->left_weapon.sp_drain[RC_NONBOSS].type = val;
+ sd->left_weapon.sp_drain[RC_BOSS].rate += type2;
+ sd->left_weapon.sp_drain[RC_BOSS].per += type3;
+ sd->left_weapon.sp_drain[RC_BOSS].type = val;
+ }
+ break;
+ case SP_HP_DRAIN_RATE_RACE:
+ if(!sd->state.lr_flag) {
+ sd->right_weapon.hp_drain[type2].rate += type3;
+ sd->right_weapon.hp_drain[type2].per += val;
+ }
+ else if(sd->state.lr_flag == 1) {
+ sd->left_weapon.hp_drain[type2].rate += type3;
+ sd->left_weapon.hp_drain[type2].per += val;
+ }
+ break;
+ case SP_SP_DRAIN_RATE_RACE:
+ if(!sd->state.lr_flag) {
+ sd->right_weapon.sp_drain[type2].rate += type3;
+ sd->right_weapon.sp_drain[type2].per += val;
+ }
+ else if(sd->state.lr_flag == 1) {
+ sd->left_weapon.sp_drain[type2].rate += type3;
+ sd->left_weapon.sp_drain[type2].per += val;
+ }
+ break;
+ case SP_ADDEFF:
+ if (type2 > SC_MAX) {
+ ShowWarning("pc_bonus3 (Add Effect): %d is not supported.\n", type2);
+ break;
+ }
+ pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2,
+ sd->state.lr_flag!=2?type3:0, sd->state.lr_flag==2?type3:0, val);
break;
- }
- pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2,
- sd->state.lr_flag!=2?type3:0, sd->state.lr_flag==2?type3:0, val);
- break;
- case SP_ADDEFF_WHENHIT:
- if (type2 > SC_MAX) {
- ShowWarning("pc_bonus3 (Add Effect when hit): %d is not supported.\n", type2);
+ case SP_ADDEFF_WHENHIT:
+ if (type2 > SC_MAX) {
+ ShowWarning("pc_bonus3 (Add Effect when hit): %d is not supported.\n", type2);
+ break;
+ }
+ if(sd->state.lr_flag != 2)
+ pc_bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), (sc_type)type2, type3, 0, val);
break;
- }
- if(sd->state.lr_flag != 2)
- pc_bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), (sc_type)type2, type3, 0, val);
- break;
- case SP_ADDEFF_ONSKILL:
- if( type3 > SC_MAX ) {
- ShowWarning("pc_bonus3 (Add Effect on skill): %d is not supported.\n", type3);
+ case SP_ADDEFF_ONSKILL:
+ if( type3 > SC_MAX ) {
+ ShowWarning("pc_bonus3 (Add Effect on skill): %d is not supported.\n", type3);
+ break;
+ }
+ if( sd->state.lr_flag != 2 )
+ pc_bonus_addeff_onskill(sd->addeff3, ARRAYLENGTH(sd->addeff3), (sc_type)type3, val, type2, ATF_TARGET);
break;
- }
- if( sd->state.lr_flag != 2 )
- pc_bonus_addeff_onskill(sd->addeff3, ARRAYLENGTH(sd->addeff3), (sc_type)type3, val, type2, ATF_TARGET);
- break;
- case SP_ADDELE:
- if (type2 > ELE_MAX) {
- ShowWarning("pc_bonus3 (SP_ADDELE): element %d is out of range.\n", type2);
+ case SP_ADDELE:
+ if (type2 > ELE_MAX) {
+ ShowWarning("pc_bonus3 (SP_ADDELE): element %d is out of range.\n", type2);
+ break;
+ }
+ if (sd->state.lr_flag != 2)
+ pc_bonus_addele(sd, (unsigned char)type2, type3, val);
break;
- }
- if (sd->state.lr_flag != 2)
- pc_bonus_addele(sd, (unsigned char)type2, type3, val);
- break;
- case SP_SUBELE:
- if (type2 > ELE_MAX) {
- ShowWarning("pc_bonus3 (SP_SUBELE): element %d is out of range.\n", type2);
+ case SP_SUBELE:
+ if (type2 > ELE_MAX) {
+ ShowWarning("pc_bonus3 (SP_SUBELE): element %d is out of range.\n", type2);
+ break;
+ }
+ if (sd->state.lr_flag != 2)
+ pc_bonus_subele(sd, (unsigned char)type2, type3, val);
break;
- }
- if (sd->state.lr_flag != 2)
- pc_bonus_subele(sd, (unsigned char)type2, type3, val);
- break;
- default:
- ShowWarning("pc_bonus3: unknown type %d %d %d %d!\n",type,type2,type3,val);
- break;
+ default:
+ ShowWarning("pc_bonus3: unknown type %d %d %d %d!\n",type,type2,type3,val);
+ break;
}
return 0;
@@ -3394,24 +3416,24 @@ int pc_bonus5(struct map_session_data *sd,int type,int type2,int type3,int type4
nullpo_ret(sd);
switch(type){
- case SP_AUTOSPELL:
- if(sd->state.lr_flag != 2)
- pc_bonus_autospell(sd->autospell, ARRAYLENGTH(sd->autospell), (val&1?type2:-type2), (val&2?-type3:type3), type4, type5, current_equip_card_id);
- break;
+ case SP_AUTOSPELL:
+ if(sd->state.lr_flag != 2)
+ pc_bonus_autospell(sd->autospell, ARRAYLENGTH(sd->autospell), (val&1?type2:-type2), (val&2?-type3:type3), type4, type5, current_equip_card_id);
+ break;
- case SP_AUTOSPELL_WHENHIT:
- if(sd->state.lr_flag != 2)
- pc_bonus_autospell(sd->autospell2, ARRAYLENGTH(sd->autospell2), (val&1?type2:-type2), (val&2?-type3:type3), type4, type5, current_equip_card_id);
- break;
+ case SP_AUTOSPELL_WHENHIT:
+ if(sd->state.lr_flag != 2)
+ pc_bonus_autospell(sd->autospell2, ARRAYLENGTH(sd->autospell2), (val&1?type2:-type2), (val&2?-type3:type3), type4, type5, current_equip_card_id);
+ break;
- case SP_AUTOSPELL_ONSKILL:
- if(sd->state.lr_flag != 2)
- pc_bonus_autospell_onskill(sd->autospell3, ARRAYLENGTH(sd->autospell3), type2, (val&1?-type3:type3), (val&2?-type4:type4), type5, current_equip_card_id);
- break;
+ case SP_AUTOSPELL_ONSKILL:
+ if(sd->state.lr_flag != 2)
+ pc_bonus_autospell_onskill(sd->autospell3, ARRAYLENGTH(sd->autospell3), type2, (val&1?-type3:type3), (val&2?-type4:type4), type5, current_equip_card_id);
+ break;
- default:
- ShowWarning("pc_bonus5: unknown type %d %d %d %d %d %d!\n",type,type2,type3,type4,type5,val);
- break;
+ default:
+ ShowWarning("pc_bonus5: unknown type %d %d %d %d %d %d!\n",type,type2,type3,type4,type5,val);
+ break;
}
return 0;
@@ -3533,7 +3555,7 @@ int pc_insert_card(struct map_session_data* sd, int idx_card, int idx_equip)
// remember the card id to insert
nameid = sd->status.inventory[idx_card].nameid;
- if( pc_delitem(sd,idx_card,1,1,0,LOG_TYPE_OTHER) == 1 )
+ if( pc->delitem(sd,idx_card,1,1,0,LOG_TYPE_OTHER) == 1 )
{// failed
clif->insert_card(sd,idx_equip,idx_card,1);
}
@@ -3558,9 +3580,9 @@ int pc_insert_card(struct map_session_data* sd, int idx_card, int idx_equip)
int pc_modifybuyvalue(struct map_session_data *sd,int orig_value)
{
int skill,val = orig_value,rate1 = 0,rate2 = 0;
- if((skill=pc_checkskill(sd,MC_DISCOUNT))>0) // merchant discount
+ if((skill=pc->checkskill(sd,MC_DISCOUNT))>0) // merchant discount
rate1 = 5+skill*2-((skill==10)? 1:0);
- if((skill=pc_checkskill(sd,RG_COMPULSION))>0) // rogue discount
+ if((skill=pc->checkskill(sd,RG_COMPULSION))>0) // rogue discount
rate2 = 5+skill*4;
if(rate1 < rate2) rate1 = rate2;
if(rate1)
@@ -3577,7 +3599,7 @@ int pc_modifybuyvalue(struct map_session_data *sd,int orig_value)
int pc_modifysellvalue(struct map_session_data *sd,int orig_value)
{
int skill,val = orig_value,rate = 0;
- if((skill=pc_checkskill(sd,MC_OVERCHARGE))>0) //OverCharge
+ if((skill=pc->checkskill(sd,MC_OVERCHARGE))>0) //OverCharge
rate = 5+skill*2-((skill==10)? 1:0);
if(rate)
val = (int)((double)orig_value*(double)(100+rate)/100.);
@@ -3601,7 +3623,7 @@ int pc_checkadditem(struct map_session_data *sd,int nameid,int amount)
if(amount > MAX_AMOUNT)
return ADDITEM_OVERAMOUNT;
- data = itemdb_search(nameid);
+ data = itemdb->search(nameid);
if(!itemdb_isstackable2(data))
return ADDITEM_NEW;
@@ -3836,7 +3858,7 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l
if( amount > MAX_AMOUNT )
return 5;
- data = itemdb_search(item_data->nameid);
+ data = itemdb->search(item_data->nameid);
if( data->stack.inventory && amount > data->stack.amount )
{// item stack limitation
@@ -3866,7 +3888,7 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l
if( i >= MAX_INVENTORY )
{
- i = pc_search_inventory(sd,0);
+ i = pc->search_inventory(sd,0);
if( i < 0 )
return 4;
@@ -3889,17 +3911,17 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l
clif->updatestatus(sd,SP_WEIGHT);
//Auto-equip
if(data->flag.autoequip)
- pc_equipitem(sd, i, data->equip);
+ pc->equipitem(sd, i, data->equip);
/* rental item check */
if( item_data->expire_time ) {
if( time(NULL) > item_data->expire_time ) {
clif->rental_expired(sd->fd, i, sd->status.inventory[i].nameid);
- pc_delitem(sd, i, sd->status.inventory[i].amount, 1, 0, LOG_TYPE_OTHER);
+ pc->delitem(sd, i, sd->status.inventory[i].amount, 1, 0, LOG_TYPE_OTHER);
} else {
int seconds = (int)( item_data->expire_time - time(NULL) );
clif->rental_time(sd->fd, sd->status.inventory[i].nameid, seconds);
- pc_inventory_rental_add(sd, seconds);
+ pc->inventory_rental_add(sd, seconds);
}
}
@@ -3929,7 +3951,7 @@ int pc_delitem(struct map_session_data *sd,int n,int amount,int type, short reas
sd->weight -= sd->inventory_data[n]->weight*amount ;
if( sd->status.inventory[n].amount <= 0 ){
if(sd->status.inventory[n].equip)
- pc_unequipitem(sd,n,3);
+ pc->unequipitem(sd,n,3);
memset(&sd->status.inventory[n],0,sizeof(sd->status.inventory[0]));
sd->inventory_data[n] = NULL;
}
@@ -3961,7 +3983,7 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount)
sd->status.inventory[n].amount <= 0 ||
sd->status.inventory[n].amount < amount ||
sd->state.trading || sd->state.vending ||
- !sd->inventory_data[n] //pc_delitem would fail on this case.
+ !sd->inventory_data[n] //pc->delitem would fail on this case.
)
return 0;
@@ -3971,16 +3993,16 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount)
return 0; //Can't drop items in nodrop mapflag maps.
}
- if( !pc_candrop(sd,&sd->status.inventory[n]) )
+ if( !pc->candrop(sd,&sd->status.inventory[n]) )
{
clif->message (sd->fd, msg_txt(263));
return 0;
}
- if (!map_addflooritem(&sd->status.inventory[n], amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 2))
+ if (!iMap->addflooritem(&sd->status.inventory[n], amount, sd->bl.m, sd->bl.x, sd->bl.y, 0, 0, 0, 2))
return 0;
- pc_delitem(sd, n, amount, 1, 0, LOG_TYPE_PICKDROP_PLAYER);
+ pc->delitem(sd, n, amount, 1, 0, LOG_TYPE_PICKDROP_PLAYER);
clif->dropitem(sd, n, amount);
return 1;
}
@@ -3994,7 +4016,7 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount)
int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem)
{
int flag=0;
- unsigned int tick = gettick();
+ unsigned int tick = iTimer->gettick();
struct map_session_data *first_sd = NULL,*second_sd = NULL,*third_sd = NULL;
struct party_data *p=NULL;
@@ -4005,11 +4027,11 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem)
return 0; // Distance is too far
if (sd->status.party_id)
- p = party_search(sd->status.party_id);
+ p = party->search(sd->status.party_id);
if(fitem->first_get_charid > 0 && fitem->first_get_charid != sd->status.char_id)
{
- first_sd = map_charid2sd(fitem->first_get_charid);
+ first_sd = iMap->charid2sd(fitem->first_get_charid);
if(DIFF_TICK(tick,fitem->first_get_tick) < 0) {
if (!(p && p->party.item&1 &&
first_sd && first_sd->status.party_id == sd->status.party_id
@@ -4019,7 +4041,7 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem)
else
if(fitem->second_get_charid > 0 && fitem->second_get_charid != sd->status.char_id)
{
- second_sd = map_charid2sd(fitem->second_get_charid);
+ second_sd = iMap->charid2sd(fitem->second_get_charid);
if(DIFF_TICK(tick, fitem->second_get_tick) < 0) {
if(!(p && p->party.item&1 &&
((first_sd && first_sd->status.party_id == sd->status.party_id) ||
@@ -4030,7 +4052,7 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem)
else
if(fitem->third_get_charid > 0 && fitem->third_get_charid != sd->status.char_id)
{
- third_sd = map_charid2sd(fitem->third_get_charid);
+ third_sd = iMap->charid2sd(fitem->third_get_charid);
if(DIFF_TICK(tick,fitem->third_get_tick) < 0) {
if(!(p && p->party.item&1 &&
((first_sd && first_sd->status.party_id == sd->status.party_id) ||
@@ -4044,7 +4066,7 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem)
}
//This function takes care of giving the item to whoever should have it, considering party-share options.
- if ((flag = party_share_loot(p,sd,&fitem->item_data, fitem->first_get_charid))) {
+ if ((flag = party->share_loot(p,sd,&fitem->item_data, fitem->first_get_charid))) {
clif->additem(sd,0,0,flag);
return 1;
}
@@ -4052,7 +4074,7 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem)
//Display pickup animation.
pc_stop_attack(sd);
clif->takeitem(&sd->bl,&fitem->bl);
- map_clearflooritem(&fitem->bl);
+ iMap->clearflooritem(&fitem->bl);
return 1;
}
@@ -4080,7 +4102,7 @@ int pc_isUseitem(struct map_session_data *sd,int n)
if( !item->script ) //if it has no script, you can't really consume it!
return 0;
- if( (item->item_usage.flag&NOUSE_SITTING) && (pc_issit(sd) == 1) && (pc_get_group_level(sd) < item->item_usage.override) ) {
+ if( (item->item_usage.flag&NOUSE_SITTING) && (pc_issit(sd) == 1) && (pc->get_group_level(sd) < item->item_usage.override) ) {
clif->msgtable(sd->fd,664);
//clif->colormes(sd->fd,COLOR_WHITE,msg_txt(1474));
return 0; // You cannot use this item while sitting.
@@ -4099,7 +4121,7 @@ int pc_isUseitem(struct map_session_data *sd,int n)
case 12212: // Giant Fly Wing
if( map[sd->bl.m].flag.noteleport || map_flag_gvg(sd->bl.m) )
{
- clif->skill_teleportmessage(sd,0);
+ clif->skill_mapinfomessage(sd,0);
return 0;
}
case 602: // ButterFly Wing
@@ -4127,7 +4149,7 @@ int pc_isUseitem(struct map_session_data *sd,int n)
break;
case 12210: // Bubble Gum
case 12264: // Comp Bubble Gum
- if( sd->sc.data[SC_ITEMBOOST] )
+ if( sd->sc.data[SC_CASH_RECEIVEITEM] )
return 0;
break;
case 12208: // Battle Manual
@@ -4137,11 +4159,11 @@ int pc_isUseitem(struct map_session_data *sd,int n)
case 14532: // Battle_Manual25
case 14533: // Battle_Manual100
case 14545: // Battle_Manual300
- if( sd->sc.data[SC_EXPBOOST] )
+ if( sd->sc.data[SC_CASH_PLUSEXP] )
return 0;
break;
case 14592: // JOB_Battle_Manual
- if( sd->sc.data[SC_JEXPBOOST] )
+ if( sd->sc.data[SC_CASH_PLUSONLYJOBEXP] )
return 0;
break;
@@ -4154,7 +4176,7 @@ int pc_isUseitem(struct map_session_data *sd,int n)
case 12243: // Mercenary's Berserk Potion
if( sd->md == NULL || sd->md->db == NULL )
return 0;
- if (sd->md->sc.data[SC_BERSERK] || sd->md->sc.data[SC_SATURDAYNIGHTFEVER] || sd->md->sc.data[SC__BLOODYLUST])
+ if (sd->md->sc.data[SC_BERSERK] || sd->md->sc.data[SC_SATURDAY_NIGHT_FEVER] || sd->md->sc.data[SC__BLOODYLUST])
return 0;
if( nameid == 12242 && sd->md->db->lv < 40 )
return 0;
@@ -4223,15 +4245,14 @@ int pc_isUseitem(struct map_session_data *sd,int n)
* 0 = fail
* 1 = success
*------------------------------------------*/
-int pc_useitem(struct map_session_data *sd,int n)
-{
- unsigned int tick = gettick();
+int pc_useitem(struct map_session_data *sd,int n) {
+ unsigned int tick = iTimer->gettick();
int amount, nameid, i;
- struct script_code *script;
+ struct script_code *item_script;
nullpo_ret(sd);
- if( sd->npc_id ){
+ if( sd->npc_id || sd->state.workinprogress&1 ){
/* TODO: add to clif->messages enum */
#ifdef RENEWAL
clif->msg(sd, 0x783); // TODO look for the client date that has this message.
@@ -4245,7 +4266,7 @@ int pc_useitem(struct map_session_data *sd,int n)
if( !pc_isUseitem(sd,n) )
return 0;
- // Store information for later use before it is lost (via pc_delitem) [Paradox924X]
+ // Store information for later use before it is lost (via pc->delitem) [Paradox924X]
nameid = sd->inventory_data[n]->nameid;
if (nameid != ITEMID_NAUTHIZ && sd->sc.opt1 > 0 && sd->sc.opt1 != OPT1_STONEWAIT && sd->sc.opt1 != OPT1_BURNING)
@@ -4258,7 +4279,8 @@ int pc_useitem(struct map_session_data *sd,int n)
sd->sc.data[SC_HIDING] ||
sd->sc.data[SC__SHADOWFORM] ||
sd->sc.data[SC__MANHOLE] ||
- sd->sc.data[SC_KAGEHUMI] ||
+ sd->sc.data[SC_KG_KAGEHUMI] ||
+ sd->sc.data[SC_WHITEIMPRISON] ||
(sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOITEM)
))
return 0;
@@ -4270,8 +4292,8 @@ int pc_useitem(struct map_session_data *sd,int n)
return 0;
/* Items with delayed consume are not meant to work while in mounts except reins of mount(12622) */
- if( sd->inventory_data[n]->flag.delay_consume ) {
- if( nameid != ITEMID_REINS_OF_MOUNT && sd->sc.data[SC_ALL_RIDING] )
+ if( sd->inventory_data[n]->flag.delay_consume && nameid != ITEMID_REINS_OF_MOUNT ) {
+ if( sd->sc.data[SC_ALL_RIDING] )
return 0;
else if( pc_issit(sd) )
return 0;
@@ -4292,22 +4314,14 @@ int pc_useitem(struct map_session_data *sd,int n)
if( sd->item_delay[i].nameid ) {// found
if( DIFF_TICK(sd->item_delay[i].tick, tick) > 0 ) {
int e_tick = DIFF_TICK(sd->item_delay[i].tick, tick)/1000;
- char e_msg[100];
- if( e_tick > 99 )
- sprintf(e_msg,"Item Failed. [%s] is cooling down. wait %.1f minutes.",
- itemdb_jname(sd->status.inventory[n].nameid),
- (double)e_tick / 60);
- else
- sprintf(e_msg,"Item Failed. [%s] is cooling down. wait %d seconds.",
- itemdb_jname(sd->status.inventory[n].nameid),
- e_tick+1);
- clif->colormes(sd->fd,COLOR_RED,e_msg);
+ clif->msgtable_num(sd->fd, 0x746, e_tick + 1); // [%d] seconds left until you can use
return 0; // Delay has not expired yet
}
} else {// not yet used item (all slots are initially empty)
sd->item_delay[i].nameid = nameid;
}
- sd->item_delay[i].tick = tick + sd->inventory_data[n]->delay;
+ if( !(nameid == ITEMID_REINS_OF_MOUNT && sd->sc.option&(OPTION_WUGRIDER|OPTION_RIDING|OPTION_DRAGON|OPTION_MADOGEAR)) )
+ sd->item_delay[i].tick = tick + sd->inventory_data[n]->delay;
} else {// should not happen
ShowError("pc_useitem: Exceeded item delay array capacity! (nameid=%d, char_id=%d)\n", nameid, sd->status.char_id);
}
@@ -4325,7 +4339,7 @@ int pc_useitem(struct map_session_data *sd,int n)
if( map[sd->bl.m].zone->disabled_items[i] == nameid ) {
if( battle_config.item_restricted_consumption_type ) {
clif->useitemack(sd,n,sd->status.inventory[n].amount-1,true);
- pc_delitem(sd,n,1,1,0,LOG_TYPE_CONSUME);
+ pc->delitem(sd,n,1,1,0,LOG_TYPE_CONSUME);
}
return 0;
}
@@ -4337,22 +4351,22 @@ int pc_useitem(struct map_session_data *sd,int n)
sd->catch_target_class = -1;
amount = sd->status.inventory[n].amount;
- script = sd->inventory_data[n]->script;
+ item_script = sd->inventory_data[n]->script;
//Check if the item is to be consumed immediately [Skotlex]
if( sd->inventory_data[n]->flag.delay_consume )
clif->useitemack(sd,n,amount,true);
else {
if( sd->status.inventory[n].expire_time == 0 ) {
clif->useitemack(sd,n,amount-1,true);
- pc_delitem(sd,n,1,1,0,LOG_TYPE_CONSUME); // Rental Usable Items are not deleted until expiration
+ pc->delitem(sd,n,1,1,0,LOG_TYPE_CONSUME); // Rental Usable Items are not deleted until expiration
} else
clif->useitemack(sd,n,0,false);
}
if(sd->status.inventory[n].card[0]==CARD0_CREATE &&
- pc_famerank(MakeDWord(sd->status.inventory[n].card[2],sd->status.inventory[n].card[3]), MAPID_ALCHEMIST))
+ pc->famerank(MakeDWord(sd->status.inventory[n].card[2],sd->status.inventory[n].card[3]), MAPID_ALCHEMIST))
{
potion_flag = 2; // Famous player's potions have 50% more efficiency
- if (sd->sc.data[SC_SPIRIT] && sd->sc.data[SC_SPIRIT]->val2 == SL_ROGUE)
+ if (sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_ROGUE)
potion_flag = 3; //Even more effective potions.
}
@@ -4360,9 +4374,14 @@ int pc_useitem(struct map_session_data *sd,int n)
sd->canuseitem_tick = tick + battle_config.item_use_interval;
if( itemdb_iscashfood(nameid) )
sd->canusecashfood_tick = tick + battle_config.cashfood_use_interval;
-
- run_script(script,0,sd->bl.id,fake_nd->bl.id);
+
+ script->current_item_id = nameid;
+
+ run_script(item_script,0,sd->bl.id,fake_nd->bl.id);
+
+ script->current_item_id = 0;
potion_flag = 0;
+
return 1;
}
@@ -4382,14 +4401,14 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun
if(item_data->nameid <= 0 || amount <= 0)
return 1;
- data = itemdb_search(item_data->nameid);
+ data = itemdb->search(item_data->nameid);
if( data->stack.cart && amount > data->stack.amount )
{// item stack limitation
return 1;
}
- if( !itemdb_cancartstore(item_data, pc_get_group_level(sd)) )
+ if( !itemdb_cancartstore(item_data, pc->get_group_level(sd)) )
{ // Check item trade restrictions [Skotlex]
clif->message (sd->fd, msg_txt(264));
return 1;
@@ -4445,7 +4464,7 @@ int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,e_log_
struct item_data * data;
nullpo_retr(1, sd);
- if( sd->status.cart[n].nameid == 0 || sd->status.cart[n].amount < amount || !(data = itemdb_exists(sd->status.cart[n].nameid)) )
+ if( sd->status.cart[n].nameid == 0 || sd->status.cart[n].amount < amount || !(data = itemdb->exists(sd->status.cart[n].nameid)) )
return 1;
logs->pick_pc(sd, log_type, -amount, &sd->status.cart[n],data);
@@ -4484,8 +4503,8 @@ int pc_putitemtocart(struct map_session_data *sd,int idx,int amount)
if( item_data->nameid == 0 || amount < 1 || item_data->amount < amount || sd->state.vending )
return 1;
- if( pc_cart_additem(sd,item_data,amount,LOG_TYPE_NONE) == 0 )
- return pc_delitem(sd,idx,amount,0,5,LOG_TYPE_NONE);
+ if( pc->cart_additem(sd,item_data,amount,LOG_TYPE_NONE) == 0 )
+ return pc->delitem(sd,idx,amount,0,5,LOG_TYPE_NONE);
return 1;
}
@@ -4512,7 +4531,7 @@ int pc_cartitem_amount(struct map_session_data* sd, int idx, int amount)
/*==========================================
* Retrieve an item at index idx from cart.
* Return:
- * 0 = player not found or (FIXME) succes (from pc_cart_delitem)
+ * 0 = player not found or (FIXME) succes (from pc->cart_delitem)
* 1 = failure
*------------------------------------------*/
int pc_getitemfromcart(struct map_session_data *sd,int idx,int amount)
@@ -4529,8 +4548,8 @@ int pc_getitemfromcart(struct map_session_data *sd,int idx,int amount)
if(item_data->nameid==0 || amount < 1 || item_data->amount<amount || sd->state.vending )
return 1;
- if((flag = pc_additem(sd,item_data,amount,LOG_TYPE_NONE)) == 0)
- return pc_cart_delitem(sd,idx,amount,0,LOG_TYPE_NONE);
+ if((flag = pc->additem(sd,item_data,amount,LOG_TYPE_NONE)) == 0)
+ return pc->cart_delitem(sd,idx,amount,0,LOG_TYPE_NONE);
clif->additem(sd,0,0,flag);
return 1;
@@ -4550,7 +4569,7 @@ int pc_show_steal(struct block_list *bl,va_list ap)
sd=va_arg(ap,struct map_session_data *);
itemid=va_arg(ap,int);
- if((item=itemdb_exists(itemid))==NULL)
+ if((item=itemdb->exists(itemid))==NULL)
sprintf(output,"%s stole an Unknown Item (id: %i).",sd->status.name, itemid);
else
sprintf(output,"%s stole %s.",sd->status.name,item->jname);
@@ -4603,7 +4622,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil
// Try dropping one item, in the order from first to last possible slot.
// Droprate is affected by the skill success rate.
for( i = 0; i < MAX_STEAL_DROP; i++ )
- if( md->db->dropitem[i].nameid > 0 && (data = itemdb_exists(md->db->dropitem[i].nameid)) && rnd() % 10000 < md->db->dropitem[i].p * rate/100. )
+ if( md->db->dropitem[i].nameid > 0 && (data = itemdb->exists(md->db->dropitem[i].nameid)) && rnd() % 10000 < md->db->dropitem[i].p * rate/100. )
break;
if( i == MAX_STEAL_DROP )
return 0;
@@ -4613,7 +4632,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil
tmp_item.nameid = itemid;
tmp_item.amount = 1;
tmp_item.identify = itemdb_isidentified2(data);
- flag = pc_additem(sd,&tmp_item,1,LOG_TYPE_PICKDROP_PLAYER);
+ flag = pc->additem(sd,&tmp_item,1,LOG_TYPE_PICKDROP_PLAYER);
//TODO: Should we disable stealing when the item you stole couldn't be added to your inventory? Perhaps players will figure out a way to exploit this behaviour otherwise?
md->state.steal_flag = UCHAR_MAX; //you can't steal from this mob any more
@@ -4660,13 +4679,13 @@ int pc_steal_coin(struct map_session_data *sd,struct block_list *target)
return 0;
// FIXME: This formula is either custom or outdated.
- skill = pc_checkskill(sd,RG_STEALCOIN)*10;
+ skill = pc->checkskill(sd,RG_STEALCOIN)*10;
rate = skill + (sd->status.base_level - md->level)*3 + sd->battle_status.dex*2 + sd->battle_status.luk*2;
if(rnd()%1000 < rate)
{
int amount = md->level*10 + rnd()%100;
- pc_getzeny(sd, amount, LOG_TYPE_STEAL, NULL);
+ pc->getzeny(sd, amount, LOG_TYPE_STEAL, NULL);
md->state.steal_coin_flag = 1;
return 1;
}
@@ -4680,36 +4699,67 @@ int pc_steal_coin(struct map_session_data *sd,struct block_list *target)
* 1 - Invalid map index.
* 2 - Map not in this map-server, and failed to locate alternate map-server.
*------------------------------------------*/
-int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y, clr_type clrtype)
-{
- struct party_data *p;
+int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y, clr_type clrtype) {
int16 m;
nullpo_ret(sd);
- if( !mapindex || !mapindex_id2name(mapindex) )
- {
+ if( !mapindex || !mapindex_id2name(mapindex) || ( m = iMap->mapindex2mapid(mapindex) ) == -1 ) {
ShowDebug("pc_setpos: Passed mapindex(%d) is invalid!\n", mapindex);
return 1;
}
- if( pc_isdead(sd) )
- { //Revive dead people before warping them
- pc_setstand(sd);
- pc_setrestartvalue(sd,1);
+ if( pc_isdead(sd) ) { //Revive dead people before warping them
+ pc->setstand(sd);
+ pc->setrestartvalue(sd,1);
}
- m = map_mapindex2mapid(mapindex);
- if( map[m].flag.src4instance && sd->status.party_id && (p = party_search(sd->status.party_id)) != NULL && p->instance_id )
- {
- // Request the mapid of this src map into the instance of the party
- int im = instance_map2imap(m, p->instance_id);
- if( im < 0 )
- ; // Player will enter the src map for instances
- else
- { // Changes destiny to the instance map, not the source map
- m = im;
- mapindex = map_id2index(m);
+ if( map[m].flag.src4instance ) {
+ struct party_data *p;
+ bool stop = false;
+ int i = 0, j = 0;
+
+ if( sd->instances ) {
+ for( i = 0; i < sd->instances; i++ ) {
+ if( sd->instance[i] >= 0 ) {
+ ARR_FIND(0, instances[sd->instance[i]].num_map, j, map[instances[sd->instance[i]].map[j]].instance_src_map == m && !map[instances[sd->instance[i]].map[j]].cName);
+ if( j != instances[sd->instance[i]].num_map )
+ break;
+ }
+ }
+ if( i != sd->instances ) {
+ m = instances[sd->instance[i]].map[j];
+ mapindex = map[m].index;
+ stop = true;
+ }
+ }
+ if ( !stop && sd->status.party_id && (p = party->search(sd->status.party_id)) && p->instances ) {
+ for( i = 0; i < p->instances; i++ ) {
+ if( p->instance[i] >= 0 ) {
+ ARR_FIND(0, instances[p->instance[i]].num_map, j, map[instances[p->instance[i]].map[j]].instance_src_map == m && !map[instances[p->instance[i]].map[j]].cName);
+ if( j != instances[p->instance[i]].num_map )
+ break;
+ }
+ }
+ if( i != p->instances ) {
+ m = instances[p->instance[i]].map[j];
+ mapindex = map[m].index;
+ stop = true;
+ }
+ }
+ if ( !stop && sd->status.guild_id && sd->guild && sd->guild->instances ) {
+ for( i = 0; i < sd->guild->instances; i++ ) {
+ if( sd->guild->instance[i] >= 0 ) {
+ ARR_FIND(0, instances[sd->guild->instance[i]].num_map, j, map[instances[sd->guild->instance[i]].map[j]].instance_src_map == m && !map[instances[sd->guild->instance[i]].map[j]].cName);
+ if( j != instances[sd->guild->instance[i]].num_map )
+ break;
+ }
+ }
+ if( i != sd->guild->instances ) {
+ m = instances[sd->guild->instance[i]].map[j];
+ mapindex = map[m].index;
+ stop = true;
+ }
}
}
@@ -4718,10 +4768,21 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y
if( sd->state.changemap ) { // Misc map-changing settings
int i;
sd->state.pmap = sd->bl.m;
+
+ for( i = 0; i < sd->queues_count; i++ ) {
+ struct hQueue *queue;
+ if( (queue = script->queue(sd->queues[i])) && queue->onMapChange[0] != '\0' ) {
+ pc->setregstr(sd, add_str("QMapChangeTo"), map[m].name);
+ npc_event(sd, queue->onMapChange, 0);
+ }
+ }
+
+ if( map[m].cell == (struct mapcell *)0xdeadbeaf )
+ iMap->cellfromcache(&map[m]);
if (sd->sc.count) { // Cancel some map related stuff.
if (sd->sc.data[SC_JAILED])
return 1; //You may not get out!
- status_change_end(&sd->bl, SC_BOSSMAPINFO, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_CASH_BOSS_ALARM, INVALID_TIMER);
status_change_end(&sd->bl, SC_WARM, INVALID_TIMER);
status_change_end(&sd->bl, SC_SUN_COMFORT, INVALID_TIMER);
status_change_end(&sd->bl, SC_MOON_COMFORT, INVALID_TIMER);
@@ -4730,8 +4791,8 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y
if (sd->sc.data[SC_KNOWLEDGE]) {
struct status_change_entry *sce = sd->sc.data[SC_KNOWLEDGE];
if (sce->timer != INVALID_TIMER)
- delete_timer(sce->timer, status_change_timer);
- sce->timer = add_timer(gettick() + skill->get_time(SG_KNOWLEDGE, sce->val1), status_change_timer, sd->bl.id, SC_KNOWLEDGE);
+ iTimer->delete_timer(sce->timer, status_change_timer);
+ sce->timer = iTimer->add_timer(iTimer->gettick() + skill->get_time(SG_KNOWLEDGE, sce->val1), status_change_timer, sd->bl.id, SC_KNOWLEDGE);
}
status_change_end(&sd->bl, SC_PROPERTYWALK, INVALID_TIMER);
status_change_end(&sd->bl, SC_CLOAKING, INVALID_TIMER);
@@ -4739,12 +4800,12 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y
}
for( i = 0; i < EQI_MAX; i++ ) {
if( sd->equip_index[ i ] >= 0 )
- if( !pc_isequip( sd , sd->equip_index[ i ] ) )
- pc_unequipitem( sd , sd->equip_index[ i ] , 2 );
+ if( !pc->isequip( sd , sd->equip_index[ i ] ) )
+ pc->unequipitem( sd , sd->equip_index[ i ] , 2 );
}
if (battle_config.clear_unit_onwarp&BL_PC)
skill->clear_unitgroup(&sd->bl);
- party_send_dot_remove(sd); //minimap dot fix [Kevin]
+ party->send_dot_remove(sd); //minimap dot fix [Kevin]
guild->send_dot_remove(sd);
bg_send_dot_remove(sd);
if (sd->regen.state.gc)
@@ -4761,12 +4822,11 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y
}
- if( m < 0 )
- {
+ if( m < 0 ) {
uint32 ip;
uint16 port;
//if can't find any map-servers, just abort setting position.
- if(!sd->mapindex || map_mapname2ipport(mapindex,&ip,&port))
+ if(!sd->mapindex || iMap->mapname2ipport(mapindex,&ip,&port))
return 2;
if (sd->npc_id)
@@ -4777,7 +4837,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y
sd->mapindex = mapindex;
sd->bl.x=x;
sd->bl.y=y;
- pc_clean_skilltree(sd);
+ pc->clean_skilltree(sd);
chrif_save(sd,2);
chrif_changemapserver(sd, ip, (short)port);
@@ -4787,28 +4847,26 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y
return 0;
}
- if( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys )
- {
+ if( x < 0 || x >= map[m].xs || y < 0 || y >= map[m].ys ) {
ShowError("pc_setpos: attempt to place player %s (%d:%d) on invalid coordinates (%s-%d,%d)\n", sd->status.name, sd->status.account_id, sd->status.char_id, mapindex_id2name(mapindex),x,y);
x = y = 0; // make it random
}
- if( x == 0 && y == 0 )
- {// pick a random walkable cell
+ if( x == 0 && y == 0 ) {// pick a random walkable cell
do {
x=rnd()%(map[m].xs-2)+1;
y=rnd()%(map[m].ys-2)+1;
- } while(map_getcell(m,x,y,CELL_CHKNOPASS));
+ } while(iMap->getcell(m,x,y,CELL_CHKNOPASS));
}
- if (sd->state.vending && map_getcell(m,x,y,CELL_CHKNOVENDING)) {
+ if (sd->state.vending && iMap->getcell(m,x,y,CELL_CHKNOVENDING)) {
clif->message (sd->fd, msg_txt(204)); // "You can't open a shop on this cell."
vending->close(sd);
}
if(sd->bl.prev != NULL){
unit_remove_map_pc(sd,clrtype);
- clif->changemap(sd,map[m].index,x,y); // [MouseJstr]
+ clif->changemap(sd,m,x,y); // [MouseJstr]
} else if(sd->state.active)
//Tag player for rewarping after map-loading is done. [Skotlex]
sd->state.rewarp = 1;
@@ -4818,31 +4876,27 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y
sd->bl.x = sd->ud.to_x = x;
sd->bl.y = sd->ud.to_y = y;
- if( sd->status.guild_id > 0 && map[m].flag.gvg_castle )
- { // Increased guild castle regen [Valaris]
+ if( sd->status.guild_id > 0 && map[m].flag.gvg_castle ) { // Increased guild castle regen [Valaris]
struct guild_castle *gc = guild->mapindex2gc(sd->mapindex);
if(gc && gc->guild_id == sd->status.guild_id)
sd->regen.state.gc = 1;
}
- if( sd->status.pet_id > 0 && sd->pd && sd->pd->pet.intimate > 0 )
- {
+ if( sd->status.pet_id > 0 && sd->pd && sd->pd->pet.intimate > 0 ) {
sd->pd->bl.m = m;
sd->pd->bl.x = sd->pd->ud.to_x = x;
sd->pd->bl.y = sd->pd->ud.to_y = y;
sd->pd->ud.dir = sd->ud.dir;
}
- if( homun_alive(sd->hd) )
- {
+ if( homun_alive(sd->hd) ) {
sd->hd->bl.m = m;
sd->hd->bl.x = sd->hd->ud.to_x = x;
sd->hd->bl.y = sd->hd->ud.to_y = y;
sd->hd->ud.dir = sd->ud.dir;
}
- if( sd->md )
- {
+ if( sd->md ) {
sd->md->bl.m = m;
sd->md->bl.x = sd->md->ud.to_x = x;
sd->md->bl.y = sd->md->ud.to_y = y;
@@ -4856,7 +4910,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y
* Warp player sd to random location on current map.
* May fail if no walkable cell found (1000 attempts).
* Return:
- * 0 = fail or FIXME success (from pc_setpos)
+ * 0 = fail or FIXME success (from pc->setpos)
* x(1|2) = fail
*------------------------------------------*/
int pc_randomwarp(struct map_session_data *sd, clr_type type)
@@ -4874,10 +4928,10 @@ int pc_randomwarp(struct map_session_data *sd, clr_type type)
do{
x=rnd()%(map[m].xs-2)+1;
y=rnd()%(map[m].ys-2)+1;
- }while(map_getcell(m,x,y,CELL_CHKNOPASS) && (i++)<1000 );
+ }while(iMap->getcell(m,x,y,CELL_CHKNOPASS) && (i++)<1000 );
if (i < 1000)
- return pc_setpos(sd,map[sd->bl.m].index,x,y,type);
+ return pc->setpos(sd,map[sd->bl.m].index,x,y,type);
return 0;
}
@@ -4894,7 +4948,7 @@ int pc_memo(struct map_session_data* sd, int pos)
// check mapflags
if( sd->bl.m >= 0 && (map[sd->bl.m].flag.nomemo || map[sd->bl.m].flag.nowarpto) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
- clif->skill_teleportmessage(sd, 1); // "Saved point cannot be memorized."
+ clif->skill_mapinfomessage(sd, 1); // "Saved point cannot be memorized."
return 0;
}
@@ -4903,7 +4957,7 @@ int pc_memo(struct map_session_data* sd, int pos)
return 0; // invalid input
// check required skill level
- skill = pc_checkskill(sd, AL_WARP);
+ skill = pc->checkskill(sd, AL_WARP);
if( skill < 1 ) {
clif->skill_memomessage(sd,2); // "You haven't learned Warp."
return 0;
@@ -4985,21 +5039,24 @@ int pc_checkallowskill(struct map_session_data *sd)
{
const enum sc_type scw_list[] = {
SC_TWOHANDQUICKEN,
- SC_ONEHAND,
+ SC_ONEHANDQUICKEN,
SC_AURABLADE,
SC_PARRYING,
SC_SPEARQUICKEN,
SC_ADRENALINE,
SC_ADRENALINE2,
SC_DANCING,
- SC_GATLINGFEVER,
+ SC_GS_GATLINGFEVER,
+#ifdef RENEWAL
+ SC_EDP,
+#endif
SC_FEARBREEZE
};
const enum sc_type scs_list[] = {
SC_AUTOGUARD,
SC_DEFENDER,
SC_REFLECTSHIELD,
- SC_REFLECTDAMAGE
+ SC_LG_REFLECTDAMAGE
};
int i;
nullpo_ret(sd);
@@ -5016,9 +5073,9 @@ int pc_checkallowskill(struct map_session_data *sd)
status_change_end(&sd->bl, scw_list[i], INVALID_TIMER);
}
- if(sd->sc.data[SC_SPURT] && sd->status.weapon)
+ if(sd->sc.data[SC_STRUP] && sd->status.weapon)
// Spurt requires bare hands (feet, in fact xD)
- status_change_end(&sd->bl, SC_SPURT, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_STRUP, INVALID_TIMER);
if(sd->status.shield <= 0) { // Skills requiring a shield
for (i = 0; i < ARRAYLENGTH(scs_list); i++)
@@ -5549,7 +5606,7 @@ int pc_follow_timer(int tid, unsigned int tick, int id, intptr_t data)
struct map_session_data *sd;
struct block_list *tbl;
- sd = map_id2sd(id);
+ sd = iMap->id2sd(id);
nullpo_ret(sd);
if (sd->followtimer != tid){
@@ -5559,11 +5616,11 @@ int pc_follow_timer(int tid, unsigned int tick, int id, intptr_t data)
}
sd->followtimer = INVALID_TIMER;
- tbl = map_id2bl(sd->followtarget);
+ tbl = iMap->id2bl(sd->followtarget);
if (tbl == NULL || pc_isdead(sd) || status_isdead(tbl))
{
- pc_stop_following(sd);
+ pc->stop_following(sd);
return 0;
}
@@ -5576,9 +5633,9 @@ int pc_follow_timer(int tid, unsigned int tick, int id, intptr_t data)
if (!check_distance_bl(&sd->bl, tbl, 5))
unit_walktobl(&sd->bl, tbl, 5, 0);
} else
- pc_setpos(sd, map_id2index(tbl->m), tbl->x, tbl->y, CLR_TELEPORT);
+ pc->setpos(sd, map_id2index(tbl->m), tbl->x, tbl->y, CLR_TELEPORT);
}
- sd->followtimer = add_timer(
+ sd->followtimer = iTimer->add_timer(
tick + 1000, // increase time a bit to loosen up map's load
pc_follow_timer, sd->bl.id, 0);
return 0;
@@ -5589,7 +5646,7 @@ int pc_stop_following (struct map_session_data *sd)
nullpo_ret(sd);
if (sd->followtimer != INVALID_TIMER) {
- delete_timer(sd->followtimer,pc_follow_timer);
+ iTimer->delete_timer(sd->followtimer,pc_follow_timer);
sd->followtimer = INVALID_TIMER;
}
sd->followtarget = -1;
@@ -5602,20 +5659,20 @@ int pc_stop_following (struct map_session_data *sd)
int pc_follow(struct map_session_data *sd,int target_id)
{
- struct block_list *bl = map_id2bl(target_id);
+ struct block_list *bl = iMap->id2bl(target_id);
if (bl == NULL /*|| bl->type != BL_PC*/)
return 1;
if (sd->followtimer != INVALID_TIMER)
- pc_stop_following(sd);
+ pc->stop_following(sd);
sd->followtarget = target_id;
- pc_follow_timer(INVALID_TIMER, gettick(), sd->bl.id, 0);
+ pc_follow_timer(INVALID_TIMER, iTimer->gettick(), sd->bl.id, 0);
return 0;
}
int pc_checkbaselevelup(struct map_session_data *sd) {
- unsigned int next = pc_nextbaseexp(sd);
+ unsigned int next = pc->nextbaseexp(sd);
if (!next || sd->status.base_exp < next)
return 0;
@@ -5626,11 +5683,11 @@ int pc_checkbaselevelup(struct map_session_data *sd) {
if(!battle_config.multi_level_up && sd->status.base_exp > next-1)
sd->status.base_exp = next-1;
- next = pc_gets_status_point(sd->status.base_level);
+ next = pc->gets_status_point(sd->status.base_level);
sd->status.base_level ++;
sd->status.status_point += next;
- } while ((next=pc_nextbaseexp(sd)) > 0 && sd->status.base_exp >= next);
+ } while ((next=pc->nextbaseexp(sd)) > 0 && sd->status.base_exp >= next);
if (battle_config.pet_lv_rate && sd->pd) //<Skotlex> update pet's level
status_calc_pet(sd->pd,0);
@@ -5658,9 +5715,9 @@ int pc_checkbaselevelup(struct map_session_data *sd) {
npc_script_event(sd, NPCE_BASELVUP); //LORDALFA - LVLUPEVENT
if(sd->status.party_id)
- party_send_levelup(sd);
+ party->send_levelup(sd);
- pc_baselevelchanged(sd);
+ pc->baselevelchanged(sd);
return 1;
}
@@ -5670,7 +5727,7 @@ void pc_baselevelchanged(struct map_session_data *sd) {
for( i = 0; i < EQI_MAX; i++ ) {
if( sd->equip_index[i] >= 0 ) {
if( sd->inventory_data[ sd->equip_index[i] ]->elvmax && sd->status.base_level > (unsigned int)sd->inventory_data[ sd->equip_index[i] ]->elvmax )
- pc_unequipitem(sd, sd->equip_index[i], 3);
+ pc->unequipitem(sd, sd->equip_index[i], 3);
}
}
#endif
@@ -5678,7 +5735,7 @@ void pc_baselevelchanged(struct map_session_data *sd) {
}
int pc_checkjoblevelup(struct map_session_data *sd)
{
- unsigned int next = pc_nextjobexp(sd);
+ unsigned int next = pc->nextjobexp(sd);
nullpo_ret(sd);
if(!next || sd->status.job_exp < next)
@@ -5693,7 +5750,7 @@ int pc_checkjoblevelup(struct map_session_data *sd)
sd->status.job_level ++;
sd->status.skill_point ++;
- } while ((next=pc_nextjobexp(sd)) > 0 && sd->status.job_exp >= next);
+ } while ((next=pc->nextjobexp(sd)) > 0 && sd->status.job_exp >= next);
clif->updatestatus(sd,SP_JOBLEVEL);
clif->updatestatus(sd,SP_JOBEXP);
@@ -5701,8 +5758,8 @@ int pc_checkjoblevelup(struct map_session_data *sd)
clif->updatestatus(sd,SP_SKILLPOINT);
status_calc_pc(sd,0);
clif->misceffect(&sd->bl,1);
- if (pc_checkskill(sd, SG_DEVIL) && !pc_nextjobexp(sd))
- clif->status_change(&sd->bl,SI_DEVIL, 1, 0, 0, 0, 1); //Permanent blind effect from SG_DEVIL.
+ if (pc->checkskill(sd, SG_DEVIL) && !pc->nextjobexp(sd))
+ clif->status_change(&sd->bl,SI_DEVIL1, 1, 0, 0, 0, 1); //Permanent blind effect from SG_DEVIL.
npc_script_event(sd, NPCE_JOBLVUP);
return 1;
@@ -5724,13 +5781,13 @@ static void pc_calcexp(struct map_session_data *sd, unsigned int *base_exp, unsi
(int)(status_get_lv(src) - sd->status.base_level) >= 20)
bonus += 15; // pk_mode additional exp if monster >20 levels [Valaris]
- if (sd->sc.data[SC_EXPBOOST])
- bonus += sd->sc.data[SC_EXPBOOST]->val1;
+ if (sd->sc.data[SC_CASH_PLUSEXP])
+ bonus += sd->sc.data[SC_CASH_PLUSEXP]->val1;
*base_exp = (unsigned int) cap_value(*base_exp + (double)*base_exp * bonus/100., 1, UINT_MAX);
- if (sd->sc.data[SC_JEXPBOOST])
- bonus += sd->sc.data[SC_JEXPBOOST]->val1;
+ if (sd->sc.data[SC_CASH_PLUSONLYJOBEXP])
+ bonus += sd->sc.data[SC_CASH_PLUSONLYJOBEXP]->val1;
*job_exp = (unsigned int) cap_value(*job_exp + (double)*job_exp * bonus/100., 1, UINT_MAX);
@@ -5756,8 +5813,8 @@ int pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned int
if(src) pc_calcexp(sd, &base_exp, &job_exp, src);
- nextb = pc_nextbaseexp(sd);
- nextj = pc_nextjobexp(sd);
+ nextb = pc->nextbaseexp(sd);
+ nextj = pc->nextjobexp(sd);
if(sd->state.showexp || battle_config.max_exp_gain_rate){
if (nextb > 0)
@@ -5783,22 +5840,22 @@ int pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned int
//Cap exp to the level up requirement of the previous level when you are at max level, otherwise cap at UINT_MAX (this is required for some S. Novice bonuses). [Skotlex]
if (base_exp) {
- nextb = nextb?UINT_MAX:pc_thisbaseexp(sd);
+ nextb = nextb?UINT_MAX:pc->thisbaseexp(sd);
if(sd->status.base_exp > nextb - base_exp)
sd->status.base_exp = nextb;
else
sd->status.base_exp += base_exp;
- pc_checkbaselevelup(sd);
+ pc->checkbaselevelup(sd);
clif->updatestatus(sd,SP_BASEEXP);
}
if (job_exp) {
- nextj = nextj?UINT_MAX:pc_thisjobexp(sd);
+ nextj = nextj?UINT_MAX:pc->thisjobexp(sd);
if(sd->status.job_exp > nextj - job_exp)
sd->status.job_exp = nextj;
else
sd->status.job_exp += job_exp;
- pc_checkjoblevelup(sd);
+ pc->checkjoblevelup(sd);
clif->updatestatus(sd,SP_JOBEXP);
}
@@ -5821,12 +5878,12 @@ int pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned int
*------------------------------------------*/
unsigned int pc_maxbaselv(struct map_session_data *sd)
{
- return max_level[pc_class2idx(sd->status.class_)][0];
+ return max_level[pc->class2idx(sd->status.class_)][0];
}
unsigned int pc_maxjoblv(struct map_session_data *sd)
{
- return max_level[pc_class2idx(sd->status.class_)][1];
+ return max_level[pc->class2idx(sd->status.class_)][1];
}
/*==========================================
@@ -5838,19 +5895,19 @@ unsigned int pc_nextbaseexp(struct map_session_data *sd)
{
nullpo_ret(sd);
- if(sd->status.base_level>=pc_maxbaselv(sd) || sd->status.base_level<=0)
+ if(sd->status.base_level>=pc->maxbaselv(sd) || sd->status.base_level<=0)
return 0;
- return exp_table[pc_class2idx(sd->status.class_)][0][sd->status.base_level-1];
+ return exp_table[pc->class2idx(sd->status.class_)][0][sd->status.base_level-1];
}
//Base exp needed for this level.
unsigned int pc_thisbaseexp(struct map_session_data *sd)
{
- if(sd->status.base_level>pc_maxbaselv(sd) || sd->status.base_level<=1)
+ if(sd->status.base_level>pc->maxbaselv(sd) || sd->status.base_level<=1)
return 0;
- return exp_table[pc_class2idx(sd->status.class_)][0][sd->status.base_level-2];
+ return exp_table[pc->class2idx(sd->status.class_)][0][sd->status.base_level-2];
}
@@ -5866,17 +5923,17 @@ unsigned int pc_nextjobexp(struct map_session_data *sd)
{
nullpo_ret(sd);
- if(sd->status.job_level>=pc_maxjoblv(sd) || sd->status.job_level<=0)
+ if(sd->status.job_level>=pc->maxjoblv(sd) || sd->status.job_level<=0)
return 0;
- return exp_table[pc_class2idx(sd->status.class_)][1][sd->status.job_level-1];
+ return exp_table[pc->class2idx(sd->status.class_)][1][sd->status.job_level-1];
}
//Job exp needed for this level.
unsigned int pc_thisjobexp(struct map_session_data *sd)
{
- if(sd->status.job_level>pc_maxjoblv(sd) || sd->status.job_level<=1)
+ if(sd->status.job_level>pc->maxjoblv(sd) || sd->status.job_level<=1)
return 0;
- return exp_table[pc_class2idx(sd->status.class_)][1][sd->status.job_level-2];
+ return exp_table[pc->class2idx(sd->status.class_)][1][sd->status.job_level-2];
}
/// Returns the value of the specified stat.
@@ -5967,7 +6024,7 @@ int pc_statusup(struct map_session_data* sd, int type)
nullpo_ret(sd);
// check conditions
- need = pc_need_status_point(sd,type,1);
+ need = pc->need_status_point(sd,type,1);
if( type < SP_STR || type > SP_LUK || need < 0 || need > sd->status.status_point )
{
clif->statusupack(sd,type,0,0);
@@ -5989,7 +6046,7 @@ int pc_statusup(struct map_session_data* sd, int type)
status_calc_pc(sd,0);
// update increase cost indicator
- if( need != pc_need_status_point(sd,type,1) )
+ if( need != pc->need_status_point(sd,type,1) )
clif->updatestatus(sd, SP_USTR + type-SP_STR);
// update statpoint count
@@ -6020,7 +6077,7 @@ int pc_statusup2(struct map_session_data* sd, int type, int val)
return 1;
}
- need = pc_need_status_point(sd,type,1);
+ need = pc->need_status_point(sd,type,1);
// set new value
max = pc_maxparameter(sd);
@@ -6029,7 +6086,7 @@ int pc_statusup2(struct map_session_data* sd, int type, int val)
status_calc_pc(sd,0);
// update increase cost indicator
- if( need != pc_need_status_point(sd,type,1) )
+ if( need != pc->need_status_point(sd,type,1) )
clif->updatestatus(sd, SP_USTR + type-SP_STR);
// update stat value
@@ -6070,8 +6127,8 @@ int pc_skillup(struct map_session_data *sd,uint16 skill_id) {
sd->status.skill_point--;
if( !skill_db[index].inf )
status_calc_pc(sd,0); // Only recalculate for passive skills.
- else if( sd->status.skill_point == 0 && (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc_famerank(sd->status.char_id, MAPID_TAEKWON) )
- pc_calc_skilltree(sd); // Required to grant all TK Ranger skills.
+ else if( sd->status.skill_point == 0 && (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) )
+ pc->calc_skilltree(sd); // Required to grant all TK Ranger skills.
else
pc_check_skilltree(sd, skill_id); // Check if a new skill can Lvlup
@@ -6081,6 +6138,19 @@ int pc_skillup(struct map_session_data *sd,uint16 skill_id) {
clif->updatestatus(sd,SP_CARTINFO);
if (!pc_has_permission(sd, PC_PERM_ALL_SKILL)) // may skill everything at any time anyways, and this would cause a huge slowdown
clif->skillinfoblock(sd);
+ }else if( battle_config.skillup_limit ){
+ int pts = 0, i, id;
+ for(i = 0; i < MAX_SKILL_TREE && (id=skill_tree[pc_class2idx(sd->status.class_)][i].id) > 0 ; i++){
+ int inf2 = skill->get_inf2(id);
+ if ( inf2&INF2_QUEST_SKILL || (inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL)) || id == NV_BASIC )
+ continue;
+ if( sd->status.skill[id].id && sd->status.skill[id].flag == SKILL_FLAG_PERMANENT )
+ pts += pc_checkskill(sd, id);
+ }
+ if( pts < sd->change_level_2nd )
+ clif->msg_value(sd, 0x61E, sd->change_level_2nd-pts);
+ else if( pts < (sd->change_level_3rd + sd->change_level_2nd) )
+ clif->msg_value(sd, 0x61F, sd->change_level_3rd - (pts - sd->change_level_2nd));
}
return 0;
@@ -6120,8 +6190,8 @@ int pc_allskillup(struct map_session_data *sd)
}
} else {
int inf2;
- for(i=0;i < MAX_SKILL_TREE && (id=skill_tree[pc_class2idx(sd->status.class_)][i].id)>0;i++){
- int idx = skill_tree[pc_class2idx(sd->status.class_)][i].idx;
+ for(i=0;i < MAX_SKILL_TREE && (id=skill_tree[pc->class2idx(sd->status.class_)][i].id)>0;i++){
+ int idx = skill_tree[pc->class2idx(sd->status.class_)][i].idx;
inf2 = skill_db[idx].inf2;
if (
(inf2&INF2_QUEST_SKILL && !battle_config.quest_skill_learn) ||
@@ -6151,7 +6221,7 @@ int pc_resetlvl(struct map_session_data* sd,int type)
nullpo_ret(sd);
if (type != 3) //Also reset skills
- pc_resetskill(sd, 0);
+ pc->resetskill(sd, 0);
if(type == 1){
sd->status.skill_point=0;
@@ -6171,8 +6241,8 @@ int pc_resetlvl(struct map_session_data* sd,int type)
if(sd->status.class_ == JOB_NOVICE_HIGH) {
sd->status.status_point=100; // not 88 [celest]
// give platinum skills upon changing
- pc_skill(sd,142,1,0);
- pc_skill(sd,143,1,0);
+ pc->skill(sd,142,1,0);
+ pc->skill(sd,143,1,0);
}
}
@@ -6217,12 +6287,12 @@ int pc_resetlvl(struct map_session_data* sd,int type)
for(i=0;i<EQI_MAX;i++) { // unequip items that can't be equipped by base 1 [Valaris]
if(sd->equip_index[i] >= 0)
- if(!pc_isequip(sd,sd->equip_index[i]))
- pc_unequipitem(sd,sd->equip_index[i],2);
+ if(!pc->isequip(sd,sd->equip_index[i]))
+ pc->unequipitem(sd,sd->equip_index[i],2);
}
if ((type == 1 || type == 2 || type == 3) && sd->status.party_id)
- party_send_levelup(sd);
+ party->send_levelup(sd);
status_calc_pc(sd,0);
clif->skillinfoblock(sd);
@@ -6250,12 +6320,12 @@ int pc_resetstate(struct map_session_data* sd)
else
{
int add=0;
- add += pc_need_status_point(sd, SP_STR, 1-pc_getstat(sd, SP_STR));
- add += pc_need_status_point(sd, SP_AGI, 1-pc_getstat(sd, SP_AGI));
- add += pc_need_status_point(sd, SP_VIT, 1-pc_getstat(sd, SP_VIT));
- add += pc_need_status_point(sd, SP_INT, 1-pc_getstat(sd, SP_INT));
- add += pc_need_status_point(sd, SP_DEX, 1-pc_getstat(sd, SP_DEX));
- add += pc_need_status_point(sd, SP_LUK, 1-pc_getstat(sd, SP_LUK));
+ add += pc->need_status_point(sd, SP_STR, 1-pc_getstat(sd, SP_STR));
+ add += pc->need_status_point(sd, SP_AGI, 1-pc_getstat(sd, SP_AGI));
+ add += pc->need_status_point(sd, SP_VIT, 1-pc_getstat(sd, SP_VIT));
+ add += pc->need_status_point(sd, SP_INT, 1-pc_getstat(sd, SP_INT));
+ add += pc->need_status_point(sd, SP_DEX, 1-pc_getstat(sd, SP_DEX));
+ add += pc->need_status_point(sd, SP_LUK, 1-pc_getstat(sd, SP_LUK));
sd->status.status_point+=add;
}
@@ -6313,35 +6383,35 @@ int pc_resetskill(struct map_session_data* sd, int flag)
/**
* It has been confirmed on official server that when you reset skills with a ranked tweakwon your skills are not reset (because you have all of them anyway)
**/
- if( (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc_famerank(sd->status.char_id, MAPID_TAEKWON) )
+ if( (sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) )
return 0;
- if( pc_checkskill(sd, SG_DEVIL) && !pc_nextjobexp(sd) ) //Remove perma blindness due to skill-reset. [Skotlex]
- clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_DEVIL);
+ if( pc->checkskill(sd, SG_DEVIL) && !pc->nextjobexp(sd) ) //Remove perma blindness due to skill-reset. [Skotlex]
+ clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_DEVIL1);
i = sd->sc.option;
- if( i&OPTION_RIDING && (!pc_checkskill(sd, KN_RIDING) || (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT) )
+ if( i&OPTION_RIDING && (!pc->checkskill(sd, KN_RIDING) || (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT) )
i &= ~OPTION_RIDING;
- if( i&OPTION_FALCON && pc_checkskill(sd, HT_FALCON) )
+ if( i&OPTION_FALCON && pc->checkskill(sd, HT_FALCON) )
i &= ~OPTION_FALCON;
- if( i&OPTION_DRAGON && pc_checkskill(sd, RK_DRAGONTRAINING) )
+ if( i&OPTION_DRAGON && pc->checkskill(sd, RK_DRAGONTRAINING) )
i &= ~OPTION_DRAGON;
- if( i&OPTION_WUG && pc_checkskill(sd, RA_WUGMASTERY) )
+ if( i&OPTION_WUG && pc->checkskill(sd, RA_WUGMASTERY) )
i &= ~OPTION_WUG;
- if( i&OPTION_WUGRIDER && pc_checkskill(sd, RA_WUGRIDER) )
+ if( i&OPTION_WUGRIDER && pc->checkskill(sd, RA_WUGRIDER) )
i &= ~OPTION_WUGRIDER;
if( i&OPTION_MADOGEAR && ( sd->class_&MAPID_THIRDMASK ) == MAPID_MECHANIC )
i &= ~OPTION_MADOGEAR;
#ifndef NEW_CARTS
- if( i&OPTION_CART && pc_checkskill(sd, MC_PUSHCART) )
+ if( i&OPTION_CART && pc->checkskill(sd, MC_PUSHCART) )
i &= ~OPTION_CART;
#else
if( sd->sc.data[SC_PUSH_CART] )
- pc_setcart(sd, 0);
+ pc->setcart(sd, 0);
#endif
if( i != sd->sc.option )
- pc_setoption(sd, i);
+ pc->setoption(sd, i);
- if( homun_alive(sd->hd) && pc_checkskill(sd, AM_CALLHOMUN) )
+ if( homun_alive(sd->hd) && pc->checkskill(sd, AM_CALLHOMUN) )
homun->vaporize(sd, 0);
}
@@ -6491,19 +6561,19 @@ void pc_respawn(struct map_session_data* sd, clr_type clrtype)
if( sd->bg_id && bg_member_respawn(sd) )
return; // member revived by battleground
- pc_setstand(sd);
- pc_setrestartvalue(sd,3);
- if( pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, clrtype) )
+ pc->setstand(sd);
+ pc->setrestartvalue(sd,3);
+ if( pc->setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, clrtype) )
clif->resurrection(&sd->bl, 1); //If warping fails, send a normal stand up packet.
}
static int pc_respawn_timer(int tid, unsigned int tick, int id, intptr_t data)
{
- struct map_session_data *sd = map_id2sd(id);
+ struct map_session_data *sd = iMap->id2sd(id);
if( sd != NULL )
{
sd->pvp_point=0;
- pc_respawn(sd,CLR_OUTSIGHT);
+ pc->respawn(sd,CLR_OUTSIGHT);
}
return 0;
@@ -6522,7 +6592,7 @@ void pc_damage(struct map_session_data *sd,struct block_list *src,unsigned int h
return;
if( pc_issit(sd) ) {
- pc_setstand(sd);
+ pc->setstand(sd);
skill->sit(sd,0);
}
@@ -6535,20 +6605,19 @@ void pc_damage(struct map_session_data *sd,struct block_list *src,unsigned int h
if( sd->status.ele_id > 0 )
elemental_set_target(sd,src);
- sd->canlog_tick = gettick();
+ sd->canlog_tick = iTimer->gettick();
}
/*==========================================
* Invoked when a player has negative current hp
*------------------------------------------*/
-int pc_dead(struct map_session_data *sd,struct block_list *src)
-{
+int pc_dead(struct map_session_data *sd,struct block_list *src) {
int i=0,j=0,k=0;
- unsigned int tick = gettick();
+ unsigned int tick = iTimer->gettick();
for(k = 0; k < 5; k++)
if (sd->devotion[k]){
- struct map_session_data *devsd = map_id2sd(sd->devotion[k]);
+ struct map_session_data *devsd = iMap->id2sd(sd->devotion[k]);
if (devsd)
status_change_end(&devsd->bl, SC_DEVOTION, INVALID_TIMER);
sd->devotion[k] = 0;
@@ -6585,18 +6654,28 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
duel_reject(sd->duel_invite, sd);
}
+ if (sd->npc_id && sd->st && sd->st->state != RUN)
+ npc_event_dequeue(sd);
+
pc_setglobalreg(sd,"PC_DIE_COUNTER",sd->die_counter+1);
- pc_setparam(sd, SP_KILLERRID, src?src->id:0);
+ pc->setparam(sd, SP_KILLERRID, src?src->id:0);
- if( sd->bg_id ) {
+ if( sd->bg_id ) {/* TODO: purge when bgqueue is deemed ok */
struct battleground_data *bg;
if( (bg = bg_team_search(sd->bg_id)) != NULL && bg->die_event[0] )
npc_event(sd, bg->die_event, 0);
}
-
+
+ for( i = 0; i < sd->queues_count; i++ ) {
+ struct hQueue *queue;
+ if( (queue = script->queue(sd->queues[i])) && queue->onDeath[0] != '\0' )
+ npc_event(sd, queue->onDeath, 0);
+ }
+
+ npc_script_event(sd,NPCE_DIE);
+
// Clear anything NPC-related when you die and was interacting with one.
- if (sd->npc_id)
- {
+ if (sd->npc_id || sd->npc_shopid) {
if (sd->state.using_fake_npc) {
clif->clearunit_single(sd->npc_id, CLR_OUTSIGHT, sd->fd);
sd->state.using_fake_npc = 0;
@@ -6607,13 +6686,12 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
sd->npc_menu = 0;
sd->npc_id = 0;
+ sd->npc_shopid = 0;
if (sd->st && sd->st->state != END)
sd->st->state = END;
}
- npc_script_event(sd,NPCE_DIE);
-
- /* e.g. not killed thru pc_damage */
+ /* e.g. not killed thru pc->damage */
if( pc_issit(sd) ) {
clif->sc_end(&sd->bl,sd->bl.id,SELF,SI_SIT);
}
@@ -6628,50 +6706,50 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
sd->hp_loss.tick = sd->sp_loss.tick = sd->hp_regen.tick = sd->sp_regen.tick = 0;
if ( sd && sd->spiritball )
- pc_delspiritball(sd,sd->spiritball,0);
+ pc->delspiritball(sd,sd->spiritball,0);
for(i = 1; i < 5; i++)
- pc_del_talisman(sd, sd->talisman[i], i);
-
- if (src)
- switch (src->type) {
- case BL_MOB:
- {
- struct mob_data *md=(struct mob_data *)src;
- if(md->target_id==sd->bl.id)
- mob_unlocktarget(md,tick);
- if(battle_config.mobs_level_up && md->status.hp &&
- (unsigned int)md->level < pc_maxbaselv(sd) &&
- !md->guardian_data && !md->special_state.ai// Guardians/summons should not level. [Skotlex]
- ) { // monster level up [Valaris]
- clif->misceffect(&md->bl,0);
- md->level++;
- status_calc_mob(md, 0);
- status_percent_heal(src,10,0);
+ pc->del_charm(sd, sd->charm[i], i);
- if( battle_config.show_mob_info&4 )
- {// update name with new level
- clif->charnameack(0, &md->bl);
+ if (src) {
+ switch (src->type) {
+ case BL_MOB:
+ {
+ struct mob_data *md=(struct mob_data *)src;
+ if(md->target_id==sd->bl.id)
+ mob_unlocktarget(md,tick);
+ if(battle_config.mobs_level_up && md->status.hp &&
+ (unsigned int)md->level < pc->maxbaselv(sd) &&
+ !md->guardian_data && !md->special_state.ai// Guardians/summons should not level. [Skotlex]
+ ) { // monster level up [Valaris]
+ clif->misceffect(&md->bl,0);
+ md->level++;
+ status_calc_mob(md, 0);
+ status_percent_heal(src,10,0);
+
+ if( battle_config.show_mob_info&4 )
+ {// update name with new level
+ clif->charnameack(0, &md->bl);
+ }
+ }
+ src = battle->get_master(src); // Maybe Player Summon
}
+ break;
+ case BL_PET: //Pass on to master...
+ src = &((TBL_PET*)src)->msd->bl;
+ break;
+ case BL_HOM:
+ src = &((TBL_HOM*)src)->master->bl;
+ break;
+ case BL_MER:
+ src = &((TBL_MER*)src)->master->bl;
+ break;
}
- src = battle->get_master(src); // Maybe Player Summon
- }
- break;
- case BL_PET: //Pass on to master...
- src = &((TBL_PET*)src)->msd->bl;
- break;
- case BL_HOM:
- src = &((TBL_HOM*)src)->master->bl;
- break;
- case BL_MER:
- src = &((TBL_MER*)src)->master->bl;
- break;
}
- if (src && src->type == BL_PC)
- {
+ if (src && src->type == BL_PC) {
struct map_session_data *ssd = (struct map_session_data *)src;
- pc_setparam(ssd, SP_KILLEDRID, sd->bl.id);
+ pc->setparam(ssd, SP_KILLEDRID, sd->bl.id);
npc_script_event(ssd, NPCE_KILLPC);
if (battle_config.pk_mode&2) {
@@ -6715,24 +6793,24 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
item_tmp.card[1]=0;
item_tmp.card[2]=GetWord(sd->status.char_id,0); // CharId
item_tmp.card[3]=GetWord(sd->status.char_id,1);
- map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
// activate Steel body if a super novice dies at 99+% exp [celest]
if ((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && !sd->state.snovice_dead_flag)
{
- unsigned int next = pc_nextbaseexp(sd);
- if( next == 0 ) next = pc_thisbaseexp(sd);
+ unsigned int next = pc->nextbaseexp(sd);
+ if( next == 0 ) next = pc->thisbaseexp(sd);
if( get_percentage(sd->status.base_exp,next) >= 99 ) {
sd->state.snovice_dead_flag = 1;
- pc_setstand(sd);
+ pc->setstand(sd);
status_percent_heal(&sd->bl, 100, 100);
clif->resurrection(&sd->bl, 1);
if(battle_config.pc_invincible_time)
- pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
+ pc->setinvincibletimer(sd, battle_config.pc_invincible_time);
sc_start(&sd->bl,status_skill2sc(MO_STEELBODY),100,1,skill->get_time(MO_STEELBODY,1));
if(map_flag_gvg(sd->bl.m))
- pc_respawn_timer(INVALID_TIMER, gettick(), sd->bl.id, 0);
+ pc_respawn_timer(INVALID_TIMER, iTimer->gettick(), sd->bl.id, 0);
return 0;
}
}
@@ -6741,13 +6819,13 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
if(battle_config.death_penalty_type
&& (sd->class_&MAPID_UPPERMASK) != MAPID_NOVICE // only novices will receive no penalty
&& !map[sd->bl.m].flag.noexppenalty && !map_flag_gvg(sd->bl.m)
- && !sd->sc.data[SC_BABY] && !sd->sc.data[SC_LIFEINSURANCE])
+ && !sd->sc.data[SC_BABY] && !sd->sc.data[SC_CASH_DEATHPENALTY])
{
unsigned int base_penalty =0;
if (battle_config.death_penalty_base > 0) {
switch (battle_config.death_penalty_type) {
case 1:
- base_penalty = (unsigned int) ((double)pc_nextbaseexp(sd) * (double)battle_config.death_penalty_base/10000);
+ base_penalty = (unsigned int) ((double)pc->nextbaseexp(sd) * (double)battle_config.death_penalty_base/10000);
break;
case 2:
base_penalty = (unsigned int) ((double)sd->status.base_exp * (double)battle_config.death_penalty_base/10000);
@@ -6765,7 +6843,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
base_penalty = 0;
switch (battle_config.death_penalty_type) {
case 1:
- base_penalty = (unsigned int) ((double)pc_nextjobexp(sd) * (double)battle_config.death_penalty_job/10000);
+ base_penalty = (unsigned int) ((double)pc->nextjobexp(sd) * (double)battle_config.death_penalty_job/10000);
break;
case 2:
base_penalty = (unsigned int) ((double)sd->status.job_exp * (double)battle_config.death_penalty_job/10000);
@@ -6782,13 +6860,13 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
{
base_penalty = (unsigned int)((double)sd->status.zeny * (double)battle_config.zeny_penalty / 10000.);
if(base_penalty)
- pc_payzeny(sd, base_penalty, LOG_TYPE_PICKDROP_PLAYER, NULL);
+ pc->payzeny(sd, base_penalty, LOG_TYPE_PICKDROP_PLAYER, NULL);
}
}
if(map[sd->bl.m].flag.pvp_nightmaredrop)
{ // Moved this outside so it works when PVP isn't enabled and during pk mode [Ancyker]
- for(j=0;j<MAX_DROP_PER_MAP;j++){
+ for(j=0;j<map[sd->bl.m].drop_list_count;j++){
int id = map[sd->bl.m].drop_list[j].drop_id;
int type = map[sd->bl.m].drop_list[j].drop_type;
int per = map[sd->bl.m].drop_list[j].drop_per;
@@ -6814,8 +6892,8 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
int n = eq_n[rnd()%eq_num];
if(rnd()%10000 < per){
if(sd->status.inventory[n].equip)
- pc_unequipitem(sd,n,3);
- pc_dropitem(sd,n,1);
+ pc->unequipitem(sd,n,3);
+ pc->dropitem(sd,n,1);
}
}
}
@@ -6827,8 +6905,8 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
|| (type == 2 && sd->status.inventory[i].equip)
|| type == 3) ){
if(sd->status.inventory[i].equip)
- pc_unequipitem(sd,i,3);
- pc_dropitem(sd,i,1);
+ pc->unequipitem(sd,i,3);
+ pc->dropitem(sd,i,1);
break;
}
}
@@ -6849,14 +6927,14 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
}
if( sd->pvp_point < 0 )
{
- add_timer(tick+1000, pc_respawn_timer,sd->bl.id,0);
+ iTimer->add_timer(tick+1000, pc_respawn_timer,sd->bl.id,0);
return 1|8;
}
}
//GvG
if( map_flag_gvg(sd->bl.m) )
{
- add_timer(tick+1000, pc_respawn_timer, sd->bl.id, 0);
+ iTimer->add_timer(tick+1000, pc_respawn_timer, sd->bl.id, 0);
return 1|8;
}
else if( sd->bg_id )
@@ -6864,7 +6942,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
struct battleground_data *bg = bg_team_search(sd->bg_id);
if( bg && bg->mapindex > 0 )
{ // Respawn by BG
- add_timer(tick+1000, pc_respawn_timer, sd->bl.id, 0);
+ iTimer->add_timer(tick+1000, pc_respawn_timer, sd->bl.id, 0);
return 1|8;
}
}
@@ -6872,7 +6950,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
//Reset "can log out" tick.
if( battle_config.prevent_logout )
- sd->canlog_tick = gettick() - battle_config.prevent_logout;
+ sd->canlog_tick = iTimer->gettick() - battle_config.prevent_logout;
return 1;
}
@@ -6880,9 +6958,9 @@ void pc_revive(struct map_session_data *sd,unsigned int hp, unsigned int sp) {
if(hp) clif->updatestatus(sd,SP_HP);
if(sp) clif->updatestatus(sd,SP_SP);
- pc_setstand(sd);
+ pc->setstand(sd);
if(battle_config.pc_invincible_time > 0)
- pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
+ pc->setinvincibletimer(sd, battle_config.pc_invincible_time);
if( sd->state.gmaster_flag ) {
guild->aura_refresh(sd,GD_LEADERSHIP,guild->checkskill(sd->state.gmaster_flag,GD_LEADERSHIP));
@@ -6909,16 +6987,16 @@ int pc_readparam(struct map_session_data* sd,int type)
case SP_BASELEVEL: val = sd->status.base_level; break;
case SP_JOBLEVEL: val = sd->status.job_level; break;
case SP_CLASS: val = sd->status.class_; break;
- case SP_BASEJOB: val = pc_mapid2jobid(sd->class_&MAPID_UPPERMASK, sd->status.sex); break; //Base job, extracting upper type.
+ case SP_BASEJOB: val = pc->mapid2jobid(sd->class_&MAPID_UPPERMASK, sd->status.sex); break; //Base job, extracting upper type.
case SP_UPPER: val = sd->class_&JOBL_UPPER?1:(sd->class_&JOBL_BABY?2:0); break;
- case SP_BASECLASS: val = pc_mapid2jobid(sd->class_&MAPID_BASEMASK, sd->status.sex); break; //Extract base class tree. [Skotlex]
+ case SP_BASECLASS: val = pc->mapid2jobid(sd->class_&MAPID_BASEMASK, sd->status.sex); break; //Extract base class tree. [Skotlex]
case SP_SEX: val = sd->status.sex; break;
case SP_WEIGHT: val = sd->weight; break;
case SP_MAXWEIGHT: val = sd->max_weight; break;
case SP_BASEEXP: val = sd->status.base_exp; break;
case SP_JOBEXP: val = sd->status.job_exp; break;
- case SP_NEXTBASEEXP: val = pc_nextbaseexp(sd); break;
- case SP_NEXTJOBEXP: val = pc_nextjobexp(sd); break;
+ case SP_NEXTBASEEXP: val = pc->nextbaseexp(sd); break;
+ case SP_NEXTJOBEXP: val = pc->nextjobexp(sd); break;
case SP_HP: val = sd->battle_status.hp; break;
case SP_MAXHP: val = sd->battle_status.max_hp; break;
case SP_SP: val = sd->battle_status.sp; break;
@@ -7054,12 +7132,12 @@ int pc_setparam(struct map_session_data *sd,int type,int val)
switch(type){
case SP_BASELEVEL:
- if ((unsigned int)val > pc_maxbaselv(sd)) //Capping to max
- val = pc_maxbaselv(sd);
+ if ((unsigned int)val > pc->maxbaselv(sd)) //Capping to max
+ val = pc->maxbaselv(sd);
if ((unsigned int)val > sd->status.base_level) {
int stat=0;
for (i = 0; i < (int)((unsigned int)val - sd->status.base_level); i++)
- stat += pc_gets_status_point(sd->status.base_level + i);
+ stat += pc->gets_status_point(sd->status.base_level + i);
sd->status.status_point += stat;
}
sd->status.base_level = (unsigned int)val;
@@ -7071,12 +7149,12 @@ int pc_setparam(struct map_session_data *sd,int type,int val)
status_calc_pc(sd, 0);
if(sd->status.party_id)
{
- party_send_levelup(sd);
+ party->send_levelup(sd);
}
break;
case SP_JOBLEVEL:
if ((unsigned int)val >= sd->status.job_level) {
- if ((unsigned int)val > pc_maxjoblv(sd)) val = pc_maxjoblv(sd);
+ if ((unsigned int)val > pc->maxjoblv(sd)) val = pc->maxjoblv(sd);
sd->status.skill_point += val - sd->status.job_level;
clif->updatestatus(sd, SP_SKILLPOINT);
}
@@ -7100,15 +7178,15 @@ int pc_setparam(struct map_session_data *sd,int type,int val)
sd->status.zeny = cap_value(val, 0, MAX_ZENY);
break;
case SP_BASEEXP:
- if(pc_nextbaseexp(sd) > 0) {
+ if(pc->nextbaseexp(sd) > 0) {
sd->status.base_exp = val;
- pc_checkbaselevelup(sd);
+ pc->checkbaselevelup(sd);
}
break;
case SP_JOBEXP:
- if(pc_nextjobexp(sd) > 0) {
+ if(pc->nextjobexp(sd) > 0) {
sd->status.job_exp = val;
- pc_checkjoblevelup(sd);
+ pc->checkjoblevelup(sd);
}
break;
case SP_SEX:
@@ -7223,19 +7301,17 @@ int pc_itemheal(struct map_session_data *sd,int itemid, int hp,int sp)
if(hp) {
int i;
bonus = 100 + (sd->battle_status.vit<<1)
- + pc_checkskill(sd,SM_RECOVERY)*10
- + pc_checkskill(sd,AM_LEARNINGPOTION)*5;
+ + pc->checkskill(sd,SM_RECOVERY)*10
+ + pc->checkskill(sd,AM_LEARNINGPOTION)*5;
// A potion produced by an Alchemist in the Fame Top 10 gets +50% effect [DracoRPG]
if (potion_flag > 1)
bonus += bonus*(potion_flag-1)*50/100;
//All item bonuses.
bonus += sd->bonus.itemhealrate2;
- //Item Group bonuses
- bonus += bonus*itemdb_group_bonus(sd, itemid)/100;
//Individual item bonuses.
- for(i = 0; i < ARRAYLENGTH(sd->itemhealrate) && sd->itemhealrate[i].nameid; i++)
- {
- if (sd->itemhealrate[i].nameid == itemid) {
+ for(i = 0; i < ARRAYLENGTH(sd->itemhealrate) && sd->itemhealrate[i].nameid; i++) {
+ struct item_data *it = itemdb->exists(sd->itemhealrate[i].nameid);
+ if (sd->itemhealrate[i].nameid == itemid || (it && it->group && itemdb->in_group(it->group,itemid))) {
bonus += bonus*sd->itemhealrate[i].rate/100;
break;
}
@@ -7244,13 +7320,13 @@ int pc_itemheal(struct map_session_data *sd,int itemid, int hp,int sp)
hp = hp * bonus / 100;
// Recovery Potion
- if( sd->sc.data[SC_INCHEALRATE] )
- hp += (int)(hp * sd->sc.data[SC_INCHEALRATE]->val1/100.);
+ if( sd->sc.data[SC_HEALPLUS] )
+ hp += (int)(hp * sd->sc.data[SC_HEALPLUS]->val1/100.);
}
if(sp) {
bonus = 100 + (sd->battle_status.int_<<1)
- + pc_checkskill(sd,MG_SRECOVERY)*10
- + pc_checkskill(sd,AM_LEARNINGPOTION)*5;
+ + pc->checkskill(sd,MG_SRECOVERY)*10
+ + pc->checkskill(sd,AM_LEARNINGPOTION)*5;
if (potion_flag > 1)
bonus += bonus*(potion_flag-1)*50/100;
if(bonus != 100)
@@ -7347,7 +7423,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
return 1;
//Normalize job.
- b_class = pc_jobid2mapid(job);
+ b_class = pc->jobid2mapid(job);
if (b_class == -1)
return 1;
switch (upper) {
@@ -7360,7 +7436,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
}
//This will automatically adjust bard/dancer classes to the correct gender
//That is, if you try to jobchange into dancer, it will turn you to bard.
- job = pc_mapid2jobid(b_class, sd->status.sex);
+ job = pc->mapid2jobid(b_class, sd->status.sex);
if (job == -1)
return 1;
@@ -7405,7 +7481,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
}
if ( (b_class&MAPID_UPPERMASK) != (sd->class_&MAPID_UPPERMASK) ) { //Things to remove when changing class tree.
- const int class_ = pc_class2idx(sd->status.class_);
+ const int class_ = pc->class2idx(sd->status.class_);
short id;
for(i = 0; i < MAX_SKILL_TREE && (id = skill_tree[class_][i].id) > 0; i++) {
//Remove status specific to your current tree skills.
@@ -7417,19 +7493,19 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
if( (sd->class_&MAPID_UPPERMASK) == MAPID_STAR_GLADIATOR && (b_class&MAPID_UPPERMASK) != MAPID_STAR_GLADIATOR) {
/* going off star glad lineage, reset feel to not store no-longer-used vars in the database */
- pc_resetfeel(sd);
+ pc->resetfeel(sd);
}
sd->status.class_ = job;
- fame_flag = pc_famerank(sd->status.char_id,sd->class_&MAPID_UPPERMASK);
+ fame_flag = pc->famerank(sd->status.char_id,sd->class_&MAPID_UPPERMASK);
sd->class_ = (unsigned short)b_class;
sd->status.job_level=1;
sd->status.job_exp=0;
- if (sd->status.base_level > pc_maxbaselv(sd)) {
- sd->status.base_level = pc_maxbaselv(sd);
+ if (sd->status.base_level > pc->maxbaselv(sd)) {
+ sd->status.base_level = pc->maxbaselv(sd);
sd->status.base_exp=0;
- pc_resetstate(sd);
+ pc->resetstate(sd);
clif->updatestatus(sd,SP_STATUSPOINT);
clif->updatestatus(sd,SP_BASELEVEL);
clif->updatestatus(sd,SP_BASEEXP);
@@ -7442,14 +7518,14 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
for(i=0;i<EQI_MAX;i++) {
if(sd->equip_index[i] >= 0)
- if(!pc_isequip(sd,sd->equip_index[i]))
- pc_unequipitem(sd,sd->equip_index[i],2); // unequip invalid item for class
+ if(!pc->isequip(sd,sd->equip_index[i]))
+ pc->unequipitem(sd,sd->equip_index[i],2); // unequip invalid item for class
}
//Change look, if disguised, you need to undisguise
//to correctly calculate new job sprite without
if (sd->disguise != -1)
- pc_disguise(sd, -1);
+ pc->disguise(sd, -1);
status_set_viewdata(&sd->bl, job);
clif->changelook(&sd->bl,LOOK_BASE,sd->vd.class_); // move sprite update to prevent client crashes with incompatible equipment [Valaris]
@@ -7457,7 +7533,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
clif->changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->vd.cloth_color);
//Update skill tree.
- pc_calc_skilltree(sd);
+ pc->calc_skilltree(sd);
clif->skillinfoblock(sd);
if (sd->ed)
@@ -7465,41 +7541,41 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
if (sd->state.vending)
vending->close(sd);
- map_foreachinmap(jobchange_killclone, sd->bl.m, BL_MOB, sd->bl.id);
+ iMap->foreachinmap(jobchange_killclone, sd->bl.m, BL_MOB, sd->bl.id);
//Remove peco/cart/falcon
i = sd->sc.option;
- if( i&OPTION_RIDING && !pc_checkskill(sd, KN_RIDING) )
+ if( i&OPTION_RIDING && (!pc->checkskill(sd, KN_RIDING) || (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT) )
i&=~OPTION_RIDING;
- if( i&OPTION_FALCON && !pc_checkskill(sd, HT_FALCON) )
+ if( i&OPTION_FALCON && !pc->checkskill(sd, HT_FALCON) )
i&=~OPTION_FALCON;
- if( i&OPTION_DRAGON && !pc_checkskill(sd,RK_DRAGONTRAINING) )
+ if( i&OPTION_DRAGON && !pc->checkskill(sd,RK_DRAGONTRAINING) )
i&=~OPTION_DRAGON;
- if( i&OPTION_WUGRIDER && !pc_checkskill(sd,RA_WUGMASTERY) )
+ if( i&OPTION_WUGRIDER && !pc->checkskill(sd,RA_WUGMASTERY) )
i&=~OPTION_WUGRIDER;
- if( i&OPTION_WUG && !pc_checkskill(sd,RA_WUGMASTERY) )
+ if( i&OPTION_WUG && !pc->checkskill(sd,RA_WUGMASTERY) )
i&=~OPTION_WUG;
if( i&OPTION_MADOGEAR ) //You do not need a skill for this.
i&=~OPTION_MADOGEAR;
#ifndef NEW_CARTS
- if( i&OPTION_CART && !pc_checkskill(sd, MC_PUSHCART) )
+ if( i&OPTION_CART && !pc->checkskill(sd, MC_PUSHCART) )
i&=~OPTION_CART;
#else
- if( sd->sc.data[SC_PUSH_CART] && !pc_checkskill(sd, MC_PUSHCART) )
- pc_setcart(sd, 0);
+ if( sd->sc.data[SC_PUSH_CART] && !pc->checkskill(sd, MC_PUSHCART) )
+ pc->setcart(sd, 0);
#endif
if(i != sd->sc.option)
- pc_setoption(sd, i);
+ pc->setoption(sd, i);
- if(homun_alive(sd->hd) && !pc_checkskill(sd, AM_CALLHOMUN))
+ if(homun_alive(sd->hd) && !pc->checkskill(sd, AM_CALLHOMUN))
homun->vaporize(sd, 0);
if(sd->status.manner < 0)
clif->changestatus(sd,SP_MANNER,sd->status.manner);
status_calc_pc(sd,0);
- pc_checkallowskill(sd);
- pc_equiplookall(sd);
+ pc->checkallowskill(sd);
+ pc->equiplookall(sd);
//if you were previously famous, not anymore.
if (fame_flag) {
@@ -7617,7 +7693,7 @@ int pc_setoption(struct map_session_data *sd,int type)
sd->sc.option=type;
clif->changeoption(&sd->bl);
- if( (type&OPTION_RIDING && !(p_type&OPTION_RIDING)) || (type&OPTION_DRAGON && !(p_type&OPTION_DRAGON) && pc_checkskill(sd,RK_DRAGONTRAINING) > 0) ) {
+ if( (type&OPTION_RIDING && !(p_type&OPTION_RIDING)) || (type&OPTION_DRAGON && !(p_type&OPTION_DRAGON) && pc->checkskill(sd,RK_DRAGONTRAINING) > 0) ) {
// Mounting
clif->sc_load(&sd->bl,sd->bl.id,AREA,SI_RIDING, 0, 0, 0);
status_calc_pc(sd,0);
@@ -7631,11 +7707,11 @@ int pc_setoption(struct map_session_data *sd,int type)
if( type&OPTION_CART && !( p_type&OPTION_CART ) ) { //Cart On
clif->cartlist(sd);
clif->updatestatus(sd, SP_CARTINFO);
- if(pc_checkskill(sd, MC_PUSHCART) < 10)
+ if(pc->checkskill(sd, MC_PUSHCART) < 10)
status_calc_pc(sd,0); //Apply speed penalty.
} else if( !( type&OPTION_CART ) && p_type&OPTION_CART ){ //Cart Off
clif->clearcart(sd->fd);
- if(pc_checkskill(sd, MC_PUSHCART) < 10)
+ if(pc->checkskill(sd, MC_PUSHCART) < 10)
status_calc_pc(sd,0); //Remove speed penalty.
}
#endif
@@ -7655,22 +7731,23 @@ int pc_setoption(struct map_session_data *sd,int type)
}
}
if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
- if( type&OPTION_MADOGEAR && !(p_type&OPTION_MADOGEAR) ) {
+ int i;
+ if( type&OPTION_MADOGEAR && !(p_type&OPTION_MADOGEAR) )
status_calc_pc(sd, 0);
- status_change_end(&sd->bl,SC_MAXIMIZEPOWER,INVALID_TIMER);
- status_change_end(&sd->bl,SC_OVERTHRUST,INVALID_TIMER);
- status_change_end(&sd->bl,SC_WEAPONPERFECTION,INVALID_TIMER);
- status_change_end(&sd->bl,SC_ADRENALINE,INVALID_TIMER);
- status_change_end(&sd->bl,SC_CARTBOOST,INVALID_TIMER);
- status_change_end(&sd->bl,SC_MELTDOWN,INVALID_TIMER);
- status_change_end(&sd->bl,SC_MAXOVERTHRUST,INVALID_TIMER);
- } else if( !(type&OPTION_MADOGEAR) && p_type&OPTION_MADOGEAR ) {
+ else if( !(type&OPTION_MADOGEAR) && p_type&OPTION_MADOGEAR )
status_calc_pc(sd, 0);
- status_change_end(&sd->bl,SC_SHAPESHIFT,INVALID_TIMER);
- status_change_end(&sd->bl,SC_HOVERING,INVALID_TIMER);
- status_change_end(&sd->bl,SC_ACCELERATION,INVALID_TIMER);
- status_change_end(&sd->bl,SC_OVERHEAT_LIMITPOINT,INVALID_TIMER);
- status_change_end(&sd->bl,SC_OVERHEAT,INVALID_TIMER);
+ for( i = 0; i < SC_MAX; i++ ){
+ if ( !sd->sc.data[i] || !status_get_sc_type(i) )
+ continue;
+ if ( status_get_sc_type(i)&SC_MADO_NO_RESET )
+ continue;
+ switch (i) {
+ case SC_BERSERK:
+ case SC_SATURDAY_NIGHT_FEVER:
+ sd->sc.data[i]->val2 = 0;
+ break;
+ }
+ status_change_end(&sd->bl, (sc_type)i, INVALID_TIMER);
}
}
@@ -7709,7 +7786,7 @@ int pc_setcart(struct map_session_data *sd,int type) {
if( type < 0 || type > MAX_CARTS )
return 1;// Never trust the values sent by the client! [Skotlex]
- if( pc_checkskill(sd,MC_PUSHCART) <= 0 && type != 0 )
+ if( pc->checkskill(sd,MC_PUSHCART) <= 0 && type != 0 )
return 1;// Push cart is required
if( type == 0 && pc_iscarton(sd) )
@@ -7736,14 +7813,14 @@ int pc_setcart(struct map_session_data *sd,int type) {
break;
}
- if(pc_checkskill(sd, MC_PUSHCART) < 10)
+ if(pc->checkskill(sd, MC_PUSHCART) < 10)
status_calc_pc(sd,0); //Recalc speed penalty.
#else
// Update option
option = sd->sc.option;
option &= ~OPTION_CART;// clear cart bits
option |= cart[type]; // set cart
- pc_setoption(sd, option);
+ pc->setoption(sd, option);
#endif
return 0;
@@ -7755,10 +7832,10 @@ int pc_setcart(struct map_session_data *sd,int type) {
int pc_setfalcon(TBL_PC* sd, int flag)
{
if( flag ){
- if( pc_checkskill(sd,HT_FALCON)>0 ) // add falcon if he have the skill
- pc_setoption(sd,sd->sc.option|OPTION_FALCON);
+ if( pc->checkskill(sd,HT_FALCON)>0 ) // add falcon if he have the skill
+ pc->setoption(sd,sd->sc.option|OPTION_FALCON);
} else if( pc_isfalcon(sd) ){
- pc_setoption(sd,sd->sc.option&~OPTION_FALCON); // remove falcon
+ pc->setoption(sd,sd->sc.option&~OPTION_FALCON); // remove falcon
}
return 0;
@@ -7770,10 +7847,10 @@ int pc_setfalcon(TBL_PC* sd, int flag)
int pc_setriding(TBL_PC* sd, int flag)
{
if( flag ){
- if( pc_checkskill(sd,KN_RIDING) > 0 ) // add peco
- pc_setoption(sd, sd->sc.option|OPTION_RIDING);
+ if( pc->checkskill(sd,KN_RIDING) > 0 ) // add peco
+ pc->setoption(sd, sd->sc.option|OPTION_RIDING);
} else if( pc_isriding(sd) ){
- pc_setoption(sd, sd->sc.option&~OPTION_RIDING);
+ pc->setoption(sd, sd->sc.option&~OPTION_RIDING);
}
return 0;
@@ -7785,10 +7862,10 @@ int pc_setriding(TBL_PC* sd, int flag)
int pc_setmadogear(TBL_PC* sd, int flag)
{
if( flag ){
- if( pc_checkskill(sd,NC_MADOLICENCE) > 0 )
- pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
+ if( pc->checkskill(sd,NC_MADOLICENCE) > 0 )
+ pc->setoption(sd, sd->sc.option|OPTION_MADOGEAR);
} else if( pc_ismadogear(sd) ){
- pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
+ pc->setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
}
return 0;
@@ -7801,9 +7878,9 @@ int pc_candrop(struct map_session_data *sd, struct item *item)
{
if( item && item->expire_time )
return 0;
- if( !pc_can_give_items(sd) ) //check if this GM level can drop items
+ if( !pc->can_give_items(sd) ) //check if this GM level can drop items
return 0;
- return (itemdb_isdropable(item, pc_get_group_level(sd)));
+ return (itemdb_isdropable(item, pc->get_group_level(sd)));
}
/*==========================================
@@ -8147,7 +8224,7 @@ int pc_setregistry_str(struct map_session_data *sd,const char *reg,const char *v
*------------------------------------------*/
static int pc_eventtimer(int tid, unsigned int tick, int id, intptr_t data)
{
- struct map_session_data *sd=map_id2sd(id);
+ struct map_session_data *sd=iMap->id2sd(id);
char *p = (char *)data;
int i;
if(sd==NULL)
@@ -8179,7 +8256,7 @@ int pc_addeventtimer(struct map_session_data *sd,int tick,const char *name)
if( i == MAX_EVENTTIMER )
return 0;
- sd->eventtimer[i] = add_timer(gettick()+tick, pc_eventtimer, sd->bl.id, (intptr_t)aStrdup(name));
+ sd->eventtimer[i] = iTimer->add_timer(iTimer->gettick()+tick, pc_eventtimer, sd->bl.id, (intptr_t)aStrdup(name));
sd->eventcount++;
return 1;
@@ -8201,13 +8278,13 @@ int pc_deleventtimer(struct map_session_data *sd,const char *name)
// find the named event timer
ARR_FIND( 0, MAX_EVENTTIMER, i,
sd->eventtimer[i] != INVALID_TIMER &&
- (p = (char *)(get_timer(sd->eventtimer[i])->data)) != NULL &&
+ (p = (char *)(iTimer->get_timer(sd->eventtimer[i])->data)) != NULL &&
strcmp(p, name) == 0
);
if( i == MAX_EVENTTIMER )
return 0; // not found
- delete_timer(sd->eventtimer[i],pc_eventtimer);
+ iTimer->delete_timer(sd->eventtimer[i],pc_eventtimer);
sd->eventtimer[i] = INVALID_TIMER;
sd->eventcount--;
aFree(p);
@@ -8226,8 +8303,8 @@ int pc_addeventtimercount(struct map_session_data *sd,const char *name,int tick)
for(i=0;i<MAX_EVENTTIMER;i++)
if( sd->eventtimer[i] != INVALID_TIMER && strcmp(
- (char *)(get_timer(sd->eventtimer[i])->data), name)==0 ){
- addtick_timer(sd->eventtimer[i],tick);
+ (char *)(iTimer->get_timer(sd->eventtimer[i])->data), name)==0 ){
+ iTimer->addtick_timer(sd->eventtimer[i],tick);
break;
}
@@ -8248,8 +8325,8 @@ int pc_cleareventtimer(struct map_session_data *sd)
for(i=0;i<MAX_EVENTTIMER;i++)
if( sd->eventtimer[i] != INVALID_TIMER ){
- char *p = (char *)(get_timer(sd->eventtimer[i])->data);
- delete_timer(sd->eventtimer[i],pc_eventtimer);
+ char *p = (char *)(iTimer->get_timer(sd->eventtimer[i])->data);
+ iTimer->delete_timer(sd->eventtimer[i],pc_eventtimer);
sd->eventtimer[i] = INVALID_TIMER;
sd->eventcount--;
if (p) aFree(p);
@@ -8402,7 +8479,7 @@ int pc_load_combo(struct map_session_data *sd) {
for( j = 0; j < id->slot; j++ ) {
if (!sd->status.inventory[idx].card[j])
continue;
- if ( ( data = itemdb_exists(sd->status.inventory[idx].card[j]) ) != NULL ) {
+ if ( ( data = itemdb->exists(sd->status.inventory[idx].card[j]) ) != NULL ) {
if( data->combos_count )
ret += pc_checkcombo(sd,data);
}
@@ -8426,24 +8503,24 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
return 0;
}
- if( DIFF_TICK(sd->canequip_tick,gettick()) > 0 )
+ if( DIFF_TICK(sd->canequip_tick,iTimer->gettick()) > 0 )
{
clif->equipitemack(sd,n,0,0);
return 0;
}
id = sd->inventory_data[n];
- pos = pc_equippoint(sd,n); //With a few exceptions, item should go in all specified slots.
+ pos = pc->equippoint(sd,n); //With a few exceptions, item should go in all specified slots.
if(battle_config.battle_log)
ShowInfo("equip %d(%d) %x:%x\n",sd->status.inventory[n].nameid,n,id?id->equip:0,req_pos);
- if(!pc_isequip(sd,n) || !(pos&req_pos) || sd->status.inventory[n].equip != 0 || sd->status.inventory[n].attribute==1 ) { // [Valaris]
- // FIXME: pc_isequip: equip level failure uses 2 instead of 0
+ if(!pc->isequip(sd,n) || !(pos&req_pos) || sd->status.inventory[n].equip != 0 || sd->status.inventory[n].attribute==1 ) { // [Valaris]
+ // FIXME: pc->isequip: equip level failure uses 2 instead of 0
clif->equipitemack(sd,n,0,0); // fail
return 0;
}
- if (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_SATURDAYNIGHTFEVER] || sd->sc.data[SC__BLOODYLUST])
+ if (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_SATURDAY_NIGHT_FEVER] || sd->sc.data[SC__BLOODYLUST])
{
clif->equipitemack(sd,n,0,0); // fail
return 0;
@@ -8474,7 +8551,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
for(i=0;i<EQI_MAX;i++) {
if(pos & equip_pos[i]) {
if(sd->equip_index[i] >= 0) //Slot taken, remove item from there.
- pc_unequipitem(sd,sd->equip_index[i],2);
+ pc->unequipitem(sd,sd->equip_index[i],2);
sd->equip_index[i] = n;
}
@@ -8516,21 +8593,21 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
}
//Added check to prevent sending the same look on multiple slots ->
//causes client to redraw item on top of itself. (suggested by Lupus)
- if(pos & EQP_HEAD_LOW && pc_checkequip(sd,EQP_COSTUME_HEAD_LOW) == -1) {
+ if(pos & EQP_HEAD_LOW && pc->checkequip(sd,EQP_COSTUME_HEAD_LOW) == -1) {
if(id && !(pos&(EQP_HEAD_TOP|EQP_HEAD_MID)))
sd->status.head_bottom = id->look;
else
sd->status.head_bottom = 0;
clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom);
}
- if(pos & EQP_HEAD_TOP && pc_checkequip(sd,EQP_COSTUME_HEAD_TOP) == -1) {
+ if(pos & EQP_HEAD_TOP && pc->checkequip(sd,EQP_COSTUME_HEAD_TOP) == -1) {
if(id)
sd->status.head_top = id->look;
else
sd->status.head_top = 0;
clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top);
}
- if(pos & EQP_HEAD_MID && pc_checkequip(sd,EQP_COSTUME_HEAD_MID) == -1) {
+ if(pos & EQP_HEAD_MID && pc->checkequip(sd,EQP_COSTUME_HEAD_MID) == -1) {
if(id && !(pos&EQP_HEAD_TOP))
sd->status.head_mid = id->look;
else
@@ -8561,7 +8638,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
if(pos & EQP_SHOES)
clif->changelook(&sd->bl,LOOK_SHOES,0);
- if( pos&EQP_GARMENT && pc_checkequip(sd,EQP_COSTUME_GARMENT) == -1 ) {
+ if( pos&EQP_GARMENT && pc->checkequip(sd,EQP_COSTUME_GARMENT) == -1 ) {
sd->status.robe = id ? id->look : 0;
clif->changelook(&sd->bl, LOOK_ROBE, sd->status.robe);
}
@@ -8572,7 +8649,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
}
- pc_checkallowskill(sd); //Check if status changes should be halted.
+ pc->checkallowskill(sd); //Check if status changes should be halted.
iflag = sd->npc_item_flag;
/* check for combos (MUST be before status_calc_pc) */
@@ -8586,7 +8663,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
struct item_data *data;
if (!sd->status.inventory[n].card[i])
continue;
- if ( ( data = itemdb_exists(sd->status.inventory[n].card[i]) ) != NULL ) {
+ if ( ( data = itemdb->exists(sd->status.inventory[n].card[i]) ) != NULL ) {
if( data->combos_count )
pc_checkcombo(sd,data);
}
@@ -8609,7 +8686,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
struct item_data *data;
if (!sd->status.inventory[n].card[i])
continue;
- if ( ( data = itemdb_exists(sd->status.inventory[n].card[i]) ) != NULL ) {
+ if ( ( data = itemdb->exists(sd->status.inventory[n].card[i]) ) != NULL ) {
if( data->equip_script )
run_script(data->equip_script,0,sd->bl.id,fake_nd->bl.id);
}
@@ -8639,7 +8716,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) {
}
// if player is berserk then cannot unequip
- if (!(flag & 2) && sd->sc.count && (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_SATURDAYNIGHTFEVER] || sd->sc.data[SC__BLOODYLUST]))
+ if (!(flag & 2) && sd->sc.count && (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_SATURDAY_NIGHT_FEVER] || sd->sc.data[SC__BLOODYLUST]))
{
clif->unequipitemack(sd,n,0,0);
return 0;
@@ -8652,7 +8729,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) {
}
if(battle_config.battle_log)
- ShowInfo("unequip %d %x:%x\n",n,pc_equippoint(sd,n),sd->status.inventory[n].equip);
+ ShowInfo("unequip %d %x:%x\n",n,pc->equippoint(sd,n),sd->status.inventory[n].equip);
if(!sd->status.inventory[n].equip){ //Nothing to unequip
clif->unequipitemack(sd,n,0,0);
@@ -8676,51 +8753,51 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) {
pc_calcweapontype(sd);
clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
}
- if(sd->status.inventory[n].equip & EQP_HEAD_LOW && pc_checkequip(sd,EQP_COSTUME_HEAD_LOW) == -1 ) {
+ if(sd->status.inventory[n].equip & EQP_HEAD_LOW && pc->checkequip(sd,EQP_COSTUME_HEAD_LOW) == -1 ) {
sd->status.head_bottom = 0;
clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom);
}
- if(sd->status.inventory[n].equip & EQP_HEAD_TOP && pc_checkequip(sd,EQP_COSTUME_HEAD_TOP) == -1 ) {
+ if(sd->status.inventory[n].equip & EQP_HEAD_TOP && pc->checkequip(sd,EQP_COSTUME_HEAD_TOP) == -1 ) {
sd->status.head_top = 0;
clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top);
}
- if(sd->status.inventory[n].equip & EQP_HEAD_MID && pc_checkequip(sd,EQP_COSTUME_HEAD_MID) == -1 ) {
+ if(sd->status.inventory[n].equip & EQP_HEAD_MID && pc->checkequip(sd,EQP_COSTUME_HEAD_MID) == -1 ) {
sd->status.head_mid = 0;
clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid);
}
if(sd->status.inventory[n].equip & EQP_COSTUME_HEAD_TOP) {
- sd->status.head_top = ( pc_checkequip(sd,EQP_HEAD_TOP) >= 0 ) ? sd->inventory_data[pc_checkequip(sd,EQP_HEAD_TOP)]->look : 0;
+ sd->status.head_top = ( pc->checkequip(sd,EQP_HEAD_TOP) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_TOP)]->look : 0;
clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top);
}
if(sd->status.inventory[n].equip & EQP_COSTUME_HEAD_MID) {
- sd->status.head_mid = ( pc_checkequip(sd,EQP_HEAD_MID) >= 0 ) ? sd->inventory_data[pc_checkequip(sd,EQP_HEAD_MID)]->look : 0;
+ sd->status.head_mid = ( pc->checkequip(sd,EQP_HEAD_MID) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_MID)]->look : 0;
clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid);
}
if(sd->status.inventory[n].equip & EQP_COSTUME_HEAD_LOW) {
- sd->status.head_bottom = ( pc_checkequip(sd,EQP_HEAD_LOW) >= 0 ) ? sd->inventory_data[pc_checkequip(sd,EQP_HEAD_LOW)]->look : 0;
+ sd->status.head_bottom = ( pc->checkequip(sd,EQP_HEAD_LOW) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_LOW)]->look : 0;
clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom);
}
if(sd->status.inventory[n].equip & EQP_SHOES)
clif->changelook(&sd->bl,LOOK_SHOES,0);
- if( sd->status.inventory[n].equip&EQP_GARMENT && pc_checkequip(sd,EQP_COSTUME_GARMENT) == -1 ) {
+ if( sd->status.inventory[n].equip&EQP_GARMENT && pc->checkequip(sd,EQP_COSTUME_GARMENT) == -1 ) {
sd->status.robe = 0;
clif->changelook(&sd->bl, LOOK_ROBE, 0);
}
if(sd->status.inventory[n].equip & EQP_COSTUME_GARMENT) {
- sd->status.robe = ( pc_checkequip(sd,EQP_GARMENT) >= 0 ) ? sd->inventory_data[pc_checkequip(sd,EQP_GARMENT)]->look : 0;
+ sd->status.robe = ( pc->checkequip(sd,EQP_GARMENT) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_GARMENT)]->look : 0;
clif->changelook(&sd->bl,LOOK_ROBE,sd->status.robe);
}
clif->unequipitemack(sd,n,sd->status.inventory[n].equip,1);
if((sd->status.inventory[n].equip & EQP_ARMS) &&
- sd->weapontype1 == 0 && sd->weapontype2 == 0 && (!sd->sc.data[SC_SEVENWIND] || sd->sc.data[SC_ASPERSIO])) //Check for seven wind (but not level seven!)
+ sd->weapontype1 == 0 && sd->weapontype2 == 0 && (!sd->sc.data[SC_TK_SEVENWIND] || sd->sc.data[SC_ASPERSIO])) //Check for seven wind (but not level seven!)
skill->enchant_elemental_end(&sd->bl,-1);
if(sd->status.inventory[n].equip & EQP_ARMOR) {
@@ -8747,7 +8824,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) {
struct item_data *data;
if (!sd->status.inventory[n].card[i])
continue;
- if ( ( data = itemdb_exists(sd->status.inventory[n].card[i]) ) != NULL ) {
+ if ( ( data = itemdb->exists(sd->status.inventory[n].card[i]) ) != NULL ) {
if( data->combos_count ) {
if( pc_removecombo(sd,data) )
status_cacl = true;
@@ -8758,12 +8835,12 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) {
}
if(flag&1 || status_cacl) {
- pc_checkallowskill(sd);
+ pc->checkallowskill(sd);
status_calc_pc(sd,0);
}
- if(sd->sc.data[SC_SIGNUMCRUCIS] && !battle->check_undead(sd->battle_status.race,sd->battle_status.def_ele))
- status_change_end(&sd->bl, SC_SIGNUMCRUCIS, INVALID_TIMER);
+ if(sd->sc.data[SC_CRUCIS] && !battle->check_undead(sd->battle_status.race,sd->battle_status.def_ele))
+ status_change_end(&sd->bl, SC_CRUCIS, INVALID_TIMER);
//OnUnEquip script [Skotlex]
if (sd->inventory_data[n]) {
@@ -8777,7 +8854,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) {
if (!sd->status.inventory[n].card[i])
continue;
- if ( ( data = itemdb_exists(sd->status.inventory[n].card[i]) ) != NULL ) {
+ if ( ( data = itemdb->exists(sd->status.inventory[n].card[i]) ) != NULL ) {
if( data->unequip_script )
run_script(data->unequip_script,0,sd->bl.id,fake_nd->bl.id);
}
@@ -8809,7 +8886,7 @@ int pc_checkitem(struct map_session_data *sd)
if( id && !itemdb_available(id) ) {
ShowWarning("Removed invalid/disabled item id %d from inventory (amount=%d, char_id=%d).\n", id, sd->status.inventory[i].amount, sd->status.char_id);
- pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_OTHER);
+ pc->delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_OTHER);
}
}
@@ -8818,7 +8895,7 @@ int pc_checkitem(struct map_session_data *sd)
if( id && !itemdb_available(id) ) {
ShowWarning("Removed invalid/disabled item id %d from cart (amount=%d, char_id=%d).\n", id, sd->status.cart[i].amount, sd->status.char_id);
- pc_cart_delitem(sd, i, sd->status.cart[i].amount, 0, LOG_TYPE_OTHER);
+ pc->cart_delitem(sd, i, sd->status.cart[i].amount, 0, LOG_TYPE_OTHER);
}
}
}
@@ -8831,8 +8908,8 @@ int pc_checkitem(struct map_session_data *sd)
if( !sd->status.inventory[i].equip )
continue;
- if( sd->status.inventory[i].equip&~pc_equippoint(sd,i) ) {
- pc_unequipitem(sd, i, 2);
+ if( sd->status.inventory[i].equip&~pc->equippoint(sd,i) ) {
+ pc->unequipitem(sd, i, 2);
calc_flag = 1;
continue;
}
@@ -8840,7 +8917,7 @@ int pc_checkitem(struct map_session_data *sd)
}
if( calc_flag && sd->state.active ) {
- pc_checkallowskill(sd);
+ pc->checkallowskill(sd);
status_calc_pc(sd,0);
}
@@ -8867,7 +8944,7 @@ int pc_calc_pvprank_sub(struct block_list *bl,va_list ap)
return 0;
}
/*==========================================
- * Calculate new rank beetween all present players (map_foreachinarea)
+ * Calculate new rank beetween all present players (iMap->foreachinarea)
* and display result
*------------------------------------------*/
int pc_calc_pvprank(struct map_session_data *sd)
@@ -8877,7 +8954,7 @@ int pc_calc_pvprank(struct map_session_data *sd)
m=&map[sd->bl.m];
old=sd->pvp_rank;
sd->pvp_rank=1;
- map_foreachinmap(pc_calc_pvprank_sub,sd->bl.m,BL_PC,sd);
+ iMap->foreachinmap(pc_calc_pvprank_sub,sd->bl.m,BL_PC,sd);
if(old!=sd->pvp_rank || sd->pvp_lastusers!=m->users_pvp)
clif->pvpset(sd,sd->pvp_rank,sd->pvp_lastusers=m->users_pvp,0);
return sd->pvp_rank;
@@ -8889,7 +8966,7 @@ int pc_calc_pvprank_timer(int tid, unsigned int tick, int id, intptr_t data)
{
struct map_session_data *sd;
- sd=map_id2sd(id);
+ sd=iMap->id2sd(id);
if(sd==NULL)
return 0;
sd->pvp_timer = INVALID_TIMER;
@@ -8899,8 +8976,8 @@ int pc_calc_pvprank_timer(int tid, unsigned int tick, int id, intptr_t data)
return 0;
}
- if( pc_calc_pvprank(sd) > 0 )
- sd->pvp_timer = add_timer(gettick()+PVP_CALCRANK_INTERVAL,pc_calc_pvprank_timer,id,data);
+ if( pc->calc_pvprank(sd) > 0 )
+ sd->pvp_timer = iTimer->add_timer(iTimer->gettick()+PVP_CALCRANK_INTERVAL,pc->calc_pvprank_timer,id,data);
return 0;
}
@@ -8947,13 +9024,13 @@ int pc_divorce(struct map_session_data *sd)
struct map_session_data *p_sd;
int i;
- if( sd == NULL || !pc_ismarried(sd) )
+ if( sd == NULL || !pc->ismarried(sd) )
return -1;
if( !sd->status.partner_id )
return -1; // Char is not married
- if( (p_sd = map_charid2sd(sd->status.partner_id)) == NULL )
+ if( (p_sd = iMap->charid2sd(sd->status.partner_id)) == NULL )
{ // Lets char server do the divorce
if( chrif_divorce(sd->status.char_id, sd->status.partner_id) )
return -1; // No char server connected
@@ -8967,9 +9044,9 @@ int pc_divorce(struct map_session_data *sd)
for( i = 0; i < MAX_INVENTORY; i++ )
{
if( sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F )
- pc_delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
+ pc->delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
if( p_sd->status.inventory[i].nameid == WEDDING_RING_M || p_sd->status.inventory[i].nameid == WEDDING_RING_F )
- pc_delitem(p_sd, i, 1, 0, 0, LOG_TYPE_OTHER);
+ pc->delitem(p_sd, i, 1, 0, 0, LOG_TYPE_OTHER);
}
clif->divorced(sd, p_sd->status.name);
@@ -8983,9 +9060,9 @@ int pc_divorce(struct map_session_data *sd)
*------------------------------------------*/
struct map_session_data *pc_get_partner(struct map_session_data *sd)
{
- if (sd && pc_ismarried(sd))
+ if (sd && pc->ismarried(sd))
// charid2sd returns NULL if not found
- return map_charid2sd(sd->status.partner_id);
+ return iMap->charid2sd(sd->status.partner_id);
return NULL;
}
@@ -8997,7 +9074,7 @@ struct map_session_data *pc_get_father (struct map_session_data *sd)
{
if (sd && sd->class_&JOBL_BABY && sd->status.father > 0)
// charid2sd returns NULL if not found
- return map_charid2sd(sd->status.father);
+ return iMap->charid2sd(sd->status.father);
return NULL;
}
@@ -9009,7 +9086,7 @@ struct map_session_data *pc_get_mother (struct map_session_data *sd)
{
if (sd && sd->class_&JOBL_BABY && sd->status.mother > 0)
// charid2sd returns NULL if not found
- return map_charid2sd(sd->status.mother);
+ return iMap->charid2sd(sd->status.mother);
return NULL;
}
@@ -9019,9 +9096,9 @@ struct map_session_data *pc_get_mother (struct map_session_data *sd)
*------------------------------------------*/
struct map_session_data *pc_get_child (struct map_session_data *sd)
{
- if (sd && pc_ismarried(sd) && sd->status.child > 0)
+ if (sd && pc->ismarried(sd) && sd->status.child > 0)
// charid2sd returns NULL if not found
- return map_charid2sd(sd->status.child);
+ return iMap->charid2sd(sd->status.child);
return NULL;
}
@@ -9138,19 +9215,19 @@ int pc_autosave(int tid, unsigned int tick, int id, intptr_t data)
}
mapit->free(iter);
- interval = autosave_interval/(map_usercount()+1);
- if(interval < minsave_interval)
- interval = minsave_interval;
- add_timer(gettick()+interval,pc_autosave,0,0);
+ interval = iMap->autosave_interval/(iMap->usercount()+1);
+ if(interval < iMap->minsave_interval)
+ interval = iMap->minsave_interval;
+ iTimer->add_timer(iTimer->gettick()+interval,pc_autosave,0,0);
return 0;
}
static int pc_daynight_timer_sub(struct map_session_data *sd,va_list ap)
{
- if (sd->state.night != night_flag && map[sd->bl.m].flag.nightenabled) { //Night/day state does not match.
- clif->status_change(&sd->bl, SI_NIGHT, night_flag, 0, 0, 0, 0); //New night effect by dynamix [Skotlex]
- sd->state.night = night_flag;
+ if (sd->state.night != iMap->night_flag && map[sd->bl.m].flag.nightenabled) { //Night/day state does not match.
+ clif->status_change(&sd->bl, SI_SKE, iMap->night_flag, 0, 0, 0, 0); //New night effect by dynamix [Skotlex]
+ sd->state.night = iMap->night_flag;
return 1;
}
return 0;
@@ -9166,11 +9243,11 @@ int map_day_timer(int tid, unsigned int tick, int id, intptr_t data)
if (data == 0 && battle_config.day_duration <= 0) // if we want a day
return 0;
- if (!night_flag)
+ if (!iMap->night_flag)
return 0; //Already day.
- night_flag = 0; // 0=day, 1=night [Yor]
- map_foreachpc(pc_daynight_timer_sub);
+ iMap->night_flag = 0; // 0=day, 1=night [Yor]
+ iMap->map_foreachpc(pc_daynight_timer_sub);
strcpy(tmp_soutput, (data == 0) ? msg_txt(502) : msg_txt(60)); // The day has arrived!
intif_broadcast(tmp_soutput, strlen(tmp_soutput) + 1, 0);
return 0;
@@ -9187,11 +9264,11 @@ int map_night_timer(int tid, unsigned int tick, int id, intptr_t data)
if (data == 0 && battle_config.night_duration <= 0) // if we want a night
return 0;
- if (night_flag)
+ if (iMap->night_flag)
return 0; //Already nigth.
- night_flag = 1; // 0=day, 1=night [Yor]
- map_foreachpc(pc_daynight_timer_sub);
+ iMap->night_flag = 1; // 0=day, 1=night [Yor]
+ iMap->map_foreachpc(pc_daynight_timer_sub);
strcpy(tmp_soutput, (data == 0) ? msg_txt(503) : msg_txt(59)); // The night has fallen...
intif_broadcast(tmp_soutput, strlen(tmp_soutput) + 1, 0);
return 0;
@@ -9217,7 +9294,7 @@ void pc_overheat(struct map_session_data *sd, int val) {
if( !pc_ismadogear(sd) || sd->sc.data[SC_OVERHEAT] )
return; // already burning
- skill = cap_value(pc_checkskill(sd,NC_MAINFRAME),0,4);
+ skill = cap_value(pc->checkskill(sd,NC_MAINFRAME),0,4);
if( sd->sc.data[SC_OVERHEAT_LIMITPOINT] ) {
heat += sd->sc.data[SC_OVERHEAT_LIMITPOINT]->val1;
status_change_end(&sd->bl,SC_OVERHEAT_LIMITPOINT,INVALID_TIMER);
@@ -9253,41 +9330,41 @@ bool pc_can_use_command(struct map_session_data *sd, const char *command) {
return atcommand->can_use(sd,command);
}
-static int pc_talisman_timer(int tid, unsigned int tick, int id, intptr_t data)
+static int pc_charm_timer(int tid, unsigned int tick, int id, intptr_t data)
{
struct map_session_data *sd;
int i, type;
- if( (sd=(struct map_session_data *)map_id2sd(id)) == NULL || sd->bl.type!=BL_PC )
+ if( (sd=(struct map_session_data *)iMap->id2sd(id)) == NULL || sd->bl.type!=BL_PC )
return 1;
- ARR_FIND(1, 5, type, sd->talisman[type] > 0);
+ ARR_FIND(1, 5, type, sd->charm[type] > 0);
- if( sd->talisman[type] <= 0 )
+ if( sd->charm[type] <= 0 )
{
- ShowError("pc_talisman_timer: %d talisman's available. (aid=%d cid=%d tid=%d)\n", sd->talisman[type], sd->status.account_id, sd->status.char_id, tid);
- sd->talisman[type] = 0;
+ ShowError("pc_charm_timer: %d charm's available. (aid=%d cid=%d tid=%d)\n", sd->charm[type], sd->status.account_id, sd->status.char_id, tid);
+ sd->charm[type] = 0;
return 0;
}
- ARR_FIND(0, sd->talisman[type], i, sd->talisman_timer[type][i] == tid);
- if( i == sd->talisman[type] )
+ ARR_FIND(0, sd->charm[type], i, sd->charm_timer[type][i] == tid);
+ if( i == sd->charm[type] )
{
- ShowError("pc_talisman_timer: timer not found (aid=%d cid=%d tid=%d)\n", sd->status.account_id, sd->status.char_id, tid);
+ ShowError("pc_charm_timer: timer not found (aid=%d cid=%d tid=%d)\n", sd->status.account_id, sd->status.char_id, tid);
return 0;
}
- sd->talisman[type]--;
- if( i != sd->talisman[type] )
- memmove(sd->talisman_timer[type]+i, sd->talisman_timer[type]+i+1, (sd->talisman[type]-i)*sizeof(int));
- sd->talisman_timer[type][sd->talisman[type]] = INVALID_TIMER;
+ sd->charm[type]--;
+ if( i != sd->charm[type] )
+ memmove(sd->charm_timer[type]+i, sd->charm_timer[type]+i+1, (sd->charm[type]-i)*sizeof(int));
+ sd->charm_timer[type][sd->charm[type]] = INVALID_TIMER;
- clif->talisman(sd, type);
+ clif->charm(sd, type);
return 0;
}
-int pc_add_talisman(struct map_session_data *sd,int interval,int max,int type)
+int pc_add_charm(struct map_session_data *sd,int interval,int max,int type)
{
int tid, i;
@@ -9295,61 +9372,61 @@ int pc_add_talisman(struct map_session_data *sd,int interval,int max,int type)
if(max > 10)
max = 10;
- if(sd->talisman[type] < 0)
- sd->talisman[type] = 0;
+ if(sd->charm[type] < 0)
+ sd->charm[type] = 0;
- if( sd->talisman[type] && sd->talisman[type] >= max )
+ if( sd->charm[type] && sd->charm[type] >= max )
{
- if(sd->talisman_timer[type][0] != INVALID_TIMER)
- delete_timer(sd->talisman_timer[type][0],pc_talisman_timer);
- sd->talisman[type]--;
- if( sd->talisman[type] != 0 )
- memmove(sd->talisman_timer[type]+0, sd->talisman_timer[type]+1, (sd->talisman[type])*sizeof(int));
- sd->talisman_timer[type][sd->talisman[type]] = INVALID_TIMER;
- }
-
- tid = add_timer(gettick()+interval, pc_talisman_timer, sd->bl.id, 0);
- ARR_FIND(0, sd->talisman[type], i, sd->talisman_timer[type][i] == INVALID_TIMER || DIFF_TICK(get_timer(tid)->tick, get_timer(sd->talisman_timer[type][i])->tick) < 0);
- if( i != sd->talisman[type] )
- memmove(sd->talisman_timer[type]+i+1, sd->talisman_timer[type]+i, (sd->talisman[type]-i)*sizeof(int));
- sd->talisman_timer[type][i] = tid;
- sd->talisman[type]++;
-
- clif->talisman(sd, type);
+ if(sd->charm_timer[type][0] != INVALID_TIMER)
+ iTimer->delete_timer(sd->charm_timer[type][0],pc_charm_timer);
+ sd->charm[type]--;
+ if( sd->charm[type] != 0 )
+ memmove(sd->charm_timer[type]+0, sd->charm_timer[type]+1, (sd->charm[type])*sizeof(int));
+ sd->charm_timer[type][sd->charm[type]] = INVALID_TIMER;
+ }
+
+ tid = iTimer->add_timer(iTimer->gettick()+interval, pc_charm_timer, sd->bl.id, 0);
+ ARR_FIND(0, sd->charm[type], i, sd->charm_timer[type][i] == INVALID_TIMER || DIFF_TICK(iTimer->get_timer(tid)->tick, iTimer->get_timer(sd->charm_timer[type][i])->tick) < 0);
+ if( i != sd->charm[type] )
+ memmove(sd->charm_timer[type]+i+1, sd->charm_timer[type]+i, (sd->charm[type]-i)*sizeof(int));
+ sd->charm_timer[type][i] = tid;
+ sd->charm[type]++;
+
+ clif->charm(sd, type);
return 0;
}
-int pc_del_talisman(struct map_session_data *sd,int count,int type)
+int pc_del_charm(struct map_session_data *sd,int count,int type)
{
int i;
nullpo_ret(sd);
- if( sd->talisman[type] <= 0 ) {
- sd->talisman[type] = 0;
+ if( sd->charm[type] <= 0 ) {
+ sd->charm[type] = 0;
return 0;
}
if( count <= 0 )
return 0;
- if( count > sd->talisman[type] )
- count = sd->talisman[type];
- sd->talisman[type] -= count;
+ if( count > sd->charm[type] )
+ count = sd->charm[type];
+ sd->charm[type] -= count;
if( count > 10 )
count = 10;
for(i = 0; i < count; i++) {
- if(sd->talisman_timer[type][i] != INVALID_TIMER) {
- delete_timer(sd->talisman_timer[type][i],pc_talisman_timer);
- sd->talisman_timer[type][i] = INVALID_TIMER;
+ if(sd->charm_timer[type][i] != INVALID_TIMER) {
+ iTimer->delete_timer(sd->charm_timer[type][i],pc_charm_timer);
+ sd->charm_timer[type][i] = INVALID_TIMER;
}
}
for(i = count; i < 10; i++) {
- sd->talisman_timer[type][i-count] = sd->talisman_timer[type][i];
- sd->talisman_timer[type][i] = INVALID_TIMER;
+ sd->charm_timer[type][i-count] = sd->charm_timer[type][i];
+ sd->charm_timer[type][i] = INVALID_TIMER;
}
- clif->talisman(sd, type);
+ clif->charm(sd, type);
return 0;
}
#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP)
@@ -9444,55 +9521,260 @@ int pc_split_atoui(char* str, unsigned int* val, char sep, int max)
val[j] = 0;
return i;
}
+/* [Ind/Hercules] */
+void pc_read_skill_tree(void) {
+ config_t skill_tree_conf;
+ config_setting_t *skt = NULL, *inherit = NULL, *skills = NULL, *sk = NULL;
+#ifdef RENEWAL
+ const char *config_filename = "db/re/skill_tree.conf"; // FIXME hardcoded name
+#else
+ const char *config_filename = "db/pre-re/skill_tree.conf"; // FIXME hardcoded name
+#endif
+ int i = 0, jnamelen = 0;
+ struct {
+ const char *name;
+ int id;
+ } jnames[] = {
+ { "Novice", JOB_NOVICE },
+ { "Swordsman", JOB_SWORDMAN },
+ { "Magician", JOB_MAGE },
+ { "Archer", JOB_ARCHER },
+ { "Acolyte", JOB_ACOLYTE },
+ { "Merchant", JOB_MERCHANT },
+ { "Thief", JOB_THIEF },
+ { "Knight", JOB_KNIGHT },
+ { "Priest", JOB_PRIEST },
+ { "Wizard", JOB_WIZARD },
+ { "Blacksmith", JOB_BLACKSMITH },
+ { "Hunter", JOB_HUNTER },
+ { "Assassin", JOB_ASSASSIN },
+ { "Crusader", JOB_CRUSADER },
+ { "Monk", JOB_MONK },
+ { "Sage", JOB_SAGE },
+ { "Rogue", JOB_ROGUE },
+ { "Alchemist", JOB_ALCHEMIST },
+ { "Bard", JOB_BARD },
+ { "Dancer", JOB_DANCER },
+ { "Super_Novice", JOB_SUPER_NOVICE },
+ { "Gunslinger", JOB_GUNSLINGER },
+ { "Ninja", JOB_NINJA },
+ { "Novice_High", JOB_NOVICE_HIGH },
+ { "Swordsman_High", JOB_SWORDMAN_HIGH },
+ { "Magician_High", JOB_MAGE_HIGH },
+ { "Archer_High", JOB_ARCHER_HIGH },
+ { "Acolyte_High", JOB_ACOLYTE_HIGH },
+ { "Merchant_High", JOB_MERCHANT_HIGH },
+ { "Thief_High", JOB_THIEF_HIGH },
+ { "Lord_Knight", JOB_LORD_KNIGHT },
+ { "High_Priest", JOB_HIGH_PRIEST },
+ { "High_Wizard", JOB_HIGH_WIZARD },
+ { "Whitesmith", JOB_WHITESMITH },
+ { "Sniper", JOB_SNIPER },
+ { "Assassin_Cross", JOB_ASSASSIN_CROSS },
+ { "Paladin", JOB_PALADIN },
+ { "Champion", JOB_CHAMPION },
+ { "Professor", JOB_PROFESSOR },
+ { "Stalker", JOB_STALKER },
+ { "Creator", JOB_CREATOR },
+ { "Clown", JOB_CLOWN },
+ { "Gypsy", JOB_GYPSY },
+ { "Baby_Novice", JOB_BABY },
+ { "Baby_Swordsman", JOB_BABY_SWORDMAN },
+ { "Baby_Magician", JOB_BABY_MAGE },
+ { "Baby_Archer", JOB_BABY_ARCHER },
+ { "Baby_Acolyte", JOB_BABY_ACOLYTE },
+ { "Baby_Merchant", JOB_BABY_MERCHANT },
+ { "Baby_Thief", JOB_BABY_THIEF },
+ { "Baby_Knight", JOB_BABY_KNIGHT },
+ { "Baby_Priest", JOB_BABY_PRIEST },
+ { "Baby_Wizard", JOB_BABY_WIZARD },
+ { "Baby_Blacksmith", JOB_BABY_BLACKSMITH },
+ { "Baby_Hunter", JOB_BABY_HUNTER },
+ { "Baby_Assassin", JOB_BABY_ASSASSIN },
+ { "Baby_Crusader", JOB_BABY_CRUSADER },
+ { "Baby_Monk", JOB_BABY_MONK },
+ { "Baby_Sage", JOB_BABY_SAGE },
+ { "Baby_Rogue", JOB_BABY_ROGUE },
+ { "Baby_Alchemist", JOB_BABY_ALCHEMIST },
+ { "Baby_Bard", JOB_BABY_BARD },
+ { "Baby_Dancer", JOB_BABY_DANCER },
+ { "Super_Baby", JOB_SUPER_BABY },
+ { "Taekwon", JOB_TAEKWON },
+ { "Star_Gladiator", JOB_STAR_GLADIATOR },
+ { "Soul_Linker", JOB_SOUL_LINKER },
+ { "Gangsi", JOB_GANGSI },
+ { "Death_Knight", JOB_DEATH_KNIGHT },
+ { "Dark_Collector", JOB_DARK_COLLECTOR },
+ { "Rune_Knight", JOB_RUNE_KNIGHT },
+ { "Warlock", JOB_WARLOCK },
+ { "Ranger", JOB_RANGER },
+ { "Arch_Bishop", JOB_ARCH_BISHOP },
+ { "Mechanic", JOB_MECHANIC },
+ { "Guillotine_Cross", JOB_GUILLOTINE_CROSS },
+ { "Rune_Knight_Trans", JOB_RUNE_KNIGHT_T },
+ { "Warlock_Trans", JOB_WARLOCK_T },
+ { "Ranger_Trans", JOB_RANGER_T },
+ { "Arch_Bishop_Trans", JOB_ARCH_BISHOP_T },
+ { "Mechanic_Trans", JOB_MECHANIC_T },
+ { "Guillotine_Cross_Trans", JOB_GUILLOTINE_CROSS_T },
+ { "Royal_Guard", JOB_ROYAL_GUARD },
+ { "Sorcerer", JOB_SORCERER },
+ { "Minstrel", JOB_MINSTREL },
+ { "Wanderer", JOB_WANDERER },
+ { "Sura", JOB_SURA },
+ { "Genetic", JOB_GENETIC },
+ { "Shadow_Chaser", JOB_SHADOW_CHASER },
+ { "Royal_Guard_Trans", JOB_ROYAL_GUARD_T },
+ { "Sorcerer_Trans", JOB_SORCERER_T },
+ { "Minstrel_Trans", JOB_MINSTREL_T },
+ { "Wanderer_Trans", JOB_WANDERER_T },
+ { "Sura_Trans", JOB_SURA_T },
+ { "Genetic_Trans", JOB_GENETIC_T },
+ { "Shadow_Chaser_Trans", JOB_SHADOW_CHASER_T },
+ { "Baby_Rune_Knight", JOB_BABY_RUNE },
+ { "Baby_Warlock", JOB_BABY_WARLOCK },
+ { "Baby_Ranger", JOB_BABY_RANGER },
+ { "Baby_Arch_Bishop", JOB_BABY_BISHOP },
+ { "Baby_Mechanic", JOB_BABY_MECHANIC },
+ { "Baby_Guillotine_Cross", JOB_BABY_CROSS },
+ { "Baby_Royal_Guard", JOB_BABY_GUARD },
+ { "Baby_Sorcerer", JOB_BABY_SORCERER },
+ { "Baby_Minstrel", JOB_BABY_MINSTREL },
+ { "Baby_Wanderer", JOB_BABY_WANDERER },
+ { "Baby_Sura", JOB_BABY_SURA },
+ { "Baby_Genetic", JOB_BABY_GENETIC },
+ { "Baby_Shadow_Chaser", JOB_BABY_CHASER },
+ { "Expanded_Super_Novice", JOB_SUPER_NOVICE_E },
+ { "Expanded_Super_Baby", JOB_SUPER_BABY_E },
+ { "Kagerou", JOB_KAGEROU },
+ { "Oboro", JOB_OBORO },
+ };
+
+ if (conf_read_file(&skill_tree_conf, config_filename)) {
+ ShowError("can't read %s\n", config_filename);
+ return;
+ }
+
+ jnamelen = ARRAYLENGTH(jnames);
+
+ while( (skt = config_setting_get_elem(skill_tree_conf.root,i++)) ) {
+ int k, idx;
+ const char *name = config_setting_name(skt);
+
+ ARR_FIND(0, jnamelen, k, strcmpi(jnames[k].name,name) == 0 );
+
+ if( k == jnamelen ) {
+ ShowWarning("pc_read_skill_tree: '%s' unknown job name!\n",name);
+ continue;
+ }
+
+
+ if( ( skills = config_setting_get_member(skt,"skills") ) ) {
+ int c = 0;
+
+ idx = pc->class2idx(jnames[k].id);
+
+ while( ( sk = config_setting_get_elem(skills,c++) ) ) {
+ const char *sk_name = config_setting_name(sk);
+ int skill_id;
+
+ if( ( skill_id = skill->name2id(sk_name) ) ) {
+ int skidx, offset = 0, h = 0, rlen = 0, rskid = 0;
+
+ ARR_FIND( 0, MAX_SKILL_TREE, skidx, skill_tree[idx][skidx].id == 0 || skill_tree[idx][skidx].id == skill_id );
+ if( skidx == MAX_SKILL_TREE ) {
+ ShowWarning("pc_read_skill_tree: Unable to load skill %hu (%s) into '%s's tree. Maximum number of skills per class has been reached.\n", skill_id, sk_name, name);
+ continue;
+ } else if(skill_tree[idx][skidx].id) {
+ ShowNotice("pc_read_skill_tree: Overwriting %hu for '%s' (%d)\n", skill_id, name, jnames[k].id);
+ }
+
+ skill_tree[idx][skidx].id = skill_id;
+ skill_tree[idx][skidx].idx = skill->get_index(skill_id);
+
+ if( config_setting_is_group(sk) ) {
+ int max = 0, jlevel = 0;
+ config_setting_lookup_int(sk, "MaxLevel", &max);
+ config_setting_lookup_int(sk, "MinJobLevel", &jlevel);
+ skill_tree[idx][skidx].max = (unsigned char)max;
+ skill_tree[idx][skidx].joblv = (unsigned char)jlevel;
+ rlen = config_setting_length(sk);
+ offset += jlevel ? 2 : 1;
+ } else {
+ skill_tree[idx][skidx].max = (unsigned char)config_setting_get_int(sk);
+ skill_tree[idx][skidx].joblv = 0;
+ }
+
+ for( h = offset; h < rlen && h < MAX_PC_SKILL_REQUIRE; h++ ) {
+ config_setting_t *rsk = config_setting_get_elem(sk,h);
+ if( rsk && ( rskid = skill->name2id(config_setting_name(rsk)) ) ) {
+ skill_tree[idx][skidx].need[h].id = rskid;
+ skill_tree[idx][skidx].need[h].idx = skill->get_index(rskid);
+ skill_tree[idx][skidx].need[h].lv = (unsigned char)config_setting_get_int(rsk);
+ } else if( rsk ) {
+ ShowWarning("pc_read_skill_tree: unknown requirement '%s' for '%s' in '%s'\n",config_setting_name(rsk),sk_name,name);
+ } else {
+ ShowWarning("pc_read_skill_tree: error for '%s' in '%s'\n",sk_name,name);
+ }
+ }
+
+ } else {
+ ShowWarning("pc_read_skill_tree: unknown skill '%s' in '%s'\n",sk_name,name);
+ }
+ }
+ }
+ }
+
+ i = 0;
+ while( (skt = config_setting_get_elem(skill_tree_conf.root,i++)) ) {
+ int k, idx, v = 0;
+ const char *name = config_setting_name(skt);
+ const char *iname;
-/*==========================================
- * sub DB reading.
- * Function used to read skill_tree.txt
- *------------------------------------------*/
-static bool pc_readdb_skilltree(char* fields[], int columns, int current)
-{
- unsigned char joblv = 0, skill_lv;
- uint16 skill_id;
- int idx, class_;
- unsigned int i, offset = 3, skill_idx;
+
+ ARR_FIND(0, jnamelen, k, strcmpi(jnames[k].name,name) == 0 );
+
+ if( k == jnamelen ) {
+ ShowWarning("pc_read_skill_tree: '%s' unknown job name!\n",name);
+ continue;
+ }
+ idx = pc->class2idx(jnames[k].id);
- class_ = atoi(fields[0]);
- skill_id = (uint16)atoi(fields[1]);
- skill_lv = (unsigned char)atoi(fields[2]);
+ if( ( inherit = config_setting_get_member(skt,"inherit") ) ) {
+ while( ( iname = config_setting_get_string_elem(inherit, v++) ) ) {
+ int b = 0, a, d, f, fidx;
- if(columns==4+MAX_PC_SKILL_REQUIRE*2)
- {// job level requirement extra column
- joblv = (unsigned char)atoi(fields[3]);
- offset++;
- }
+ ARR_FIND(0, jnamelen, b, strcmpi(jnames[b].name,iname) == 0 );
+
+ if( b == jnamelen ) {
+ ShowWarning("pc_read_skill_tree: '%s' trying to inherit unknown '%s'!\n",name,iname);
+ continue;
+ }
+
+ fidx = pc->class2idx(jnames[b].id);
+
+ ARR_FIND( 0, MAX_SKILL_TREE, d, skill_tree[fidx][d].id == 0 );
- if(!pcdb_checkid(class_))
- {
- ShowWarning("pc_readdb_skilltree: Invalid job class %d specified.\n", class_);
- return false;
- }
- idx = pc_class2idx(class_);
+ for( f = 0; f < d; f++ ) {
+
+ ARR_FIND( 0, MAX_SKILL_TREE, a, skill_tree[idx][a].id == 0 || skill_tree[idx][a].id == skill_tree[fidx][f].id );
- //This is to avoid adding two lines for the same skill. [Skotlex]
- ARR_FIND( 0, MAX_SKILL_TREE, skill_idx, skill_tree[idx][skill_idx].id == 0 || skill_tree[idx][skill_idx].id == skill_id );
- if( skill_idx == MAX_SKILL_TREE ) {
- ShowWarning("pc_readdb_skilltree: Unable to load skill %hu into job %d's tree. Maximum number of skills per class has been reached.\n", skill_id, class_);
- return false;
- } else if(skill_tree[idx][skill_idx].id) {
- ShowNotice("pc_readdb_skilltree: Overwriting skill %hu for job class %d.\n", skill_id, class_);
+ if( a == MAX_SKILL_TREE ) {
+ ShowWarning("pc_read_skill_tree: '%s' can't inherit '%s', skill tree is full!\n", name,iname);
+ break;
+ } else if ( skill_tree[idx][a].id || ( skill_tree[idx][a].id == NV_TRICKDEAD && ((pc->jobid2mapid(jnames[k].id)&MAPID_UPPERMASK)!=MAPID_NOVICE) ) ) /* we skip trickdead for non-novices */
+ continue;/* skip */
+
+ memcpy(&skill_tree[idx][a],&skill_tree[fidx][f],sizeof(skill_tree[fidx][f]));
+ }
+
+ }
+ }
+
}
+
+ config_destroy(&skill_tree_conf);
- skill_tree[idx][skill_idx].id = skill_id;
- skill_tree[idx][skill_idx].idx = skill->get_index(skill_id);
- skill_tree[idx][skill_idx].max = skill_lv;
- skill_tree[idx][skill_idx].joblv = joblv;
-
- for(i = 0; i < MAX_PC_SKILL_REQUIRE; i++) {
- skill_tree[idx][skill_idx].need[i].id = atoi(fields[i*2+offset]);
- skill_tree[idx][skill_idx].need[i].idx = skill->get_index(atoi(fields[i*2+offset]));
- skill_tree[idx][skill_idx].need[i].lv = atoi(fields[i*2+offset+1]);
- }
- return true;
}
#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP)
static bool pc_readdb_levelpenalty(char* fields[], int columns, int current)
@@ -9541,7 +9823,7 @@ int pc_readdb(void)
memset(exp_table,0,sizeof(exp_table));
memset(max_level,0,sizeof(max_level));
- sprintf(line, "%s/"DBPATH"exp.txt", db_path);
+ sprintf(line, "%s/"DBPATH"exp.txt", iMap->db_path);
fp=fopen(line, "r");
if(fp==NULL){
@@ -9578,7 +9860,7 @@ int pc_readdb(void)
maxlv = MAX_LEVEL;
}
count++;
- job = jobs[0] = pc_class2idx(job_id);
+ job = jobs[0] = pc->class2idx(job_id);
//We send one less and then one more because the last entry in the exp array should hold 0.
max_level[job][type] = pc_split_atoui(split[3], exp_table[job][type],',',maxlv-1)+1;
//Reverse check in case the array has a bunch of trailing zeros... [Skotlex]
@@ -9603,7 +9885,7 @@ int pc_readdb(void)
ShowError("pc_readdb: Invalid job ID %d.\n", job_id);
continue;
}
- job = pc_class2idx(job_id);
+ job = pc->class2idx(job_id);
memcpy(exp_table[job][type], exp_table[jobs[0]][type], sizeof(exp_table[0][0]));
max_level[job][type] = maxlv;
// ShowDebug("%s - Class %d: %u\n", type?"Job":"Base", job_id, max_level[job][type]);
@@ -9614,20 +9896,19 @@ int pc_readdb(void)
if (!pcdb_checkid(i)) continue;
if (i == JOB_WEDDING || i == JOB_XMAS || i == JOB_SUMMER)
continue; //Classes that do not need exp tables.
- j = pc_class2idx(i);
+ j = pc->class2idx(i);
if (!max_level[j][0])
- ShowWarning("Class %s (%d) does not has a base exp table.\n", job_name(i), i);
+ ShowWarning("Class %s (%d) does not has a base exp table.\n", pc->job_name(i), i);
if (!max_level[j][1])
- ShowWarning("Class %s (%d) does not has a job exp table.\n", job_name(i), i);
+ ShowWarning("Class %s (%d) does not has a job exp table.\n", pc->job_name(i), i);
}
- ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,db_path,"exp.txt");
+ ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,iMap->db_path,"exp.txt");
count = 0;
// Reset and read skilltree
memset(skill_tree,0,sizeof(skill_tree));
- sv->readdb(db_path, DBPATH"skill_tree.txt", ',', 3+MAX_PC_SKILL_REQUIRE*2, 4+MAX_PC_SKILL_REQUIRE*2, -1, &pc_readdb_skilltree);
-
+ pc_read_skill_tree();
#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP)
- sv->readdb(db_path, "re/level_penalty.txt", ',', 4, 4, -1, &pc_readdb_levelpenalty);
+ sv->readdb(iMap->db_path, "re/level_penalty.txt", ',', 4, 4, -1, &pc_readdb_levelpenalty);
for( k=1; k < 3; k++ ){ // fill in the blanks
for( j = 0; j < RC_MAX; j++ ){
int tmp = 0;
@@ -9649,7 +9930,7 @@ int pc_readdb(void)
for(k=0;k<ELE_MAX;k++)
attr_fix_table[i][j][k]=100;
- sprintf(line, "%s/"DBPATH"attr_fix.txt", db_path);
+ sprintf(line, "%s/"DBPATH"attr_fix.txt", iMap->db_path);
fp=fopen(line,"r");
if(fp==NULL){
@@ -9693,13 +9974,13 @@ int pc_readdb(void)
}
}
fclose(fp);
- ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,db_path,"attr_fix.txt");
+ ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,iMap->db_path,"attr_fix.txt");
count = 0;
// reset then read statspoint
memset(statp,0,sizeof(statp));
i=1;
- sprintf(line, "%s/"DBPATH"statpoint.txt", db_path);
+ sprintf(line, "%s/"DBPATH"statpoint.txt", iMap->db_path);
fp=fopen(line,"r");
if(fp == NULL){
ShowWarning("Can't read '"CL_WHITE"%s"CL_RESET"'... Generating DB.\n",line);
@@ -9720,14 +10001,14 @@ int pc_readdb(void)
}
fclose(fp);
- ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,db_path,"statpoint.txt");
+ ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,iMap->db_path,"statpoint.txt");
}
// generate the remaining parts of the db if necessary
k = battle_config.use_statpoint_table; //save setting
- battle_config.use_statpoint_table = 0; //temporarily disable to force pc_gets_status_point use default values
+ battle_config.use_statpoint_table = 0; //temporarily disable to force pc->gets_status_point use default values
statp[0] = 45; // seed value
for (; i <= MAX_LEVEL; i++)
- statp[i] = statp[i-1] + pc_gets_status_point(i-1);
+ statp[i] = statp[i-1] + pc->gets_status_point(i-1);
battle_config.use_statpoint_table = k; //restore setting
return 0;
@@ -9743,7 +10024,7 @@ void pc_itemcd_do(struct map_session_data *sd, bool load) {
return;
}
for(i = 0; i < MAX_ITEMDELAYS; i++) {
- if( cd->nameid[i] && DIFF_TICK(gettick(),cd->tick[i]) < 0 ) {
+ if( cd->nameid[i] && DIFF_TICK(iTimer->gettick(),cd->tick[i]) < 0 ) {
sd->item_delay[cursor].tick = cd->tick[i];
sd->item_delay[cursor].nameid = cd->nameid[i];
cursor++;
@@ -9757,7 +10038,7 @@ void pc_itemcd_do(struct map_session_data *sd, bool load) {
idb_put( itemcd_db, sd->status.char_id, cd );
}
for(i = 0; i < MAX_ITEMDELAYS; i++) {
- if( sd->item_delay[i].nameid && DIFF_TICK(gettick(),sd->item_delay[i].tick) < 0 ) {
+ if( sd->item_delay[i].nameid && DIFF_TICK(iTimer->gettick(),sd->item_delay[i].tick) < 0 ) {
cd->tick[cursor] = sd->item_delay[i].tick;
cd->nameid[cursor] = sd->item_delay[i].nameid;
cursor++;
@@ -9766,6 +10047,7 @@ void pc_itemcd_do(struct map_session_data *sd, bool load) {
}
return;
}
+
/*==========================================
* pc Init/Terminate
*------------------------------------------*/
@@ -9783,32 +10065,32 @@ int do_init_pc(void) {
itemcd_db = idb_alloc(DB_OPT_RELEASE_DATA);
- pc_readdb();
+ pc->readdb();
- add_timer_func_list(pc_invincible_timer, "pc_invincible_timer");
- add_timer_func_list(pc_eventtimer, "pc_eventtimer");
- add_timer_func_list(pc_inventory_rental_end, "pc_inventory_rental_end");
- add_timer_func_list(pc_calc_pvprank_timer, "pc_calc_pvprank_timer");
- add_timer_func_list(pc_autosave, "pc_autosave");
- add_timer_func_list(pc_spiritball_timer, "pc_spiritball_timer");
- add_timer_func_list(pc_follow_timer, "pc_follow_timer");
- add_timer_func_list(pc_endautobonus, "pc_endautobonus");
- add_timer_func_list(pc_talisman_timer, "pc_talisman_timer");
+ iTimer->add_timer_func_list(pc_invincible_timer, "pc_invincible_timer");
+ iTimer->add_timer_func_list(pc_eventtimer, "pc_eventtimer");
+ iTimer->add_timer_func_list(pc_inventory_rental_end, "pc_inventory_rental_end");
+ iTimer->add_timer_func_list(pc->calc_pvprank_timer, "pc->calc_pvprank_timer");
+ iTimer->add_timer_func_list(pc_autosave, "pc_autosave");
+ iTimer->add_timer_func_list(pc_spiritball_timer, "pc_spiritball_timer");
+ iTimer->add_timer_func_list(pc_follow_timer, "pc_follow_timer");
+ iTimer->add_timer_func_list(pc->endautobonus, "pc->endautobonus");
+ iTimer->add_timer_func_list(pc_charm_timer, "pc_charm_timer");
- add_timer(gettick() + autosave_interval, pc_autosave, 0, 0);
+ iTimer->add_timer(iTimer->gettick() + iMap->autosave_interval, pc_autosave, 0, 0);
// 0=day, 1=night [Yor]
- night_flag = battle_config.night_at_start ? 1 : 0;
+ iMap->night_flag = battle_config.night_at_start ? 1 : 0;
if (battle_config.day_duration > 0 && battle_config.night_duration > 0) {
int day_duration = battle_config.day_duration;
int night_duration = battle_config.night_duration;
// add night/day timer [Yor]
- add_timer_func_list(map_day_timer, "map_day_timer");
- add_timer_func_list(map_night_timer, "map_night_timer");
+ iTimer->add_timer_func_list(pc->map_day_timer, "pc->map_day_timer");
+ iTimer->add_timer_func_list(pc->map_night_timer, "pc->map_night_timer");
- day_timer_tid = add_timer_interval(gettick() + (night_flag ? 0 : day_duration) + night_duration, map_day_timer, 0, 0, day_duration + night_duration);
- night_timer_tid = add_timer_interval(gettick() + day_duration + (night_flag ? night_duration : 0), map_night_timer, 0, 0, day_duration + night_duration);
+ pc->day_timer_tid = iTimer->add_timer_interval(iTimer->gettick() + (iMap->night_flag ? 0 : day_duration) + night_duration, pc->map_day_timer, 0, 0, day_duration + night_duration);
+ pc->night_timer_tid = iTimer->add_timer_interval(iTimer->gettick() + day_duration + (iMap->night_flag ? night_duration : 0), pc->map_night_timer, 0, 0, day_duration + night_duration);
}
do_init_pc_groups();
@@ -9817,3 +10099,220 @@ int do_init_pc(void) {
return 0;
}
+
+/*=====================================
+* Default Functions : pc.h
+* Generated by HerculesInterfaceMaker
+* created by Susu
+*-------------------------------------*/
+void pc_defaults(void) {
+ pc = &pc_s;
+
+ /* vars */
+ // timer for night.day
+ pc->day_timer_tid = day_timer_tid;
+ pc->night_timer_tid = night_timer_tid;
+
+ /* funcs */
+
+ pc->class2idx = pc_class2idx;
+ pc->get_group_level = pc_get_group_level;
+ pc->can_give_items = pc_can_give_items;
+
+ pc->can_use_command = pc_can_use_command;
+
+ pc->setrestartvalue = pc_setrestartvalue;
+ pc->makesavestatus = pc_makesavestatus;
+ pc->respawn = pc_respawn;
+ pc->setnewpc = pc_setnewpc;
+ pc->authok = pc_authok;
+ pc->authfail = pc_authfail;
+ pc->reg_received = pc_reg_received;
+
+ pc->isequip = pc_isequip;
+ pc->equippoint = pc_equippoint;
+ pc->setinventorydata = pc_setinventorydata;
+
+ pc->checkskill = pc_checkskill;
+ pc->checkskill2 = pc_checkskill2;
+ pc->checkallowskill = pc_checkallowskill;
+ pc->checkequip = pc_checkequip;
+
+ pc->calc_skilltree = pc_calc_skilltree;
+ pc->calc_skilltree_normalize_job = pc_calc_skilltree_normalize_job;
+ pc->clean_skilltree = pc_clean_skilltree;
+
+ pc->setpos = pc_setpos;
+ pc->setsavepoint = pc_setsavepoint;
+ pc->randomwarp = pc_randomwarp;
+ pc->memo = pc_memo;
+
+ pc->checkadditem = pc_checkadditem;
+ pc->inventoryblank = pc_inventoryblank;
+ pc->search_inventory = pc_search_inventory;
+ pc->payzeny = pc_payzeny;
+ pc->additem = pc_additem;
+ pc->getzeny = pc_getzeny;
+ pc->delitem = pc_delitem;
+ // Special Shop System
+ pc->paycash = pc_paycash;
+ pc->getcash = pc_getcash;
+
+ pc->cart_additem = pc_cart_additem;
+ pc->cart_delitem = pc_cart_delitem;
+ pc->putitemtocart = pc_putitemtocart;
+ pc->getitemfromcart = pc_getitemfromcart;
+ pc->cartitem_amount = pc_cartitem_amount;
+
+ pc->takeitem = pc_takeitem;
+ pc->dropitem = pc_dropitem;
+
+ pc->isequipped = pc_isequipped;
+ pc->can_Adopt = pc_can_Adopt;
+ pc->adoption = pc_adoption;
+
+ pc->updateweightstatus = pc_updateweightstatus;
+
+ pc->addautobonus = pc_addautobonus;
+ pc->exeautobonus = pc_exeautobonus;
+ pc->endautobonus = pc_endautobonus;
+ pc->delautobonus = pc_delautobonus;
+
+ pc->bonus = pc_bonus;
+ pc->bonus2 = pc_bonus2;
+ pc->bonus3 = pc_bonus3;
+ pc->bonus4 = pc_bonus4;
+ pc->bonus5 = pc_bonus5;
+ pc->skill = pc_skill;
+
+ pc->insert_card = pc_insert_card;
+
+ pc->steal_item = pc_steal_item;
+ pc->steal_coin = pc_steal_coin;
+
+ pc->modifybuyvalue = pc_modifybuyvalue;
+ pc->modifysellvalue = pc_modifysellvalue;
+
+ pc->follow = pc_follow; // [MouseJstr]
+ pc->stop_following = pc_stop_following;
+
+ pc->maxbaselv = pc_maxbaselv;
+ pc->maxjoblv = pc_maxjoblv;
+ pc->checkbaselevelup = pc_checkbaselevelup;
+ pc->checkjoblevelup = pc_checkjoblevelup;
+ pc->gainexp = pc_gainexp;
+ pc->nextbaseexp = pc_nextbaseexp;
+ pc->thisbaseexp = pc_thisbaseexp;
+ pc->nextjobexp = pc_nextjobexp;
+ pc->thisjobexp = pc_thisjobexp;
+ pc->gets_status_point = pc_gets_status_point;
+ pc->need_status_point = pc_need_status_point;
+ pc->statusup = pc_statusup;
+ pc->statusup2 = pc_statusup2;
+ pc->skillup = pc_skillup;
+ pc->allskillup = pc_allskillup;
+ pc->resetlvl = pc_resetlvl;
+ pc->resetstate = pc_resetstate;
+ pc->resetskill = pc_resetskill;
+ pc->resetfeel = pc_resetfeel;
+ pc->resethate = pc_resethate;
+ pc->equipitem = pc_equipitem;
+ pc->unequipitem = pc_unequipitem;
+ pc->checkitem = pc_checkitem;
+ pc->useitem = pc_useitem;
+
+ pc->skillatk_bonus = pc_skillatk_bonus;
+ pc->skillheal_bonus = pc_skillheal_bonus;
+ pc->skillheal2_bonus = pc_skillheal2_bonus;
+
+ pc->damage = pc_damage;
+ pc->dead = pc_dead;
+ pc->revive = pc_revive;
+ pc->heal = pc_heal;
+ pc->itemheal = pc_itemheal;
+ pc->percentheal = pc_percentheal;
+ pc->jobchange = pc_jobchange;
+ pc->setoption = pc_setoption;
+ pc->setcart = pc_setcart;
+ pc->setfalcon = pc_setfalcon;
+ pc->setriding = pc_setriding;
+ pc->setmadogear = pc_setmadogear;
+ pc->changelook = pc_changelook;
+ pc->equiplookall = pc_equiplookall;
+
+ pc->readparam = pc_readparam;
+ pc->setparam = pc_setparam;
+ pc->readreg = pc_readreg;
+ pc->setreg = pc_setreg;
+ pc->readregstr = pc_readregstr;
+ pc->setregstr = pc_setregstr;
+ pc->readregistry = pc_readregistry;
+ pc->setregistry = pc_setregistry;
+ pc->readregistry_str = pc_readregistry_str;
+ pc->setregistry_str = pc_setregistry_str;
+
+ pc->addeventtimer = pc_addeventtimer;
+ pc->deleventtimer = pc_deleventtimer;
+ pc->cleareventtimer = pc_cleareventtimer;
+ pc->addeventtimercount = pc_addeventtimercount;
+
+ pc->calc_pvprank = pc_calc_pvprank;
+ pc->calc_pvprank_timer = pc_calc_pvprank_timer;
+
+ pc->ismarried = pc_ismarried;
+ pc->marriage = pc_marriage;
+ pc->divorce = pc_divorce;
+ pc->get_partner = pc_get_partner;
+ pc->get_father = pc_get_father;
+ pc->get_mother = pc_get_mother;
+ pc->get_child = pc_get_child;
+
+ pc->bleeding = pc_bleeding;
+ pc->regen = pc_regen;
+
+ pc->setstand = pc_setstand;
+ pc->candrop = pc_candrop;
+
+ pc->jobid2mapid = pc_jobid2mapid; // Skotlex
+ pc->mapid2jobid = pc_mapid2jobid; // Skotlex
+
+ pc->job_name = job_name;
+
+ pc->setinvincibletimer = pc_setinvincibletimer;
+ pc->delinvincibletimer = pc_delinvincibletimer;
+
+ pc->addspiritball = pc_addspiritball;
+ pc->delspiritball = pc_delspiritball;
+ pc->addfame = pc_addfame;
+ pc->famerank = pc_famerank;
+ pc->set_hate_mob = pc_set_hate_mob;
+
+ pc->readdb = pc_readdb;
+ pc->do_init_pc = do_init_pc;
+ pc->do_final_pc = do_final_pc;
+ pc->map_day_timer = map_day_timer; // by [yor]
+ pc->map_night_timer = map_night_timer; // by [yor]
+ // Rental System
+ pc->inventory_rentals = pc_inventory_rentals;
+ pc->inventory_rental_clear = pc_inventory_rental_clear;
+ pc->inventory_rental_add = pc_inventory_rental_add;
+
+ pc->disguise = pc_disguise;
+ pc->isautolooting = pc_isautolooting;
+
+ pc->overheat = pc_overheat;
+
+ pc->banding = pc_banding;
+
+ pc->itemcd_do = pc_itemcd_do;
+
+ pc->load_combo = pc_load_combo;
+
+ pc->add_charm = pc_add_charm;
+ pc->del_charm = pc_del_charm;
+
+ pc->baselevelchanged = pc_baselevelchanged;
+#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP)
+ pc->level_penalty_mod = pc_level_penalty_mod;
+#endif
+}
diff --git a/src/map/pc.h b/src/map/pc.h
index b1fa3e741..442b55965 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -1,17 +1,16 @@
// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-
#ifndef _PC_H_
#define _PC_H_
-
#include "../common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus
#include "../common/ers.h"
#include "../common/timer.h" // INVALID_TIMER
#include "atcommand.h" // AtCommandType
#include "battle.h" // battle_config
+#include "battleground.h"
#include "buyingstore.h" // struct s_buyingstore
-#include "itemdb.h" // MAX_ITEMGROUP
+#include "itemdb.h"
#include "map.h" // RC_MAX
#include "script.h" // struct script_reg, struct script_regstr
#include "searchstore.h" // struct s_search_store_info
@@ -21,11 +20,9 @@
#include "mob.h"
#include "log.h"
#include "pc_groups.h"
-
#define MAX_PC_BONUS 10
#define MAX_PC_SKILL_REQUIRE 5
#define MAX_PC_FEELHATE 3
-
//Equip indexes constants. (eg: sd->equip_index[EQI_AMMO] returns the index
//where the arrows are equipped)
enum equip_index {
@@ -46,7 +43,6 @@ enum equip_index {
EQI_AMMO,
EQI_MAX
};
-
struct weapon_data {
int atkmods[3];
// all the variables except atkmods get zero'ed in each call of status_calc_pc
@@ -62,46 +58,38 @@ struct weapon_data {
int addrace[RC_MAX];
int addrace2[RC2_MAX];
int addsize[3];
-
struct drain_data {
short rate;
short per;
short value;
unsigned type:1;
} hp_drain[RC_MAX], sp_drain[RC_MAX];
-
struct {
short class_, rate;
} add_dmg[MAX_PC_BONUS];
-
struct {
short flag, rate;
unsigned char ele;
} addele2[MAX_PC_BONUS];
};
-
struct s_autospell {
short id, lv, rate, card_id, flag;
bool lock; // bAutoSpellOnSkill: blocks autospell from triggering again, while being executed
};
-
struct s_addeffect {
enum sc_type id;
short rate, arrow_rate;
unsigned char flag;
};
-
struct s_addeffectonskill {
enum sc_type id;
short rate, skill;
unsigned char target;
};
-
struct s_add_drop {
short id, group;
int race, rate;
};
-
struct s_autobonus {
short rate,atk_type;
unsigned int duration;
@@ -109,13 +97,11 @@ struct s_autobonus {
int active;
unsigned short pos;
};
-
enum npc_timeout_type {
NPCT_INPUT = 0,
NPCT_MENU = 1,
NPCT_WAIT = 2,
};
-
struct map_session_data {
struct block_list bl;
struct unit_data ud;
@@ -173,6 +159,9 @@ struct map_session_data {
unsigned int prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not.
unsigned int warping : 1;//states whether you're in the middle of a warp processing
unsigned int permanent_speed : 1; // When 1, speed cannot be changed through status_calc_pc().
+ unsigned int dialog : 1;
+ unsigned int prerefining : 1;
+ unsigned int workinprogress : 3; // 1 = disable skill/item, 2 = disable npc interaction, 3 = disable both
} state;
struct {
unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;
@@ -194,7 +183,6 @@ struct map_session_data {
struct mmo_charstatus status;
struct registry save_reg;
-
struct item_data* inventory_data[MAX_INVENTORY]; // direct pointers to itemdb entries (faster than doing item_id lookups)
short equip_index[EQI_MAX];
unsigned int weight,max_weight;
@@ -204,7 +192,7 @@ struct map_session_data {
unsigned char head_dir; //0: Look forward. 1: Look right, 2: Look left.
unsigned int client_tick;
int npc_id,areanpc_id,npc_shopid,touching_id; //for script follow scriptoid; ,npcid
- int npc_item_flag; //Marks the npc_id with which you can use items during interactions with said npc (see script command enable_itemuse)
+ int npc_item_flag; //Marks the npc_id with which you can change equipments during interactions with said npc (see script command enable_itemuse)
int npc_menu; // internal variable, used in npc menu handling
int npc_amount;
struct script_state *st;
@@ -212,21 +200,16 @@ struct map_session_data {
int npc_timer_id; //For player attached npc timers. [Skotlex]
unsigned int chatID;
time_t idletime;
-
struct{
int npc_id;
unsigned int timeout;
} progressbar; //Progress Bar [Inkfish]
-
struct{
char name[NAME_LENGTH];
} ignore[MAX_IGNORE_LIST];
-
int followtimer; // [MouseJstr]
int followtarget;
-
time_t emotionlasttime; // to limit flood with emotion packets
-
short skillitem,skillitemlv;
uint16 skill_id_old,skill_lv_old;
uint16 skill_id_dance,skill_lv_dance;
@@ -234,7 +217,6 @@ struct map_session_data {
unsigned char blockskill[MAX_SKILL];
int cloneskill_id, reproduceskill_id;
int menuskill_id, menuskill_val, menuskill_val2;
-
int invincible_timer;
unsigned int canlog_tick;
unsigned int canuseitem_tick; // [Skotlex]
@@ -245,17 +227,13 @@ struct map_session_data {
unsigned int cansendmail_tick; // [Mail System Flood Protection]
unsigned int ks_floodprotect_tick; // [Kill Steal Protection]
unsigned int bloodylust_tick; // bloodylust player timer [out/in re full-heal protection]
-
struct {
short nameid;
unsigned int tick;
} item_delay[MAX_ITEMDELAYS]; // [Paradox924X]
-
short weapontype1,weapontype2;
short disguise; // [Valaris]
-
struct weapon_data right_weapon, left_weapon;
-
// here start arrays to be globally zeroed at the beginning of status_calc_pc()
int param_bonus[6],param_equip[6]; //Stores card/equipment bonuses.
int subele[ELE_MAX];
@@ -278,7 +256,6 @@ struct map_session_data {
int expaddrace[RC_MAX];
int ignore_mdef[RC_MAX];
int ignore_def[RC_MAX];
- int itemgrouphealrate[MAX_ITEMGROUP];
short sp_gain_race[RC_MAX];
short sp_gain_race_attack[RC_MAX];
short hp_gain_race_attack[RC_MAX];
@@ -287,7 +264,6 @@ struct map_session_data {
struct s_autospell autospell[15], autospell2[15], autospell3[15];
struct s_addeffect addeff[MAX_PC_BONUS], addeff2[MAX_PC_BONUS];
struct s_addeffectonskill addeff3[MAX_PC_BONUS];
-
struct { //skillatk raises bonus dmg% of skills, skillheal increases heal%, skillblown increases bonus blewcount for some skills.
unsigned short id;
short val;
@@ -337,7 +313,6 @@ struct map_session_data {
int itemhealrate2; // [Epoque] Increase heal rate of all healing items.
int shieldmdef;//royal guard's
unsigned int setitem_hash, setitem_hash2; //Split in 2 because shift operations only work on int ranges. [Skotlex]
-
short splash_range, splash_add_range;
short add_steal_rate;
short add_heal_rate, add_heal2_rate;
@@ -350,26 +325,20 @@ struct map_session_data {
int fixcastrate,varcastrate;
int add_fixcast,add_varcast;
int ematk; // matk bonus from equipment
-// int eatk; // atk bonus from equipment
+ int eatk; // atk bonus from equipment
} bonus;
-
// zeroed vars end here.
-
int castrate,delayrate,hprate,sprate,dsprate;
int hprecov_rate,sprecov_rate;
int matk_rate;
int critical_rate,hit_rate,flee_rate,flee2_rate,def_rate,def2_rate,mdef_rate,mdef2_rate;
-
int itemid;
short itemindex; //Used item's index in sd->inventory [Skotlex]
-
short catch_target_class; // pet catching, stores a pet class to catch (short now) [zzo]
-
short spiritball, spiritball_old;
int spirit_timer[MAX_SPIRITBALL];
- short talisman[ELE_POISON+1]; // There are actually 5 talisman Fire, Ice, Wind, Earth & Poison maybe because its color violet.
- int talisman_timer[ELE_POISON+1][10];
-
+ short charm[ELE_POISON+1]; // There are actually 5 charm Fire, Ice, Wind, Earth & Poison maybe because its color violet.
+ int charm_timer[ELE_POISON+1][10];
unsigned char potion_success_counter; //Potion successes in row counter
unsigned char mission_count; //Stores the bounty kill count for TK_MISSION
short mission_mobid; //Stores the target mob_id for TK_MISSION
@@ -377,10 +346,8 @@ struct map_session_data {
int devotion[5]; //Stores the account IDs of chars devoted to.
int reg_num; //Number of registries (type numeric)
int regstr_num; //Number of registries (type string)
-
struct script_reg *reg;
struct script_regstr *regstr;
-
int trade_partner;
struct {
struct {
@@ -388,7 +355,6 @@ struct map_session_data {
} item[10];
int zeny, weight;
} deal;
-
bool party_creating; // whether the char is requesting party creation
bool party_joining; // whether the char is accepting party invitation
int party_invite, party_invite_account; // for handling party invitation (holds party id and account id)
@@ -399,16 +365,13 @@ struct map_session_data {
short guild_x,guild_y; // For guildmate position display. [Skotlex] should be short [zzo]
int guildspy; // [Syrus22]
int partyspy; // [Syrus22]
-
unsigned int vended_id;
unsigned int vender_id;
int vend_num;
char message[MESSAGE_SIZE];
struct s_vending vending[MAX_VENDING];
-
unsigned int buyer_id; // uid of open buying store
struct s_buyingstore buyingstore;
-
struct s_search_store_info searchstore;
struct pet_data *pd;
@@ -419,7 +382,7 @@ struct map_session_data {
struct{
int m; //-1 - none, other: map index corresponding to map name.
unsigned short index; //map index
- }feel_map[3];// 0 - Sun; 1 - Moon; 2 - Stars
+ } feel_map[3];// 0 - Sun; 1 - Moon; 2 - Stars
short hate_mob[3];
int pvp_timer;
@@ -519,6 +482,23 @@ struct map_session_data {
struct sc_display_entry **sc_display;
unsigned char sc_display_count;
+ short *instance;
+ unsigned short instances;
+
+ /* Possible Thanks to Yommy~! */
+ struct {
+ unsigned int ready : 1;/* did he accept the 'match is about to start, enter' dialog? */
+ unsigned int client_has_bg_data : 1; /* flags whether the client has the "in queue" window (aka the client knows it is in a queue) */
+ struct bg_arena *arena;
+ enum bg_queue_types type;
+ } bg_queue;
+
+ int *queues;
+ unsigned int queues_count;
+
+ /* Made Possible Thanks to Yommy~! */
+ unsigned int cryptKey;
+
// temporary debugging of bug #3504
const char* delunit_prevfile;
int delunit_prevline;
@@ -622,7 +602,7 @@ enum equip_pos {
#define pc_cant_act(sd) ( (sd)->npc_id || (sd)->state.vending || (sd)->state.buyingstore || (sd)->chatID || ((sd)->sc.opt1 && (sd)->sc.opt1 != OPT1_BURNING) || (sd)->state.trading || (sd)->state.storage_flag || (sd)->state.prevend )
/* equals pc_cant_act except it doesn't check for chat rooms */
-#define pc_cant_act2(sd) ( (sd)->npc_id || (sd)->state.vending || (sd)->state.buyingstore || ((sd)->sc.opt1 && (sd)->sc.opt1 != OPT1_BURNING) || (sd)->state.trading || (sd)->state.storage_flag || (sd)->state.prevend )
+#define pc_cant_act2(sd) ( (sd)->npc_id || (sd)->state.buyingstore || ((sd)->sc.opt1 && (sd)->sc.opt1 != OPT1_BURNING) || (sd)->state.trading || (sd)->state.storage_flag || (sd)->state.prevend )
#define pc_setdir(sd,b,h) ( (sd)->ud.dir = (b) ,(sd)->head_dir = (h) )
#define pc_setchatid(sd,n) ( (sd)->chatID = n )
@@ -674,13 +654,13 @@ enum equip_pos {
// clientside display macros (values to the left/right of the "+")
#ifdef RENEWAL
#define pc_leftside_atk(sd) ((sd)->battle_status.batk)
- #define pc_rightside_atk(sd) ((sd)->battle_status.rhw.atk + (sd)->battle_status.lhw.atk + (sd)->battle_status.rhw.atk2 + (sd)->battle_status.lhw.atk2)
+ #define pc_rightside_atk(sd) ((sd)->battle_status.rhw.atk + (sd)->battle_status.lhw.atk + (sd)->battle_status.rhw.atk2 + (sd)->battle_status.lhw.atk2 + (sd)->bonus.eatk )
#define pc_leftside_def(sd) ((sd)->battle_status.def2)
#define pc_rightside_def(sd) ((sd)->battle_status.def)
#define pc_leftside_mdef(sd) ((sd)->battle_status.mdef2)
#define pc_rightside_mdef(sd) ((sd)->battle_status.mdef)
#define pc_leftside_matk(sd) (status_base_matk(status_get_status_data(&(sd)->bl), (sd)->status.base_level))
-#define pc_rightside_matk(sd) ((sd)->battle_status.rhw.matk+(sd)->bonus.ematk)
+#define pc_rightside_matk(sd) ((sd)->battle_status.rhw.matk+(sd)->battle_status.lhw.matk+(sd)->bonus.ematk)
#else
#define pc_leftside_atk(sd) ((sd)->battle_status.batk + (sd)->battle_status.rhw.atk + (sd)->battle_status.lhw.atk)
#define pc_rightside_atk(sd) ((sd)->battle_status.rhw.atk2 + (sd)->battle_status.lhw.atk2)
@@ -702,189 +682,26 @@ enum equip_pos {
)
#endif
-int pc_class2idx(int class_);
-int pc_get_group_level(struct map_session_data *sd);
#define pc_get_group_id(sd) ( (sd)->group_id )
-int pc_getrefinebonus(int lv,int type);
-bool pc_can_give_items(struct map_session_data *sd);
-bool pc_can_use_command(struct map_session_data *sd, const char *command);
#define pc_has_permission(sd, permission) ( ((sd)->permissions&permission) != 0 )
#define pc_should_log_commands(sd) ( (sd)->group_log_command != false )
-int pc_setrestartvalue(struct map_session_data *sd,int type);
-int pc_makesavestatus(struct map_session_data *);
-void pc_respawn(struct map_session_data* sd, clr_type clrtype);
-int pc_setnewpc(struct map_session_data*,int,int,int,unsigned int,int,int);
-bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers);
-void pc_authfail(struct map_session_data *);
-int pc_reg_received(struct map_session_data *sd);
-
-int pc_isequip(struct map_session_data *sd,int n);
-int pc_equippoint(struct map_session_data *sd,int n);
-int pc_setinventorydata(struct map_session_data *sd);
-
-int pc_checkskill(struct map_session_data *sd,uint16 skill_id);
-int pc_checkskill2(struct map_session_data *sd,uint16 index);
-int pc_checkallowskill(struct map_session_data *sd);
-int pc_checkequip(struct map_session_data *sd,int pos);
-
-int pc_calc_skilltree(struct map_session_data *sd);
-int pc_calc_skilltree_normalize_job(struct map_session_data *sd);
-int pc_clean_skilltree(struct map_session_data *sd);
-
#define pc_checkoverhp(sd) ((sd)->battle_status.hp == (sd)->battle_status.max_hp)
#define pc_checkoversp(sd) ((sd)->battle_status.sp == (sd)->battle_status.max_sp)
-int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y, clr_type clrtype);
-int pc_setsavepoint(struct map_session_data*,short,int,int);
-int pc_randomwarp(struct map_session_data *sd,clr_type type);
-int pc_memo(struct map_session_data* sd, int pos);
-
-int pc_checkadditem(struct map_session_data*,int,int);
-int pc_inventoryblank(struct map_session_data*);
-int pc_search_inventory(struct map_session_data *sd,int item_id);
-int pc_payzeny(struct map_session_data*,int, enum e_log_pick_type type, struct map_session_data*);
-int pc_additem(struct map_session_data*,struct item*,int,e_log_pick_type);
-int pc_getzeny(struct map_session_data*,int, enum e_log_pick_type, struct map_session_data*);
-int pc_delitem(struct map_session_data*,int,int,int,short,e_log_pick_type);
-
-// Special Shop System
-int pc_paycash(struct map_session_data *sd, int price, int points);
-int pc_getcash(struct map_session_data *sd, int cash, int points);
-
-int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amount,e_log_pick_type log_type);
-int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,e_log_pick_type log_type);
-int pc_putitemtocart(struct map_session_data *sd,int idx,int amount);
-int pc_getitemfromcart(struct map_session_data *sd,int idx,int amount);
-int pc_cartitem_amount(struct map_session_data *sd,int idx,int amount);
-
-int pc_takeitem(struct map_session_data*,struct flooritem_data*);
-int pc_dropitem(struct map_session_data*,int,int);
-
-bool pc_isequipped(struct map_session_data *sd, int nameid);
-bool pc_can_Adopt(struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd );
-bool pc_adoption(struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd);
-
-int pc_updateweightstatus(struct map_session_data *sd);
-
-int pc_addautobonus(struct s_autobonus *bonus,char max,const char *script,short rate,unsigned int dur,short atk_type,const char *o_script,unsigned short pos,bool onskill);
-int pc_exeautobonus(struct map_session_data* sd,struct s_autobonus *bonus);
-int pc_endautobonus(int tid, unsigned int tick, int id, intptr_t data);
-int pc_delautobonus(struct map_session_data* sd,struct s_autobonus *bonus,char max,bool restore);
-
-int pc_bonus(struct map_session_data*,int,int);
-int pc_bonus2(struct map_session_data *sd,int,int,int);
-int pc_bonus3(struct map_session_data *sd,int,int,int,int);
-int pc_bonus4(struct map_session_data *sd,int,int,int,int,int);
-int pc_bonus5(struct map_session_data *sd,int,int,int,int,int,int);
-int pc_skill(struct map_session_data* sd, int id, int level, int flag);
-
-int pc_insert_card(struct map_session_data *sd,int idx_card,int idx_equip);
-
-int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skill_lv);
-int pc_steal_coin(struct map_session_data *sd,struct block_list *bl);
-
-int pc_modifybuyvalue(struct map_session_data*,int);
-int pc_modifysellvalue(struct map_session_data*,int);
-
-int pc_follow(struct map_session_data*, int); // [MouseJstr]
-int pc_stop_following(struct map_session_data*);
-
-unsigned int pc_maxbaselv(struct map_session_data *sd);
-unsigned int pc_maxjoblv(struct map_session_data *sd);
-int pc_checkbaselevelup(struct map_session_data *sd);
-int pc_checkjoblevelup(struct map_session_data *sd);
-int pc_gainexp(struct map_session_data*,struct block_list*,unsigned int,unsigned int, bool);
-unsigned int pc_nextbaseexp(struct map_session_data *);
-unsigned int pc_thisbaseexp(struct map_session_data *);
-unsigned int pc_nextjobexp(struct map_session_data *);
-unsigned int pc_thisjobexp(struct map_session_data *);
-int pc_gets_status_point(int);
-int pc_need_status_point(struct map_session_data *,int,int);
-int pc_statusup(struct map_session_data*,int);
-int pc_statusup2(struct map_session_data*,int,int);
-int pc_skillup(struct map_session_data*,uint16 skill_id);
-int pc_allskillup(struct map_session_data*);
-int pc_resetlvl(struct map_session_data*,int type);
-int pc_resetstate(struct map_session_data*);
-int pc_resetskill(struct map_session_data*, int);
-int pc_resetfeel(struct map_session_data*);
-int pc_resethate(struct map_session_data*);
-int pc_equipitem(struct map_session_data*,int,int);
-int pc_unequipitem(struct map_session_data*,int,int);
-int pc_checkitem(struct map_session_data*);
-int pc_useitem(struct map_session_data*,int);
-
-int pc_skillatk_bonus(struct map_session_data *sd, uint16 skill_id);
-int pc_skillheal_bonus(struct map_session_data *sd, uint16 skill_id);
-int pc_skillheal2_bonus(struct map_session_data *sd, uint16 skill_id);
-
-void pc_damage(struct map_session_data *sd,struct block_list *src,unsigned int hp, unsigned int sp);
-int pc_dead(struct map_session_data *sd,struct block_list *src);
-void pc_revive(struct map_session_data *sd,unsigned int hp, unsigned int sp);
-void pc_heal(struct map_session_data *sd,unsigned int hp,unsigned int sp, int type);
-int pc_itemheal(struct map_session_data *sd,int itemid, int hp,int sp);
-int pc_percentheal(struct map_session_data *sd,int,int);
-int pc_jobchange(struct map_session_data *,int, int);
-int pc_setoption(struct map_session_data *,int);
-int pc_setcart(struct map_session_data* sd, int type);
-int pc_setfalcon(struct map_session_data* sd, int flag);
-int pc_setriding(struct map_session_data* sd, int flag);
-int pc_setmadogear(struct map_session_data* sd, int flag);
-int pc_changelook(struct map_session_data *,int,int);
-int pc_equiplookall(struct map_session_data *sd);
-
-int pc_readparam(struct map_session_data*,int);
-int pc_setparam(struct map_session_data*,int,int);
-int pc_readreg(struct map_session_data*,int);
-int pc_setreg(struct map_session_data*,int,int);
-char *pc_readregstr(struct map_session_data *sd,int reg);
-int pc_setregstr(struct map_session_data *sd,int reg,const char *str);
-
-#define pc_readglobalreg(sd,reg) pc_readregistry(sd,reg,3)
-#define pc_setglobalreg(sd,reg,val) pc_setregistry(sd,reg,val,3)
-#define pc_readglobalreg_str(sd,reg) pc_readregistry_str(sd,reg,3)
-#define pc_setglobalreg_str(sd,reg,val) pc_setregistry_str(sd,reg,val,3)
-#define pc_readaccountreg(sd,reg) pc_readregistry(sd,reg,2)
-#define pc_setaccountreg(sd,reg,val) pc_setregistry(sd,reg,val,2)
-#define pc_readaccountregstr(sd,reg) pc_readregistry_str(sd,reg,2)
-#define pc_setaccountregstr(sd,reg,val) pc_setregistry_str(sd,reg,val,2)
-#define pc_readaccountreg2(sd,reg) pc_readregistry(sd,reg,1)
-#define pc_setaccountreg2(sd,reg,val) pc_setregistry(sd,reg,val,1)
-#define pc_readaccountreg2str(sd,reg) pc_readregistry_str(sd,reg,1)
-#define pc_setaccountreg2str(sd,reg,val) pc_setregistry_str(sd,reg,val,1)
-int pc_readregistry(struct map_session_data*,const char*,int);
-int pc_setregistry(struct map_session_data*,const char*,int,int);
-char *pc_readregistry_str(struct map_session_data*,const char*,int);
-int pc_setregistry_str(struct map_session_data*,const char*,const char*,int);
-
-int pc_addeventtimer(struct map_session_data *sd,int tick,const char *name);
-int pc_deleventtimer(struct map_session_data *sd,const char *name);
-int pc_cleareventtimer(struct map_session_data *sd);
-int pc_addeventtimercount(struct map_session_data *sd,const char *name,int tick);
-
-int pc_calc_pvprank(struct map_session_data *sd);
-int pc_calc_pvprank_timer(int tid, unsigned int tick, int id, intptr_t data);
-
-int pc_ismarried(struct map_session_data *sd);
-int pc_marriage(struct map_session_data *sd,struct map_session_data *dstsd);
-int pc_divorce(struct map_session_data *sd);
-struct map_session_data *pc_get_partner(struct map_session_data *sd);
-struct map_session_data *pc_get_father(struct map_session_data *sd);
-struct map_session_data *pc_get_mother(struct map_session_data *sd);
-struct map_session_data *pc_get_child(struct map_session_data *sd);
-
-void pc_bleeding (struct map_session_data *sd, unsigned int diff_tick);
-void pc_regen (struct map_session_data *sd, unsigned int diff_tick);
-
-void pc_setstand(struct map_session_data *sd);
-int pc_candrop(struct map_session_data *sd,struct item *item);
-
-int pc_jobid2mapid(unsigned short b_class); // Skotlex
-int pc_mapid2jobid(unsigned short class_, int sex); // Skotlex
-
-const char * job_name(int class_);
+#define pc_readglobalreg(sd,reg) pc->readregistry(sd,reg,3)
+#define pc_setglobalreg(sd,reg,val) pc->setregistry(sd,reg,val,3)
+#define pc_readglobalreg_str(sd,reg) pc->readregistry_str(sd,reg,3)
+#define pc_setglobalreg_str(sd,reg,val) pc->setregistry_str(sd,reg,val,3)
+#define pc_readaccountreg(sd,reg) pc->readregistry(sd,reg,2)
+#define pc_setaccountreg(sd,reg,val) pc->setregistry(sd,reg,val,2)
+#define pc_readaccountregstr(sd,reg) pc->readregistry_str(sd,reg,2)
+#define pc_setaccountregstr(sd,reg,val) pc->setregistry_str(sd,reg,val,2)
+#define pc_readaccountreg2(sd,reg) pc->readregistry(sd,reg,1)
+#define pc_setaccountreg2(sd,reg,val) pc->setregistry(sd,reg,val,1)
+#define pc_readaccountreg2str(sd,reg) pc->readregistry_str(sd,reg,1)
+#define pc_setaccountreg2str(sd,reg,val) pc->setregistry_str(sd,reg,val,1)
struct skill_tree_entry {
short id;
@@ -897,6 +714,7 @@ struct skill_tree_entry {
unsigned char lv;
} need[MAX_PC_SKILL_REQUIRE];
}; // Celest
+
extern struct skill_tree_entry skill_tree[CLASS_COUNT][MAX_SKILL_TREE];
struct sg_data {
@@ -907,55 +725,236 @@ struct sg_data {
char hate_var[NAME_LENGTH];
int (*day_func)(void);
};
-extern const struct sg_data sg_info[MAX_PC_FEELHATE];
-
-void pc_setinvincibletimer(struct map_session_data* sd, int val);
-void pc_delinvincibletimer(struct map_session_data* sd);
-int pc_addspiritball(struct map_session_data *sd,int,int);
-int pc_delspiritball(struct map_session_data *sd,int,int);
-void pc_addfame(struct map_session_data *sd,int count);
-unsigned char pc_famerank(int char_id, int job);
-int pc_set_hate_mob(struct map_session_data *sd, int pos, struct block_list *bl);
+extern const struct sg_data sg_info[MAX_PC_FEELHATE];
extern struct fame_list smith_fame_list[MAX_FAME_LIST];
extern struct fame_list chemist_fame_list[MAX_FAME_LIST];
extern struct fame_list taekwon_fame_list[MAX_FAME_LIST];
-int pc_readdb(void);
-int do_init_pc(void);
-void do_final_pc(void);
-
enum {ADDITEM_EXIST,ADDITEM_NEW,ADDITEM_OVERAMOUNT};
-// timer for night.day
-extern int day_timer_tid;
-extern int night_timer_tid;
-int map_day_timer(int tid, unsigned int tick, int id, intptr_t data); // by [yor]
-int map_night_timer(int tid, unsigned int tick, int id, intptr_t data); // by [yor]
-
-// Rental System
-void pc_inventory_rentals(struct map_session_data *sd);
-int pc_inventory_rental_clear(struct map_session_data *sd);
-void pc_inventory_rental_add(struct map_session_data *sd, int seconds);
-
-int pc_disguise(struct map_session_data *sd, int class_);
-bool pc_isautolooting(struct map_session_data *sd, int nameid);
-
-void pc_overheat(struct map_session_data *sd, int val);
-
-int pc_banding(struct map_session_data *sd, uint16 skill_lv);
-
-void pc_itemcd_do(struct map_session_data *sd, bool load);
-
-int pc_load_combo(struct map_session_data *sd);
+#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP)
+#endif
+/*=====================================
+* Interface : pc.h
+* Generated by HerculesInterfaceMaker
+* created by Susu
+*-------------------------------------*/
+struct pc_interface {
+
+ /* vars */
+ // timer for night.day
+ int day_timer_tid;
+ int night_timer_tid;
+
+ /* funcs */
+
+ int (*class2idx) (int class_);
+ int (*get_group_level) (struct map_session_data *sd);
+ int (*getrefinebonus) (int lv,int type);
+ bool (*can_give_items) (struct map_session_data *sd);
+
+ bool (*can_use_command) (struct map_session_data *sd, const char *command);
+
+ int (*setrestartvalue) (struct map_session_data *sd,int type);
+ int (*makesavestatus) (struct map_session_data *);
+ void (*respawn) (struct map_session_data* sd, clr_type clrtype);
+ int (*setnewpc) (struct map_session_data*,int,int,int,unsigned int,int,int);
+ bool (*authok) (struct map_session_data *sd, int login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers);
+ void (*authfail) (struct map_session_data *);
+ int (*reg_received) (struct map_session_data *sd);
+
+ int (*isequip) (struct map_session_data *sd,int n);
+ int (*equippoint) (struct map_session_data *sd,int n);
+ int (*setinventorydata) (struct map_session_data *sd);
+
+ int (*checkskill) (struct map_session_data *sd,uint16 skill_id);
+ int (*checkskill2) (struct map_session_data *sd,uint16 index);
+ int (*checkallowskill) (struct map_session_data *sd);
+ int (*checkequip) (struct map_session_data *sd,int pos);
+
+ int (*calc_skilltree) (struct map_session_data *sd);
+ int (*calc_skilltree_normalize_job) (struct map_session_data *sd);
+ int (*clean_skilltree) (struct map_session_data *sd);
+
+ int (*setpos) (struct map_session_data* sd, unsigned short mapindex, int x, int y, clr_type clrtype);
+ int (*setsavepoint) (struct map_session_data*,short,int,int);
+ int (*randomwarp) (struct map_session_data *sd,clr_type type);
+ int (*memo) (struct map_session_data* sd, int pos);
+
+ int (*checkadditem) (struct map_session_data*,int,int);
+ int (*inventoryblank) (struct map_session_data*);
+ int (*search_inventory) (struct map_session_data *sd,int item_id);
+ int (*payzeny) (struct map_session_data*,int, enum e_log_pick_type type, struct map_session_data*);
+ int (*additem) (struct map_session_data*,struct item*,int,e_log_pick_type);
+ int (*getzeny) (struct map_session_data*,int, enum e_log_pick_type, struct map_session_data*);
+ int (*delitem) (struct map_session_data*,int,int,int,short,e_log_pick_type);
+ // Special Shop System
+ int (*paycash) (struct map_session_data *sd, int price, int points);
+ int (*getcash) (struct map_session_data *sd, int cash, int points);
+
+ int (*cart_additem) (struct map_session_data *sd,struct item *item_data,int amount,e_log_pick_type log_type);
+ int (*cart_delitem) (struct map_session_data *sd,int n,int amount,int type,e_log_pick_type log_type);
+ int (*putitemtocart) (struct map_session_data *sd,int idx,int amount);
+ int (*getitemfromcart) (struct map_session_data *sd,int idx,int amount);
+ int (*cartitem_amount) (struct map_session_data *sd,int idx,int amount);
+
+ int (*takeitem) (struct map_session_data*,struct flooritem_data*);
+ int (*dropitem) (struct map_session_data*,int,int);
+
+ bool (*isequipped) (struct map_session_data *sd, int nameid);
+ bool (*can_Adopt) (struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd);
+ bool (*adoption) (struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd);
+
+ int (*updateweightstatus) (struct map_session_data *sd);
+
+ int (*addautobonus) (struct s_autobonus *bonus,char max,const char *script,short rate,unsigned int dur,short atk_type,const char *o_script,unsigned short pos,bool onskill);
+ int (*exeautobonus) (struct map_session_data* sd,struct s_autobonus *bonus);
+ int (*endautobonus) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*delautobonus) (struct map_session_data* sd,struct s_autobonus *bonus,char max,bool restore);
+
+ int (*bonus) (struct map_session_data*,int,int);
+ int (*bonus2) (struct map_session_data *sd,int,int,int);
+ int (*bonus3) (struct map_session_data *sd,int,int,int,int);
+ int (*bonus4) (struct map_session_data *sd,int,int,int,int,int);
+ int (*bonus5) (struct map_session_data *sd,int,int,int,int,int,int);
+ int (*skill) (struct map_session_data* sd, int id, int level, int flag);
+
+ int (*insert_card) (struct map_session_data *sd,int idx_card,int idx_equip);
+
+ int (*steal_item) (struct map_session_data *sd,struct block_list *bl, uint16 skill_lv);
+ int (*steal_coin) (struct map_session_data *sd,struct block_list *bl);
+
+ int (*modifybuyvalue) (struct map_session_data*,int);
+ int (*modifysellvalue) (struct map_session_data*,int);
+
+ int (*follow) (struct map_session_data*, int); // [MouseJstr]
+ int (*stop_following) (struct map_session_data*);
+
+ unsigned int (*maxbaselv) (struct map_session_data *sd);
+ unsigned int (*maxjoblv) (struct map_session_data *sd);
+ int (*checkbaselevelup) (struct map_session_data *sd);
+ int (*checkjoblevelup) (struct map_session_data *sd);
+ int (*gainexp) (struct map_session_data*,struct block_list*,unsigned int,unsigned int, bool);
+ unsigned int (*nextbaseexp) (struct map_session_data *);
+ unsigned int (*thisbaseexp) (struct map_session_data *);
+ unsigned int (*nextjobexp) (struct map_session_data *);
+ unsigned int (*thisjobexp) (struct map_session_data *);
+ int (*gets_status_point) (int);
+ int (*need_status_point) (struct map_session_data *,int,int);
+ int (*statusup) (struct map_session_data*,int);
+ int (*statusup2) (struct map_session_data*,int,int);
+ int (*skillup) (struct map_session_data*,uint16 skill_id);
+ int (*allskillup) (struct map_session_data*);
+ int (*resetlvl) (struct map_session_data*,int type);
+ int (*resetstate) (struct map_session_data*);
+ int (*resetskill) (struct map_session_data*, int);
+ int (*resetfeel) (struct map_session_data*);
+ int (*resethate) (struct map_session_data*);
+ int (*equipitem) (struct map_session_data*,int,int);
+ int (*unequipitem) (struct map_session_data*,int,int);
+ int (*checkitem) (struct map_session_data*);
+ int (*useitem) (struct map_session_data*,int);
+
+ int (*skillatk_bonus) (struct map_session_data *sd, uint16 skill_id);
+ int (*skillheal_bonus) (struct map_session_data *sd, uint16 skill_id);
+ int (*skillheal2_bonus) (struct map_session_data *sd, uint16 skill_id);
+
+ void (*damage) (struct map_session_data *sd,struct block_list *src,unsigned int hp, unsigned int sp);
+ int (*dead) (struct map_session_data *sd,struct block_list *src);
+ void (*revive) (struct map_session_data *sd,unsigned int hp, unsigned int sp);
+ void (*heal) (struct map_session_data *sd,unsigned int hp,unsigned int sp, int type);
+ int (*itemheal) (struct map_session_data *sd,int itemid, int hp,int sp);
+ int (*percentheal) (struct map_session_data *sd,int,int);
+ int (*jobchange) (struct map_session_data *,int, int);
+ int (*setoption) (struct map_session_data *,int);
+ int (*setcart) (struct map_session_data* sd, int type);
+ int (*setfalcon) (struct map_session_data* sd, int flag);
+ int (*setriding) (struct map_session_data* sd, int flag);
+ int (*setmadogear) (struct map_session_data* sd, int flag);
+ int (*changelook) (struct map_session_data *,int,int);
+ int (*equiplookall) (struct map_session_data *sd);
+
+ int (*readparam) (struct map_session_data*,int);
+ int (*setparam) (struct map_session_data*,int,int);
+ int (*readreg) (struct map_session_data*,int);
+ int (*setreg) (struct map_session_data*,int,int);
+ char * (*readregstr) (struct map_session_data *sd,int reg);
+ int (*setregstr) (struct map_session_data *sd,int reg,const char *str);
+ int (*readregistry) (struct map_session_data*,const char*,int);
+ int (*setregistry) (struct map_session_data*,const char*,int,int);
+ char * (*readregistry_str) (struct map_session_data*,const char*,int);
+ int (*setregistry_str) (struct map_session_data*,const char*,const char*,int);
+
+ int (*addeventtimer) (struct map_session_data *sd,int tick,const char *name);
+ int (*deleventtimer) (struct map_session_data *sd,const char *name);
+ int (*cleareventtimer) (struct map_session_data *sd);
+ int (*addeventtimercount) (struct map_session_data *sd,const char *name,int tick);
+
+ int (*calc_pvprank) (struct map_session_data *sd);
+ int (*calc_pvprank_timer) (int tid, unsigned int tick, int id, intptr_t data);
+
+ int (*ismarried) (struct map_session_data *sd);
+ int (*marriage) (struct map_session_data *sd,struct map_session_data *dstsd);
+ int (*divorce) (struct map_session_data *sd);
+ struct map_session_data * (*get_partner) (struct map_session_data *sd);
+ struct map_session_data * (*get_father) (struct map_session_data *sd);
+ struct map_session_data * (*get_mother) (struct map_session_data *sd);
+ struct map_session_data * (*get_child) (struct map_session_data *sd);
+
+ void (*bleeding) (struct map_session_data *sd, unsigned int diff_tick);
+ void (*regen) (struct map_session_data *sd, unsigned int diff_tick);
+
+ void (*setstand) (struct map_session_data *sd);
+ int (*candrop) (struct map_session_data *sd,struct item *item);
+
+ int (*jobid2mapid) (unsigned short b_class); // Skotlex
+ int (*mapid2jobid) (unsigned short class_, int sex); // Skotlex
+
+ const char * (*job_name) (int class_);
+
+ void (*setinvincibletimer) (struct map_session_data* sd, int val);
+ void (*delinvincibletimer) (struct map_session_data* sd);
+
+ int (*addspiritball) (struct map_session_data *sd,int,int);
+ int (*delspiritball) (struct map_session_data *sd,int,int);
+ void (*addfame) (struct map_session_data *sd,int count);
+ unsigned char (*famerank) (int char_id, int job);
+ int (*set_hate_mob) (struct map_session_data *sd, int pos, struct block_list *bl);
+
+ int (*readdb) (void);
+ int (*do_init_pc) (void);
+ void (*do_final_pc) (void);
+ int (*map_day_timer) (int tid, unsigned int tick, int id, intptr_t data); // by [yor]
+ int (*map_night_timer) (int tid, unsigned int tick, int id, intptr_t data); // by [yor]
+ // Rental System
+ void (*inventory_rentals) (struct map_session_data *sd);
+ int (*inventory_rental_clear) (struct map_session_data *sd);
+ void (*inventory_rental_add) (struct map_session_data *sd, int seconds);
+
+ int (*disguise) (struct map_session_data *sd, int class_);
+ bool (*isautolooting) (struct map_session_data *sd, int nameid);
+
+ void (*overheat) (struct map_session_data *sd, int val);
+
+ int (*banding) (struct map_session_data *sd, uint16 skill_lv);
+
+ void (*itemcd_do) (struct map_session_data *sd, bool load);
+
+ int (*load_combo) (struct map_session_data *sd);
+
+ int (*add_charm) (struct map_session_data *sd,int interval,int max,int type);
+ int (*del_charm) (struct map_session_data *sd,int count,int type);
+
+ void (*baselevelchanged) (struct map_session_data *sd);
+#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP)
+ int (*level_penalty_mod) (struct map_session_data *sd, struct mob_data * md, int type);
+#endif
+} pc_s;
-int pc_add_talisman(struct map_session_data *sd,int interval,int max,int type);
-int pc_del_talisman(struct map_session_data *sd,int count,int type);
+struct pc_interface *pc;
-void pc_baselevelchanged(struct map_session_data *sd);
+void pc_defaults(void);
-#if defined(RENEWAL_DROP) || defined(RENEWAL_EXP)
-int pc_level_penalty_mod(struct map_session_data *sd, struct mob_data * md, int type);
-#endif
#endif /* _PC_H_ */
diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c
index 1a83c8b63..f1f69f7cb 100644
--- a/src/map/pc_groups.c
+++ b/src/map/pc_groups.c
@@ -414,6 +414,19 @@ int pc_group_id2level(int group_id)
return 0;
return group->level;
}
+/**
+ * Group ID -> group level lookup.
+ * @param group id
+ * @return group index
+ * @public
+ */
+int pc_group_id2idx(int group_id)
+{
+ GroupSettings *group = id2group(group_id);
+ if (group == NULL)
+ return 0;
+ return group->group_pos;
+}
/**
* Initialize PC Groups: allocate DBMaps and read config.
diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h
index 26cd8f39f..0ce7b0d51 100644
--- a/src/map/pc_groups.h
+++ b/src/map/pc_groups.h
@@ -15,6 +15,7 @@ bool pc_group_has_permission(int group_id, int permission);
bool pc_group_should_log_commands(int group_id);
const char* pc_group_id2name(int group_id);
int pc_group_id2level(int group_id);
+int pc_group_id2idx(int group_id);
void pc_group_pc_load(struct map_session_data *);
void do_init_pc_groups(void);
diff --git a/src/map/pet.c b/src/map/pet.c
index c85092a01..8ed88c46c 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -76,7 +76,7 @@ int pet_create_egg(struct map_session_data *sd, int item_id)
{
int pet_id = search_petDB_index(item_id, PET_EGG);
if (pet_id < 0) return 0; //No pet egg here.
- if (!pc_inventoryblank(sd)) return 0; // Inventory full
+ if (!pc->inventoryblank(sd)) return 0; // Inventory full
sd->catch_target_class = pet_db[pet_id].class_;
intif_create_pet(sd->status.account_id, sd->status.char_id,
(short)pet_db[pet_id].class_,
@@ -106,7 +106,7 @@ int pet_attackskill(struct pet_data *pd, int target_id)
(battle_config.pet_equip_required && !pd->pet.equip))
return 0;
- if (DIFF_TICK(pd->ud.canact_tick, gettick()) > 0)
+ if (DIFF_TICK(pd->ud.canact_tick, iTimer->gettick()) > 0)
return 0;
if (rnd()%100 < (pd->a_skill->rate +pd->pet.intimate*pd->a_skill->bonusrate/1000))
@@ -114,7 +114,7 @@ int pet_attackskill(struct pet_data *pd, int target_id)
int inf;
struct block_list *bl;
- bl=map_id2bl(target_id);
+ bl=iMap->id2bl(target_id);
if(bl == NULL || pd->bl.m != bl->m || bl->prev == NULL || status_isdead(bl) ||
!check_distance_bl(&pd->bl, bl, pd->db->range3))
return 0;
@@ -187,7 +187,7 @@ int pet_sc_check(struct map_session_data *sd, int type)
|| pd->recovery->type != type )
return 1;
- pd->recovery->timer = add_timer(gettick()+pd->recovery->delay*1000,pet_recovery_timer,sd->bl.id,0);
+ pd->recovery->timer = iTimer->add_timer(iTimer->gettick()+pd->recovery->delay*1000,pet_recovery_timer,sd->bl.id,0);
return 0;
}
@@ -198,7 +198,7 @@ static int pet_hungry(int tid, unsigned int tick, int id, intptr_t data)
struct pet_data *pd;
int interval;
- sd=map_id2sd(id);
+ sd=iMap->id2sd(id);
if(!sd)
return 1;
@@ -237,7 +237,7 @@ static int pet_hungry(int tid, unsigned int tick, int id, intptr_t data)
interval = pd->petDB->hungry_delay;
if(interval <= 0)
interval = 1;
- pd->pet_hungry_timer = add_timer(tick+interval,pet_hungry,sd->bl.id,0);
+ pd->pet_hungry_timer = iTimer->add_timer(tick+interval,pet_hungry,sd->bl.id,0);
return 0;
}
@@ -267,7 +267,7 @@ int pet_hungry_timer_delete(struct pet_data *pd)
{
nullpo_ret(pd);
if(pd->pet_hungry_timer != INVALID_TIMER) {
- delete_timer(pd->pet_hungry_timer,pet_hungry);
+ iTimer->delete_timer(pd->pet_hungry_timer,pet_hungry);
pd->pet_hungry_timer = INVALID_TIMER;
}
@@ -304,9 +304,9 @@ static int pet_return_egg(struct map_session_data *sd, struct pet_data *pd)
tmp_item.card[1] = GetWord(pd->pet.pet_id,0);
tmp_item.card[2] = GetWord(pd->pet.pet_id,1);
tmp_item.card[3] = pd->pet.rename_flag;
- if((flag = pc_additem(sd,&tmp_item,1,LOG_TYPE_OTHER))) {
+ if((flag = pc->additem(sd,&tmp_item,1,LOG_TYPE_OTHER))) {
clif->additem(sd,0,0,flag);
- map_addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ iMap->addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
pd->pet.incuvate = 1;
unit_free(&pd->bl,CLR_OUTSIGHT);
@@ -366,10 +366,10 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *pet)
pd->bl.x = pd->ud.to_x;
pd->bl.y = pd->ud.to_y;
- map_addiddb(&pd->bl);
+ iMap->addiddb(&pd->bl);
status_calc_pet(pd,1);
- pd->last_thinktime = gettick();
+ pd->last_thinktime = iTimer->gettick();
pd->state.skillbonus = 0;
if( battle_config.pet_status_support )
run_script(pet_db[i].pet_script,0,sd->bl.id,0);
@@ -382,7 +382,7 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *pet)
interval = pd->petDB->hungry_delay;
if( interval <= 0 )
interval = 1;
- pd->pet_hungry_timer = add_timer(gettick() + interval, pet_hungry, sd->bl.id, 0);
+ pd->pet_hungry_timer = iTimer->add_timer(iTimer->gettick() + interval, pet_hungry, sd->bl.id, 0);
return 0;
}
@@ -407,11 +407,11 @@ int pet_birth_process(struct map_session_data *sd, struct s_pet *pet)
}
intif_save_petdata(sd->status.account_id,pet);
- if (save_settings&8)
+ if (iMap->save_settings&8)
chrif_save(sd,0); //is it REALLY Needed to save the char for hatching a pet? [Skotlex]
if(sd->bl.prev != NULL) {
- map_addblock(&sd->pd->bl);
+ iMap->addblock(&sd->pd->bl);
clif->spawn(&sd->pd->bl);
clif->send_petdata(sd,sd->pd, 0,0);
clif->send_petdata(sd,sd->pd, 5,battle_config.pet_hair_style);
@@ -427,7 +427,7 @@ int pet_recv_petdata(int account_id,struct s_pet *p,int flag)
{
struct map_session_data *sd;
- sd = map_id2sd(account_id);
+ sd = iMap->id2sd(account_id);
if(sd == NULL)
return 1;
if(flag == 1) {
@@ -448,11 +448,11 @@ int pet_recv_petdata(int account_id,struct s_pet *p,int flag)
return 1;
}
if (!pet_birth_process(sd,p)) //Pet hatched. Delete egg.
- pc_delitem(sd,i,1,0,0,LOG_TYPE_OTHER);
+ pc->delitem(sd,i,1,0,0,LOG_TYPE_OTHER);
} else {
pet_data_init(sd,p);
if(sd->pd && sd->bl.prev != NULL) {
- map_addblock(&sd->pd->bl);
+ iMap->addblock(&sd->pd->bl);
clif->spawn(&sd->pd->bl);
clif->send_petdata(sd,sd->pd,0,0);
clif->send_petdata(sd,sd->pd,5,battle_config.pet_hair_style);
@@ -496,7 +496,7 @@ int pet_catch_process2(struct map_session_data* sd, int target_id)
nullpo_retr(1, sd);
- md = (struct mob_data*)map_id2bl(target_id);
+ md = (struct mob_data*)iMap->id2bl(target_id);
if(!md || md->bl.type != BL_MOB || md->bl.prev == NULL)
{ // Invalid inputs/state, abort capture.
clif->pet_roulette(sd,0);
@@ -550,7 +550,7 @@ int pet_get_egg(int account_id,int pet_id,int flag)
if(flag)
return 0;
- sd = map_id2sd(account_id);
+ sd = iMap->id2sd(account_id);
if(sd == NULL)
return 0;
@@ -569,9 +569,9 @@ int pet_get_egg(int account_id,int pet_id,int flag)
tmp_item.card[1] = GetWord(pet_id,0);
tmp_item.card[2] = GetWord(pet_id,1);
tmp_item.card[3] = 0; //New pets are not named.
- if((ret = pc_additem(sd,&tmp_item,1,LOG_TYPE_PICKDROP_PLAYER))) {
+ if((ret = pc->additem(sd,&tmp_item,1,LOG_TYPE_PICKDROP_PLAYER))) {
clif->additem(sd,0,0,ret);
- map_addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ iMap->addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
return 1;
@@ -592,9 +592,9 @@ int pet_menu(struct map_session_data *sd,int menunum)
if(!sd->status.pet_id || sd->pd->pet.intimate <= 0 || sd->pd->pet.incuvate)
return 1;
- egg_id = itemdb_exists(sd->pd->petDB->EggID);
+ egg_id = itemdb->exists(sd->pd->petDB->EggID);
if (egg_id) {
- if ((egg_id->flag.trade_restriction&0x01) && !pc_inventoryblank(sd)) {
+ if ((egg_id->flag.trade_restriction&0x01) && !pc->inventoryblank(sd)) {
clif->message(sd->fd, msg_txt(451)); // You can't return your pet because your inventory is full.
return 1;
}
@@ -674,22 +674,22 @@ int pet_equipitem(struct map_session_data *sd,int index)
return 1;
}
- pc_delitem(sd,index,1,0,0,LOG_TYPE_OTHER);
+ pc->delitem(sd,index,1,0,0,LOG_TYPE_OTHER);
pd->pet.equip = nameid;
status_set_viewdata(&pd->bl, pd->pet.class_); //Updates view_data.
clif->send_petdata(NULL, sd->pd, 3, sd->pd->vd.head_bottom);
if (battle_config.pet_equip_required)
{ //Skotlex: start support timers if need
- unsigned int tick = gettick();
+ unsigned int tick = iTimer->gettick();
if (pd->s_skill && pd->s_skill->timer == INVALID_TIMER)
{
if (pd->s_skill->id)
- pd->s_skill->timer=add_timer(tick+pd->s_skill->delay*1000, pet_skill_support_timer, sd->bl.id, 0);
+ pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000, pet_skill_support_timer, sd->bl.id, 0);
else
- pd->s_skill->timer=add_timer(tick+pd->s_skill->delay*1000, pet_heal_timer, sd->bl.id, 0);
+ pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000, pet_heal_timer, sd->bl.id, 0);
}
if (pd->bonus && pd->bonus->timer == INVALID_TIMER)
- pd->bonus->timer=add_timer(tick+pd->bonus->delay*1000, pet_skill_bonus_timer, sd->bl.id, 0);
+ pd->bonus->timer=iTimer->add_timer(tick+pd->bonus->delay*1000, pet_skill_bonus_timer, sd->bl.id, 0);
}
return 0;
@@ -710,9 +710,9 @@ static int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd)
memset(&tmp_item,0,sizeof(tmp_item));
tmp_item.nameid = nameid;
tmp_item.identify = 1;
- if((flag = pc_additem(sd,&tmp_item,1,LOG_TYPE_OTHER))) {
+ if((flag = pc->additem(sd,&tmp_item,1,LOG_TYPE_OTHER))) {
clif->additem(sd,0,0,flag);
- map_addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ iMap->addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
if( battle_config.pet_equip_required )
{ // Skotlex: halt support timers if needed
@@ -724,14 +724,14 @@ static int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd)
if( pd->s_skill && pd->s_skill->timer != INVALID_TIMER )
{
if( pd->s_skill->id )
- delete_timer(pd->s_skill->timer, pet_skill_support_timer);
+ iTimer->delete_timer(pd->s_skill->timer, pet_skill_support_timer);
else
- delete_timer(pd->s_skill->timer, pet_heal_timer);
+ iTimer->delete_timer(pd->s_skill->timer, pet_heal_timer);
pd->s_skill->timer = INVALID_TIMER;
}
if( pd->bonus && pd->bonus->timer != INVALID_TIMER )
{
- delete_timer(pd->bonus->timer, pet_skill_bonus_timer);
+ iTimer->delete_timer(pd->bonus->timer, pet_skill_bonus_timer);
pd->bonus->timer = INVALID_TIMER;
}
}
@@ -744,12 +744,12 @@ static int pet_food(struct map_session_data *sd, struct pet_data *pd)
int i,k;
k=pd->petDB->FoodID;
- i=pc_search_inventory(sd,k);
+ i=pc->search_inventory(sd,k);
if(i < 0) {
clif->pet_food(sd,k,0);
return 1;
}
- pc_delitem(sd,i,1,0,0,LOG_TYPE_CONSUME);
+ pc->delitem(sd,i,1,0,0,LOG_TYPE_CONSUME);
if( pd->pet.hungry > 90 )
pet_set_intimate(pd, pd->pet.intimate - pd->petDB->r_full);
@@ -801,7 +801,7 @@ static int pet_randomwalk(struct pet_data *pd,unsigned int tick)
int r=rnd();
x=pd->bl.x+r%(d*2+1)-d;
y=pd->bl.y+r/(d*2+1)%(d*2+1)-d;
- if(map_getcell(pd->bl.m,x,y,CELL_CHKPASS) && unit_walktoxy(&pd->bl,x,y,0)){
+ if(iMap->getcell(pd->bl.m,x,y,CELL_CHKPASS) && unit_walktoxy(&pd->bl,x,y,0)){
pd->move_fail_count=0;
break;
}
@@ -876,7 +876,7 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns
}
if (pd->target_id) {
- target= map_id2bl(pd->target_id);
+ target= iMap->id2bl(pd->target_id);
if (!target || pd->bl.m != target->m || status_isdead(target) ||
!check_distance_bl(&pd->bl, target, pd->db->range3))
{
@@ -887,7 +887,7 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns
if(!target && pd->loot && pd->msd && pc_has_permission(pd->msd, PC_PERM_TRADE) && pd->loot->count < pd->loot->max && DIFF_TICK(tick,pd->ud.canact_tick)>0) {
//Use half the pet's range of sight.
- map_foreachinrange(pet_ai_sub_hard_lootsearch,&pd->bl,
+ iMap->foreachinrange(pet_ai_sub_hard_lootsearch,&pd->bl,
pd->db->range2/2, BL_ITEM,pd,&target);
}
@@ -931,7 +931,7 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns
if(pd->loot->count < pd->loot->max){
memcpy(&pd->loot->item[pd->loot->count++],&fitem->item_data,sizeof(pd->loot->item[0]));
pd->loot->weight += itemdb_weight(fitem->item_data.nameid)*fitem->item_data.amount;
- map_clearflooritem(target);
+ iMap->clearflooritem(target);
}
//Target is unlocked regardless of whether it was picked or not.
pet_unlocktarget(pd);
@@ -951,7 +951,7 @@ static int pet_ai_sub_foreachclient(struct map_session_data *sd,va_list ap)
static int pet_ai_hard(int tid, unsigned int tick, int id, intptr_t data)
{
- map_foreachpc(pet_ai_sub_foreachclient,tick);
+ iMap->map_foreachpc(pet_ai_sub_foreachclient,tick);
return 0;
}
@@ -990,7 +990,7 @@ static int pet_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data
list=(struct item_drop_list *)data;
ditem = list->item;
while (ditem) {
- map_addflooritem(&ditem->item_data,ditem->item_data.amount,
+ iMap->addflooritem(&ditem->item_data,ditem->item_data.amount,
list->m,list->x,list->y,
list->first_charid,list->second_charid,list->third_charid,0);
ditem_prev = ditem;
@@ -1021,7 +1021,7 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd)
for(i=0;i<pd->loot->count;i++) {
it = &pd->loot->item[i];
if(sd){
- if((flag = pc_additem(sd,it,it->amount,LOG_TYPE_PICKDROP_PLAYER))){
+ if((flag = pc->additem(sd,it,it->amount,LOG_TYPE_PICKDROP_PLAYER))){
clif->additem(sd,0,0,flag);
ditem = ers_alloc(item_drop_ers, struct item_drop);
memcpy(&ditem->item_data, it, sizeof(struct item));
@@ -1040,10 +1040,10 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd)
memset(pd->loot->item,0,pd->loot->max * sizeof(struct item));
pd->loot->count = 0;
pd->loot->weight = 0;
- pd->ud.canact_tick = gettick()+10000; //prevent picked up during 10*1000ms
+ pd->ud.canact_tick = iTimer->gettick()+10000; //prevent picked up during 10*1000ms
if (dlist->item)
- add_timer(gettick()+540,pet_delay_item_drop,0,(intptr_t)dlist);
+ iTimer->add_timer(iTimer->gettick()+540,pet_delay_item_drop,0,(intptr_t)dlist);
else
ers_free(item_drop_list_ers, dlist);
return 1;
@@ -1054,7 +1054,7 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd)
*------------------------------------------*/
int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data)
{
- struct map_session_data *sd=map_id2sd(id);
+ struct map_session_data *sd=iMap->id2sd(id);
struct pet_data *pd;
int bonus;
int timer = 0;
@@ -1087,7 +1087,7 @@ int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data)
status_calc_pc(sd, 0);
}
// wait for the next timer
- pd->bonus->timer=add_timer(tick+timer,pet_skill_bonus_timer,sd->bl.id,0);
+ pd->bonus->timer=iTimer->add_timer(tick+timer,pet_skill_bonus_timer,sd->bl.id,0);
return 0;
}
@@ -1096,7 +1096,7 @@ int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data)
*------------------------------------------*/
int pet_recovery_timer(int tid, unsigned int tick, int id, intptr_t data)
{
- struct map_session_data *sd=map_id2sd(id);
+ struct map_session_data *sd=iMap->id2sd(id);
struct pet_data *pd;
if(sd==NULL || sd->pd == NULL || sd->pd->recovery == NULL)
@@ -1124,7 +1124,7 @@ int pet_recovery_timer(int tid, unsigned int tick, int id, intptr_t data)
int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data)
{
- struct map_session_data *sd=map_id2sd(id);
+ struct map_session_data *sd=iMap->id2sd(id);
struct status_data *status;
struct pet_data *pd;
unsigned int rate = 100;
@@ -1146,14 +1146,14 @@ int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data)
(rate = get_percentage(status->hp, status->max_hp)) > pd->s_skill->hp ||
(rate = (pd->ud.skilltimer != INVALID_TIMER)) //Another skill is in effect
) { //Wait (how long? 1 sec for every 10% of remaining)
- pd->s_skill->timer=add_timer(gettick()+(rate>10?rate:10)*100,pet_heal_timer,sd->bl.id,0);
+ pd->s_skill->timer=iTimer->add_timer(iTimer->gettick()+(rate>10?rate:10)*100,pet_heal_timer,sd->bl.id,0);
return 0;
}
pet_stop_attack(pd);
pet_stop_walking(pd,1);
clif->skill_nodamage(&pd->bl,&sd->bl,AL_HEAL,pd->s_skill->lv,1);
status_heal(&sd->bl, pd->s_skill->lv,0, 0);
- pd->s_skill->timer=add_timer(tick+pd->s_skill->delay*1000,pet_heal_timer,sd->bl.id,0);
+ pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000,pet_heal_timer,sd->bl.id,0);
return 0;
}
@@ -1162,7 +1162,7 @@ int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data)
*------------------------------------------*/
int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data)
{
- struct map_session_data *sd=map_id2sd(id);
+ struct map_session_data *sd=iMap->id2sd(id);
struct pet_data *pd;
struct status_data *status;
short rate = 100;
@@ -1180,7 +1180,7 @@ int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data)
if (DIFF_TICK(pd->ud.canact_tick, tick) > 0)
{ //Wait until the pet can act again.
- pd->s_skill->timer=add_timer(pd->ud.canact_tick,pet_skill_support_timer,sd->bl.id,0);
+ pd->s_skill->timer=iTimer->add_timer(pd->ud.canact_tick,pet_skill_support_timer,sd->bl.id,0);
return 0;
}
@@ -1189,13 +1189,13 @@ int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data)
(rate = get_percentage(status->hp, status->max_hp)) > pd->s_skill->hp ||
(rate = (pd->ud.skilltimer != INVALID_TIMER)) //Another skill is in effect
) { //Wait (how long? 1 sec for every 10% of remaining)
- pd->s_skill->timer=add_timer(tick+(rate>10?rate:10)*100,pet_skill_support_timer,sd->bl.id,0);
+ pd->s_skill->timer=iTimer->add_timer(tick+(rate>10?rate:10)*100,pet_skill_support_timer,sd->bl.id,0);
return 0;
}
pet_stop_attack(pd);
pet_stop_walking(pd,1);
- pd->s_skill->timer=add_timer(tick+pd->s_skill->delay*1000,pet_skill_support_timer,sd->bl.id,0);
+ pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000,pet_skill_support_timer,sd->bl.id,0);
if (skill->get_inf(pd->s_skill->id) & INF_GROUND_SKILL)
unit_skilluse_pos(&pd->bl, sd->bl.x, sd->bl.y, pd->s_skill->id, pd->s_skill->lv);
else
@@ -1238,7 +1238,7 @@ int read_petdb()
char line[1024];
int lines, entries;
- sprintf(line, "%s/%s", db_path, filename[i]);
+ sprintf(line, "%s/%s", iMap->db_path, filename[i]);
fp=fopen(line,"r");
if( fp == NULL )
{
@@ -1363,14 +1363,14 @@ int do_init_pet(void)
item_drop_ers = ers_new(sizeof(struct item_drop),"pet.c::item_drop_ers",ERS_OPT_NONE);
item_drop_list_ers = ers_new(sizeof(struct item_drop_list),"pet.c::item_drop_list_ers",ERS_OPT_NONE);
- add_timer_func_list(pet_hungry,"pet_hungry");
- add_timer_func_list(pet_ai_hard,"pet_ai_hard");
- add_timer_func_list(pet_skill_bonus_timer,"pet_skill_bonus_timer"); // [Valaris]
- add_timer_func_list(pet_delay_item_drop,"pet_delay_item_drop");
- add_timer_func_list(pet_skill_support_timer, "pet_skill_support_timer"); // [Skotlex]
- add_timer_func_list(pet_recovery_timer,"pet_recovery_timer"); // [Valaris]
- add_timer_func_list(pet_heal_timer,"pet_heal_timer"); // [Valaris]
- add_timer_interval(gettick()+MIN_PETTHINKTIME,pet_ai_hard,0,0,MIN_PETTHINKTIME);
+ iTimer->add_timer_func_list(pet_hungry,"pet_hungry");
+ iTimer->add_timer_func_list(pet_ai_hard,"pet_ai_hard");
+ iTimer->add_timer_func_list(pet_skill_bonus_timer,"pet_skill_bonus_timer"); // [Valaris]
+ iTimer->add_timer_func_list(pet_delay_item_drop,"pet_delay_item_drop");
+ iTimer->add_timer_func_list(pet_skill_support_timer, "pet_skill_support_timer"); // [Skotlex]
+ iTimer->add_timer_func_list(pet_recovery_timer,"pet_recovery_timer"); // [Valaris]
+ iTimer->add_timer_func_list(pet_heal_timer,"pet_heal_timer"); // [Valaris]
+ iTimer->add_timer_interval(iTimer->gettick()+MIN_PETTHINKTIME,pet_ai_hard,0,0,MIN_PETTHINKTIME);
return 0;
}
diff --git a/src/map/quest.c b/src/map/quest.c
index 3ef162aaa..b56088886 100644
--- a/src/map/quest.c
+++ b/src/map/quest.c
@@ -99,7 +99,7 @@ int quest_add(TBL_PC * sd, int quest_id)
clif->quest_add(sd, &sd->quest_log[i], sd->quest_index[i]);
- if( save_settings&64 )
+ if( iMap->save_settings&64 )
chrif_save(sd,0);
return 0;
@@ -147,7 +147,7 @@ int quest_change(TBL_PC * sd, int qid1, int qid2)
clif->quest_delete(sd, qid1);
clif->quest_add(sd, &sd->quest_log[i], sd->quest_index[i]);
- if( save_settings&64 )
+ if( iMap->save_settings&64 )
chrif_save(sd,0);
return 0;
@@ -178,7 +178,7 @@ int quest_delete(TBL_PC * sd, int quest_id)
clif->quest_delete(sd, quest_id);
- if( save_settings&64 )
+ if( iMap->save_settings&64 )
chrif_save(sd,0);
return 0;
@@ -249,7 +249,7 @@ int quest_update_status(TBL_PC * sd, int quest_id, quest_state status) {
clif->quest_delete(sd, quest_id);
- if( save_settings&64 )
+ if( iMap->save_settings&64 )
chrif_save(sd,0);
return 0;
@@ -293,7 +293,7 @@ int quest_read_db(void) {
int i,j,k = 0;
char *str[20],*p,*np;
- sprintf(line, "%s/quest_db.txt", db_path);
+ sprintf(line, "%s/quest_db.txt", iMap->db_path);
if( (fp=fopen(line,"r"))==NULL ){
ShowError("can't read %s\n", line);
return -1;
@@ -302,7 +302,7 @@ int quest_read_db(void) {
while(fgets(line, sizeof(line), fp)) {
if (k == MAX_QUEST_DB) {
- ShowError("quest_read_db: Too many entries specified in %s/quest_db.txt!\n", db_path);
+ ShowError("quest_read_db: Too many entries specified in %s/quest_db.txt!\n", iMap->db_path);
break;
}
diff --git a/src/map/script.c b/src/map/script.c
index 41f8e7472..bbae42c6f 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -89,26 +89,6 @@ static inline void SETVALUE(unsigned char* buf, int i, int n)
buf[i+2] = GetByte(n, 2);
}
-// String buffer structures.
-// str_data stores string information
-static struct str_data_struct {
- enum c_op type;
- int str;
- int backpatch;
- int label;
- bool (*func)(struct script_state *st);
- int val;
- int next;
-} *str_data = NULL;
-static int str_data_size = 0; // size of the data
-static int str_num = LABEL_START; // next id to be assigned
-
-// str_buf holds the strings themselves
-static char *str_buf;
-static int str_size = 0; // size of the buffer
-static int str_pos = 0; // next position to be assigned
-
-
// Using a prime number for SCRIPT_HASH_SIZE should give better distributions
#define SCRIPT_HASH_SIZE 1021
int str_hash[SCRIPT_HASH_SIZE];
@@ -201,8 +181,6 @@ int potion_target=0;
c_op get_com(unsigned char *script,int *pos);
int get_num(unsigned char *script,int *pos);
-static struct linkdb_node* sleep_db;// int oid -> struct script_state*
-
/*==========================================
* (Only those needed) local declaration prototype
*------------------------------------------*/
@@ -338,7 +316,7 @@ static void script_dump_stack(struct script_state* st)
break;
case C_NAME:
- ShowMessage(" \"%s\" (id=%d ref=%p subtype=%s)\n", reference_getname(data), data->u.num, data->ref, script_op2name(str_data[data->u.num].type));
+ ShowMessage(" \"%s\" (id=%d ref=%p subtype=%s)\n", reference_getname(data), data->u.num, data->ref, script_op2name(script->str_data[data->u.num].type));
break;
case C_RETINFO:
@@ -363,7 +341,7 @@ static void script_reportsrc(struct script_state *st)
if( st->oid == 0 )
return; //Can't report source.
- bl = map_id2bl(st->oid);
+ bl = iMap->id2bl(st->oid);
if( bl == NULL )
return;
@@ -416,7 +394,7 @@ static void script_reportdata(struct script_data* data)
ShowDebug("Data: param name='%s' type=%d\n", reference_getname(data), reference_getparamtype(data));
} else {// ???
ShowDebug("Data: reference name='%s' type=%s\n", reference_getname(data), script_op2name(data->type));
- ShowDebug("Please report this!!! - str_data.type=%s\n", script_op2name(str_data[reference_getid(data)].type));
+ ShowDebug("Please report this!!! - script->str_data.type=%s\n", script_op2name(script->str_data[reference_getid(data)].type));
}
break;
case C_POS:// label
@@ -442,7 +420,7 @@ static void script_reportfunc(struct script_state* st)
data = script_getdata(st,0);
- if( !data_isreference(data) || str_data[reference_getid(data)].type != C_FUNC )
+ if( !data_isreference(data) || script->str_data[reference_getid(data)].type != C_FUNC )
{// script currently not executing a built-in function or corrupt stack
return;
}
@@ -526,14 +504,14 @@ static unsigned int calc_hash(const char* p)
/*==========================================
- * str_data manipulation functions
+ * script->str_data manipulation functions
*------------------------------------------*/
/// Looks up string using the provided id.
const char* get_str(int id)
{
- Assert( id >= LABEL_START && id < str_size );
- return str_buf+str_data[id].str;
+ Assert( id >= LABEL_START && id < script->str_size );
+ return script->str_buf+script->str_data[id].str;
}
/// Returns the uid of the string, or -1.
@@ -541,7 +519,7 @@ static int search_str(const char* p)
{
int i;
- for( i = str_hash[calc_hash(p)]; i != 0; i = str_data[i].next )
+ for( i = str_hash[calc_hash(p)]; i != 0; i = script->str_data[i].next )
if( strcasecmp(get_str(i),p) == 0 )
return i;
@@ -557,52 +535,46 @@ int add_str(const char* p)
h = calc_hash(p);
- if( str_hash[h] == 0 )
- {// empty bucket, add new node here
- str_hash[h] = str_num;
- }
- else
- {// scan for end of list, or occurence of identical string
- for( i = str_hash[h]; ; i = str_data[i].next )
- {
+ if( str_hash[h] == 0 ) {// empty bucket, add new node here
+ str_hash[h] = script->str_num;
+ } else {// scan for end of list, or occurence of identical string
+ for( i = str_hash[h]; ; i = script->str_data[i].next ) {
if( strcasecmp(get_str(i),p) == 0 )
return i; // string already in list
- if( str_data[i].next == 0 )
+ if( script->str_data[i].next == 0 )
break; // reached the end
}
// append node to end of list
- str_data[i].next = str_num;
+ script->str_data[i].next = script->str_num;
}
// grow list if neccessary
- if( str_num >= str_data_size )
- {
- str_data_size += 128;
- RECREATE(str_data,struct str_data_struct,str_data_size);
- memset(str_data + (str_data_size - 128), '\0', 128);
+ if( script->str_num >= script->str_data_size ) {
+ script->str_data_size += 1280;
+ RECREATE(script->str_data,struct str_data_struct,script->str_data_size);
+ memset(script->str_data + (script->str_data_size - 1280), '\0', 1280);
}
len=(int)strlen(p);
// grow string buffer if neccessary
- while( str_pos+len+1 >= str_size )
- {
- str_size += 256;
- RECREATE(str_buf,char,str_size);
- memset(str_buf + (str_size - 256), '\0', 256);
+ while( script->str_pos+len+1 >= script->str_size ) {
+ script->str_size += 10240;
+ RECREATE(script->str_buf,char,script->str_size);
+ memset(script->str_buf + (script->str_size - 10240), '\0', 10240);
}
- safestrncpy(str_buf+str_pos, p, len+1);
- str_data[str_num].type = C_NOP;
- str_data[str_num].str = str_pos;
- str_data[str_num].next = 0;
- str_data[str_num].func = NULL;
- str_data[str_num].backpatch = -1;
- str_data[str_num].label = -1;
- str_pos += len+1;
+ safestrncpy(script->str_buf+script->str_pos, p, len+1);
+ script->str_data[script->str_num].type = C_NOP;
+ script->str_data[script->str_num].str = script->str_pos;
+ script->str_data[script->str_num].next = 0;
+ script->str_data[script->str_num].func = NULL;
+ script->str_data[script->str_num].backpatch = -1;
+ script->str_data[script->str_num].label = -1;
+ script->str_pos += len+1;
- return str_num++;
+ return script->str_num++;
}
@@ -646,35 +618,35 @@ static void add_scripti(int a)
add_scriptb(a|0x80);
}
-/// Appends a str_data object (label/function/variable/integer) to the script buffer.
+/// Appends a script->str_data object (label/function/variable/integer) to the script buffer.
///
-/// @param l The id of the str_data entry
+/// @param l The id of the script->str_data entry
// Maximum up to 16M
static void add_scriptl(int l)
{
- int backpatch = str_data[l].backpatch;
+ int backpatch = script->str_data[l].backpatch;
- switch(str_data[l].type){
+ switch(script->str_data[l].type){
case C_POS:
case C_USERFUNC_POS:
add_scriptc(C_POS);
- add_scriptb(str_data[l].label);
- add_scriptb(str_data[l].label>>8);
- add_scriptb(str_data[l].label>>16);
+ add_scriptb(script->str_data[l].label);
+ add_scriptb(script->str_data[l].label>>8);
+ add_scriptb(script->str_data[l].label>>16);
break;
case C_NOP:
case C_USERFUNC:
// Embedded data backpatch there is a possibility of label
add_scriptc(C_NAME);
- str_data[l].backpatch = script_pos;
+ script->str_data[l].backpatch = script_pos;
add_scriptb(backpatch);
add_scriptb(backpatch>>8);
add_scriptb(backpatch>>16);
break;
case C_INT:
- add_scripti(abs(str_data[l].val));
- if( str_data[l].val < 0 ) //Notice that this is negative, from jA (Rayce)
+ add_scripti(abs(script->str_data[l].val));
+ if( script->str_data[l].val < 0 ) //Notice that this is negative, from jA (Rayce)
add_scriptc(C_NEG);
break;
default: // assume C_NAME
@@ -693,20 +665,20 @@ void set_label(int l,int pos, const char* script_pos)
{
int i,next;
- if(str_data[l].type==C_INT || str_data[l].type==C_PARAM || str_data[l].type==C_FUNC)
+ if(script->str_data[l].type==C_INT || script->str_data[l].type==C_PARAM || script->str_data[l].type==C_FUNC)
{ //Prevent overwriting constants values, parameters and built-in functions [Skotlex]
disp_error_message("set_label: invalid label name",script_pos);
return;
}
- if(str_data[l].label!=-1){
+ if(script->str_data[l].label!=-1){
disp_error_message("set_label: dup label ",script_pos);
return;
}
- str_data[l].type=(str_data[l].type == C_USERFUNC ? C_USERFUNC_POS : C_POS);
- str_data[l].label=pos;
- for(i=str_data[l].backpatch;i>=0 && i!=0x00ffffff;){
+ script->str_data[l].type=(script->str_data[l].type == C_USERFUNC ? C_USERFUNC_POS : C_POS);
+ script->str_data[l].label=pos;
+ for(i=script->str_data[l].backpatch;i>=0 && i!=0x00ffffff;){
next=GETVALUE(script_buf,i);
- script_buf[i-1]=(str_data[l].type == C_USERFUNC ? C_USERFUNC_POS : C_POS);
+ script_buf[i-1]=(script->str_data[l].type == C_USERFUNC ? C_USERFUNC_POS : C_POS);
SETVALUE(script_buf,i,pos);
i=next;
}
@@ -748,24 +720,21 @@ const char* skip_space(const char* p)
}
/// Skips a word.
-/// A word consists of undercores and/or alfanumeric characters,
+/// A word consists of undercores and/or alphanumeric characters,
/// and valid variable prefixes/postfixes.
-static
-const char* skip_word(const char* p)
-{
+static const char* skip_word(const char* p) {
// prefix
- switch( *p )
- {
- case '@':// temporary char variable
- ++p; break;
- case '#':// account variable
- p += ( p[1] == '#' ? 2 : 1 ); break;
- case '\'':// instance variable
- ++p; break;
- case '.':// npc variable
- p += ( p[1] == '@' ? 2 : 1 ); break;
- case '$':// global variable
- p += ( p[1] == '@' ? 2 : 1 ); break;
+ switch( *p ) {
+ case '@':// temporary char variable
+ ++p; break;
+ case '#':// account variable
+ p += ( p[1] == '#' ? 2 : 1 ); break;
+ case '\'':// instance variable
+ ++p; break;
+ case '.':// npc variable
+ p += ( p[1] == '@' ? 2 : 1 ); break;
+ case '$':// global variable
+ p += ( p[1] == '@' ? 2 : 1 ); break;
}
while( ISALNUM(*p) || *p == '_' )
@@ -777,30 +746,28 @@ const char* skip_word(const char* p)
return p;
}
-
-/// Adds a word to str_data.
+/// Adds a word to script->str_data.
/// @see skip_word
/// @see add_str
-static
-int add_word(const char* p)
-{
- char* word;
+static int add_word(const char* p) {
int len;
int i;
// Check for a word
len = skip_word(p) - p;
if( len == 0 )
- disp_error_message("script:add_word: invalid word. A word consists of undercores and/or alfanumeric characters, and valid variable prefixes/postfixes.", p);
+ disp_error_message("script:add_word: invalid word. A word consists of undercores and/or alphanumeric characters, and valid variable prefixes/postfixes.", p);
// Duplicate the word
- word = (char*)aMalloc(len+1);
- memcpy(word, p, len);
- word[len] = 0;
+ if( len+1 > script->word_size )
+ RECREATE(script->word_buf, char, (script->word_size = (len+1)));
+
+ memcpy(script->word_buf, p, len);
+ script->word_buf[len] = 0;
// add the word
- i = add_str(word);
- aFree(word);
+ i = add_str(script->word_buf);
+
return i;
}
@@ -815,19 +782,21 @@ const char* parse_callfunc(const char* p, int require_paren, int is_custom)
int func;
func = add_word(p);
- if( str_data[func].type == C_FUNC ){
+ if( script->str_data[func].type == C_FUNC ){
+ char argT = 0;
// buildin function
add_scriptl(func);
add_scriptc(C_ARG);
- arg = script->buildin[str_data[func].val];
- } else if( str_data[func].type == C_USERFUNC || str_data[func].type == C_USERFUNC_POS ){
+ arg = script->buildin[script->str_data[func].val];
+ if( !arg ) arg = &argT;
+ } else if( script->str_data[func].type == C_USERFUNC || script->str_data[func].type == C_USERFUNC_POS ){
// script defined function
add_scriptl(buildin_callsub_ref);
add_scriptc(C_ARG);
add_scriptl(func);
- arg = script->buildin[str_data[buildin_callsub_ref].val];
+ arg = script->buildin[script->str_data[buildin_callsub_ref].val];
if( *arg == 0 )
- disp_error_message("parse_callfunc: callsub has no arguments, please review it's definition",p);
+ disp_error_message("parse_callfunc: callsub has no arguments, please review its definition",p);
if( *arg != '*' )
++arg; // count func as argument
} else {
@@ -843,7 +812,7 @@ const char* parse_callfunc(const char* p, int require_paren, int is_custom)
add_scriptc(C_STR);
while( *name ) add_scriptb(*name ++);
add_scriptb(0);
- arg = script->buildin[str_data[buildin_callfunc_ref].val];
+ arg = script->buildin[script->str_data[buildin_callfunc_ref].val];
if( *arg != '*' ) ++ arg;
}
#endif
@@ -916,9 +885,9 @@ static void parse_nextline(bool first, const char* p)
}
// initialize data for new '-' label fix up scheduling
- str_data[LABEL_NEXTLINE].type = C_NOP;
- str_data[LABEL_NEXTLINE].backpatch = -1;
- str_data[LABEL_NEXTLINE].label = -1;
+ script->str_data[LABEL_NEXTLINE].type = C_NOP;
+ script->str_data[LABEL_NEXTLINE].backpatch = -1;
+ script->str_data[LABEL_NEXTLINE].label = -1;
}
/// Parse a variable assignment using the direct equals operator
@@ -1005,7 +974,7 @@ const char* parse_variable(const char* p) {
// parse the variable currently being modified
word = add_word(var);
- if( str_data[word].type == C_FUNC || str_data[word].type == C_USERFUNC || str_data[word].type == C_USERFUNC_POS )
+ if( script->str_data[word].type == C_FUNC || script->str_data[word].type == C_USERFUNC || script->str_data[word].type == C_USERFUNC_POS )
{// cannot assign a variable which exists as a function or label
disp_error_message("Cannot modify a variable which has the same name as a function or label.", p);
}
@@ -1067,7 +1036,7 @@ const char* parse_simpleexpr(const char *p)
p=skip_space(p);
if(*p==';' || *p==',')
- disp_error_message("parse_simpleexpr: unexpected expr end",p);
+ disp_error_message("parse_simpleexpr: unexpected end of expression",p);
if(*p=='('){
if( (i=syntax.curly_count-1) >= 0 && syntax.curly[i].type == TYPE_ARGLIST )
++syntax.curly[i].count;
@@ -1083,7 +1052,7 @@ const char* parse_simpleexpr(const char *p)
syntax.curly[i].flag = ARGLIST_NO_PAREN;
}
if( *p != ')' )
- disp_error_message("parse_simpleexpr: unmatch ')'",p);
+ disp_error_message("parse_simpleexpr: unmatched ')'",p);
++p;
} else if(ISDIGIT(*p) || ((*p=='-' || *p=='+') && ISDIGIT(p[1]))){
char *np;
@@ -1109,7 +1078,7 @@ const char* parse_simpleexpr(const char *p)
add_scriptb(*p++);
}
if(!*p)
- disp_error_message("parse_simpleexpr: unexpected eof @ string",p);
+ disp_error_message("parse_simpleexpr: unexpected end of file @ string",p);
add_scriptb(0);
p++; //'"'
} else {
@@ -1121,7 +1090,7 @@ const char* parse_simpleexpr(const char *p)
disp_error_message("parse_simpleexpr: unexpected character",p);
l=add_word(p);
- if( str_data[l].type == C_FUNC || str_data[l].type == C_USERFUNC || str_data[l].type == C_USERFUNC_POS)
+ if( script->str_data[l].type == C_FUNC || script->str_data[l].type == C_USERFUNC || script->str_data[l].type == C_USERFUNC_POS)
return parse_callfunc(p,1,0);
#ifdef SCRIPT_CALLFUNC_CHECK
else {
@@ -1147,7 +1116,7 @@ const char* parse_simpleexpr(const char *p)
p=parse_subexpr(p+1,-1);
p=skip_space(p);
if( *p != ']' )
- disp_error_message("parse_simpleexpr: unmatch ']'",p);
+ disp_error_message("parse_simpleexpr: unmatched ']'",p);
++p;
add_scriptc(C_FUNC);
}else
@@ -1348,8 +1317,8 @@ const char* parse_curly_close(const char* p)
}
// Syntax-related processing
-// break, case, continue, default, do, for, function,
-// if, switch, while ? will handle this internally.
+// break, case, continue, default, do, for, function,
+// if, switch, while ? will handle this internally.
const char* parse_syntax(const char* p)
{
const char *p2 = skip_word(p);
@@ -1428,15 +1397,15 @@ const char* parse_syntax(const char* p)
v = p2-p; // length of word at p2
memcpy(label,p,v);
label[v]='\0';
- if( !script_get_constant(label, &v) )
- disp_error_message("parse_syntax: 'case' label not integer",p);
+ if( !script->get_constant(label, &v) )
+ disp_error_message("parse_syntax: 'case' label is not an integer",p);
p = skip_word(p);
} else { //Numeric value
if((*p == '-' || *p == '+') && ISDIGIT(p[1])) // pre-skip because '-' can not skip_word
p++;
p = skip_word(p);
if(np != p)
- disp_error_message("parse_syntax: 'case' label not integer",np);
+ disp_error_message("parse_syntax: 'case' label is not an integer",np);
}
p = skip_space(p);
if(*p != ':')
@@ -1644,9 +1613,9 @@ const char* parse_syntax(const char* p)
// function declaration - just register the name
int l;
l = add_word(func_name);
- if( str_data[l].type == C_NOP )// register only, if the name was not used by something else
- str_data[l].type = C_USERFUNC;
- else if( str_data[l].type == C_USERFUNC )
+ if( script->str_data[l].type == C_NOP )// register only, if the name was not used by something else
+ script->str_data[l].type = C_USERFUNC;
+ else if( script->str_data[l].type == C_USERFUNC )
; // already registered
else
disp_error_message("parse_syntax:function: function name is invalid", func_name);
@@ -1675,9 +1644,9 @@ const char* parse_syntax(const char* p)
// Set the position of the function (label)
l=add_word(func_name);
- if( str_data[l].type == C_NOP || str_data[l].type == C_USERFUNC )// register only, if the name was not used by something else
+ if( script->str_data[l].type == C_NOP || script->str_data[l].type == C_USERFUNC )// register only, if the name was not used by something else
{
- str_data[l].type = C_USERFUNC;
+ script->str_data[l].type = C_USERFUNC;
set_label(l, script_pos, p);
if( parse_options&SCRIPT_USE_LABEL_DB )
strdb_iput(scriptlabel_db, get_str(l), script_pos);
@@ -1972,35 +1941,42 @@ bool script_get_constant(const char* name, int* value)
{
int n = search_str(name);
- if( n == -1 || str_data[n].type != C_INT )
+ if( n == -1 || script->str_data[n].type != C_INT )
{// not found or not a constant
return false;
}
- value[0] = str_data[n].val;
+ value[0] = script->str_data[n].val;
return true;
}
/// Creates new constant or parameter with given value.
-void script_set_constant(const char* name, int value, bool isparameter)
-{
+void script_set_constant(const char* name, int value, bool isparameter) {
int n = add_str(name);
- if( str_data[n].type == C_NOP )
- {// new
- str_data[n].type = isparameter ? C_PARAM : C_INT;
- str_data[n].val = value;
- }
- else if( str_data[n].type == C_PARAM || str_data[n].type == C_INT )
- {// existing parameter or constant
- ShowError("script_set_constant: Attempted to overwrite existing %s '%s' (old value=%d, new value=%d).\n", ( str_data[n].type == C_PARAM ) ? "parameter" : "constant", name, str_data[n].val, value);
- }
- else
- {// existing name
- ShowError("script_set_constant: Invalid name for %s '%s' (already defined as %s).\n", isparameter ? "parameter" : "constant", name, script_op2name(str_data[n].type));
+ if( script->str_data[n].type == C_NOP ) {// new
+ script->str_data[n].type = isparameter ? C_PARAM : C_INT;
+ script->str_data[n].val = value;
+ } else if( script->str_data[n].type == C_PARAM || script->str_data[n].type == C_INT ) {// existing parameter or constant
+ ShowError("script_set_constant: Attempted to overwrite existing %s '%s' (old value=%d, new value=%d).\n", ( script->str_data[n].type == C_PARAM ) ? "parameter" : "constant", name, script->str_data[n].val, value);
+ } else {// existing name
+ ShowError("script_set_constant: Invalid name for %s '%s' (already defined as %s).\n", isparameter ? "parameter" : "constant", name, script_op2name(script->str_data[n].type));
}
}
+/* will override if necessary */
+void script_set_constant2(const char *name, int value, bool isparameter) {
+ int n = add_str(name);
+
+ if( script->str_data[n].type != C_NOP ) {
+ script->str_data[n].next = 0;
+ script->str_data[n].func = NULL;
+ script->str_data[n].backpatch = -1;
+ script->str_data[n].label = -1;
+ }
+ script->str_data[n].type = isparameter ? C_PARAM : C_INT;
+ script->str_data[n].val = value;
+}
/*==========================================
* Reading constant databases
* const.txt
@@ -2011,7 +1987,7 @@ static void read_constdb(void)
char line[1024],name[1024],val[1024];
int type;
- sprintf(line, "%s/const.txt", db_path);
+ sprintf(line, "%s/const.txt", iMap->db_path);
fp=fopen(line, "r");
if(fp==NULL){
ShowError("can't read %s\n", line);
@@ -2074,7 +2050,11 @@ void script_error(const char* src, const char* file, int start_line, const char*
StrBuf->Init(&buf);
StrBuf->AppendStr(&buf, "\a\n");
- StrBuf->Printf(&buf, "script error on %s line %d\n", file, line);
+ if( line >= 0 )
+ StrBuf->Printf(&buf, "script error on %s line %d\n", file, line);
+ else
+ StrBuf->Printf(&buf, "script error on %s item ID %d\n", file, -line);
+
StrBuf->Printf(&buf, " %s\n", error_msg);
for(j = 0; j < 5; j++ ) {
script_print_line(&buf, linestart[j], NULL, line + j - 5);
@@ -2124,8 +2104,8 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
script_pos = 0;
script_size = 0;
script_buf = NULL;
- for(i=LABEL_START;i<str_num;i++)
- if(str_data[i].type == C_NOP) str_data[i].type = C_NAME;
+ for(i=LABEL_START;i<script->str_num;i++)
+ if(script->str_data[i].type == C_NOP) script->str_data[i].type = C_NAME;
for(i=0; i<size; i++)
linkdb_final(&syntax.curly[i].case_label);
return NULL;
@@ -2163,14 +2143,14 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
}
// clear references of labels, variables and internal functions
- for(i=LABEL_START;i<str_num;i++){
+ for(i=LABEL_START;i<script->str_num;i++){
if(
- str_data[i].type==C_POS || str_data[i].type==C_NAME ||
- str_data[i].type==C_USERFUNC || str_data[i].type == C_USERFUNC_POS
+ script->str_data[i].type==C_POS || script->str_data[i].type==C_NAME ||
+ script->str_data[i].type==C_USERFUNC || script->str_data[i].type == C_USERFUNC_POS
){
- str_data[i].type=C_NOP;
- str_data[i].backpatch=-1;
- str_data[i].label=-1;
+ script->str_data[i].type=C_NOP;
+ script->str_data[i].backpatch=-1;
+ script->str_data[i].label=-1;
}
}
@@ -2204,20 +2184,20 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
RECREATE(script_buf,unsigned char,script_pos);
// default unknown references to variables
- for(i=LABEL_START;i<str_num;i++){
- if(str_data[i].type==C_NOP){
+ for(i=LABEL_START;i<script->str_num;i++){
+ if(script->str_data[i].type==C_NOP){
int j,next;
- str_data[i].type=C_NAME;
- str_data[i].label=i;
- for(j=str_data[i].backpatch;j>=0 && j!=0x00ffffff;){
+ script->str_data[i].type=C_NAME;
+ script->str_data[i].label=i;
+ for(j=script->str_data[i].backpatch;j>=0 && j!=0x00ffffff;){
next=GETVALUE(script_buf,j);
SETVALUE(script_buf,j,i);
j=next;
}
}
- else if( str_data[i].type == C_USERFUNC )
+ else if( script->str_data[i].type == C_USERFUNC )
{// 'function name;' without follow-up code
- ShowError("parse_script: function '%s' declared but not defined.\n", str_buf+str_data[i].str);
+ ShowError("parse_script: function '%s' declared but not defined.\n", script->str_buf+script->str_data[i].str);
unresolved_names = true;
}
}
@@ -2270,16 +2250,15 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
CREATE(code,struct script_code,1);
code->script_buf = script_buf;
code->script_size = script_size;
- code->script_vars = idb_alloc(DB_OPT_RELEASE_DATA);
+ code->script_vars = NULL;
return code;
}
/// Returns the player attached to this script, identified by the rid.
/// If there is no player attached, the script is terminated.
-TBL_PC *script_rid2sd(struct script_state *st)
-{
- TBL_PC *sd=map_id2sd(st->rid);
- if(!sd){
+TBL_PC *script_rid2sd(struct script_state *st) {
+ TBL_PC *sd;
+ if( !( sd = iMap->id2sd(st->rid) ) ){
ShowError("script_rid2sd: fatal error ! player not attached!\n");
script_reportfunc(st);
script_reportsrc(st);
@@ -2307,20 +2286,15 @@ void get_val(struct script_state* st, struct script_data* data)
postfix = name[strlen(name) - 1];
//##TODO use reference_tovariable(data) when it's confirmed that it works [FlavioJS]
- if( !reference_toconstant(data) && not_server_variable(prefix) )
- {
+ if( !reference_toconstant(data) && not_server_variable(prefix) ) {
sd = script_rid2sd(st);
- if( sd == NULL )
- {// needs player attached
- if( postfix == '$' )
- {// string variable
- ShowWarning("script:get_val: cannot access player variable '%s', defaulting to \"\"\n", name);
+ if( sd == NULL ) {// needs player attached
+ if( postfix == '$' ) {// string variable
+ ShowWarning("script:script->get_val: cannot access player variable '%s', defaulting to \"\"\n", name);
data->type = C_CONSTSTR;
data->u.str = "";
- }
- else
- {// integer variable
- ShowWarning("script:get_val: cannot access player variable '%s', defaulting to 0\n", name);
+ } else {// integer variable
+ ShowWarning("script:script->get_val: cannot access player variable '%s', defaulting to 0\n", name);
data->type = C_INT;
data->u.num = 0;
}
@@ -2328,128 +2302,113 @@ void get_val(struct script_state* st, struct script_data* data)
}
}
- if( postfix == '$' )
- {// string variable
+ if( postfix == '$' ) {// string variable
- switch( prefix )
- {
- case '@':
- data->u.str = pc_readregstr(sd, data->u.num);
- break;
- case '$':
- data->u.str = mapreg_readregstr(data->u.num);
- break;
- case '#':
- if( name[1] == '#' )
- data->u.str = pc_readaccountreg2str(sd, name);// global
- else
- data->u.str = pc_readaccountregstr(sd, name);// local
- break;
- case '.':
- {
- struct DBMap* n =
- data->ref ? *data->ref:
- name[1] == '@' ? st->stack->var_function:// instance/scope variable
- st->script->script_vars;// npc variable
- if( n )
- data->u.str = (char*)idb_get(n,reference_getuid(data));
+ switch( prefix ) {
+ case '@':
+ data->u.str = pc->readregstr(sd, data->u.num);
+ break;
+ case '$':
+ data->u.str = mapreg_readregstr(data->u.num);
+ break;
+ case '#':
+ if( name[1] == '#' )
+ data->u.str = pc_readaccountreg2str(sd, name);// global
else
- data->u.str = NULL;
- }
- break;
- case '\'':
- if (st->instance_id) {
- data->u.str = (char*)idb_get(instance[st->instance_id].vars,reference_getuid(data));
- } else {
- ShowWarning("script:get_val: cannot access instance variable '%s', defaulting to \"\"\n", name);
- data->u.str = NULL;
+ data->u.str = pc_readaccountregstr(sd, name);// local
+ break;
+ case '.':
+ {
+ struct DBMap* n =
+ data->ref ? *data->ref:
+ name[1] == '@' ? st->stack->var_function:// instance/scope variable
+ st->script->script_vars;// npc variable
+ if( n )
+ data->u.str = (char*)idb_get(n,reference_getuid(data));
+ else
+ data->u.str = NULL;
}
- break;
- default:
- data->u.str = pc_readglobalreg_str(sd, name);
- break;
+ break;
+ case '\'':
+ if ( st->instance_id >= 0 ) {
+ data->u.str = (char*)idb_get(instances[st->instance_id].vars,reference_getuid(data));
+ } else {
+ ShowWarning("script:script->get_val: cannot access instance variable '%s', defaulting to \"\"\n", name);
+ data->u.str = NULL;
+ }
+ break;
+ default:
+ data->u.str = pc_readglobalreg_str(sd, name);
+ break;
}
- if( data->u.str == NULL || data->u.str[0] == '\0' )
- {// empty string
+ if( data->u.str == NULL || data->u.str[0] == '\0' ) {// empty string
data->type = C_CONSTSTR;
data->u.str = "";
- }
- else
- {// duplicate string
+ } else {// duplicate string
data->type = C_STR;
data->u.str = aStrdup(data->u.str);
}
- }
- else
- {// integer variable
+ } else {// integer variable
data->type = C_INT;
- if( reference_toconstant(data) )
- {
+ if( reference_toconstant(data) ) {
data->u.num = reference_getconstant(data);
- }
- else if( reference_toparam(data) )
- {
- data->u.num = pc_readparam(sd, reference_getparamtype(data));
- }
- else
- switch( prefix )
- {
- case '@':
- data->u.num = pc_readreg(sd, data->u.num);
- break;
- case '$':
- data->u.num = mapreg_readreg(data->u.num);
- break;
- case '#':
- if( name[1] == '#' )
- data->u.num = pc_readaccountreg2(sd, name);// global
- else
- data->u.num = pc_readaccountreg(sd, name);// local
- break;
- case '.':
- {
- struct DBMap* n =
- data->ref ? *data->ref:
- name[1] == '@' ? st->stack->var_function:// instance/scope variable
- st->script->script_vars;// npc variable
- if( n )
- data->u.num = (int)idb_iget(n,reference_getuid(data));
- else
- data->u.num = 0;
+ } else if( reference_toparam(data) ) {
+ data->u.num = pc->readparam(sd, reference_getparamtype(data));
+ } else
+ switch( prefix ) {
+ case '@':
+ data->u.num = pc->readreg(sd, data->u.num);
+ break;
+ case '$':
+ data->u.num = mapreg_readreg(data->u.num);
+ break;
+ case '#':
+ if( name[1] == '#' )
+ data->u.num = pc_readaccountreg2(sd, name);// global
+ else
+ data->u.num = pc_readaccountreg(sd, name);// local
+ break;
+ case '.':
+ {
+ struct DBMap* n =
+ data->ref ? *data->ref:
+ name[1] == '@' ? st->stack->var_function:// instance/scope variable
+ st->script->script_vars;// npc variable
+ if( n )
+ data->u.num = (int)idb_iget(n,reference_getuid(data));
+ else
+ data->u.num = 0;
+ }
+ break;
+ case '\'':
+ if( st->instance_id >= 0 )
+ data->u.num = (int)idb_iget(instances[st->instance_id].vars,reference_getuid(data));
+ else {
+ ShowWarning("script:script->get_val: cannot access instance variable '%s', defaulting to 0\n", name);
+ data->u.num = 0;
+ }
+ break;
+ default:
+ data->u.num = pc_readglobalreg(sd, name);
+ break;
}
- break;
- case '\'':
- if( st->instance_id )
- data->u.num = (int)idb_iget(instance[st->instance_id].vars,reference_getuid(data));
- else {
- ShowWarning("script:get_val: cannot access instance variable '%s', defaulting to 0\n", name);
- data->u.num = 0;
- }
- break;
- default:
- data->u.num = pc_readglobalreg(sd, name);
- break;
- }
}
return;
}
-struct script_data* push_val2(struct script_stack* stack, enum c_op type, int val, struct DBMap** ref);
-
/// Retrieves the value of a reference identified by uid (variable, constant, param)
/// The value is left in the top of the stack and needs to be removed manually.
-void* get_val2(struct script_state* st, int uid, struct DBMap** ref)
-{
+void* get_val2(struct script_state* st, int uid, struct DBMap** ref) {
struct script_data* data;
- push_val2(st->stack, C_NAME, uid, ref);
+ script->push_val(st->stack, C_NAME, uid, ref);
data = script_getdatatop(st, -1);
- get_val(st, data);
+ script->get_val(st, data);
return (data->type == C_INT ? (void*)__64BPTRSIZE(data->u.num) : (void*)__64BPTRSIZE(data->u.str));
}
@@ -2466,7 +2425,7 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, const char* nam
const char* str = (const char*)value;
switch (prefix) {
case '@':
- return pc_setregstr(sd, num, str);
+ return pc->setregstr(sd, num, str);
case '$':
return mapreg_setregstr(num, str);
case '#':
@@ -2484,9 +2443,9 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, const char* nam
}
return 1;
case '\'':
- if( st->instance_id ) {
- idb_remove(instance[st->instance_id].vars, num);
- if( str[0] ) idb_put(instance[st->instance_id].vars, num, aStrdup(str));
+ if( st->instance_id >= 0 ) {
+ idb_remove(instances[st->instance_id].vars, num);
+ if( str[0] ) idb_put(instances[st->instance_id].vars, num, aStrdup(str));
}
return 1;
default:
@@ -2496,9 +2455,9 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, const char* nam
else
{// integer variable
int val = (int)__64BPTRSIZE(value);
- if(str_data[num&0x00ffffff].type == C_PARAM)
+ if(script->str_data[num&0x00ffffff].type == C_PARAM)
{
- if( pc_setparam(sd, str_data[num&0x00ffffff].val, val) == 0 )
+ if( pc->setparam(sd, script->str_data[num&0x00ffffff].val, val) == 0 )
{
if( st != NULL )
{
@@ -2513,7 +2472,7 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, const char* nam
switch (prefix) {
case '@':
- return pc_setreg(sd, num, val);
+ return pc->setreg(sd, num, val);
case '$':
return mapreg_setreg(num, val);
case '#':
@@ -2532,10 +2491,10 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, const char* nam
}
return 1;
case '\'':
- if( st->instance_id ) {
- idb_remove(instance[st->instance_id].vars, num);
+ if( st->instance_id >= 0 ) {
+ idb_remove(instances[st->instance_id].vars, num);
if( val != 0 )
- idb_iput(instance[st->instance_id].vars, num, val);
+ idb_iput(instances[st->instance_id].vars, num, val);
}
return 1;
default:
@@ -2559,7 +2518,7 @@ const char* conv_str(struct script_state* st, struct script_data* data)
{
char* p;
- get_val(st, data);
+ script->get_val(st, data);
if( data_isstring(data) )
{// nothing to convert
}
@@ -2573,7 +2532,7 @@ const char* conv_str(struct script_state* st, struct script_data* data)
}
else if( data_isreference(data) )
{// reference -> string
- //##TODO when does this happen (check get_val) [FlavioJS]
+ //##TODO when does this happen (check script->get_val) [FlavioJS]
data->type = C_CONSTSTR;
data->u.str = reference_getname(data);
}
@@ -2593,7 +2552,7 @@ int conv_num(struct script_state* st, struct script_data* data) {
char* p;
long num;
- get_val(st, data);
+ script->get_val(st, data);
if( data_isint(data) )
{// nothing to convert
}
@@ -2648,8 +2607,7 @@ int conv_num(struct script_state* st, struct script_data* data) {
//
/// Increases the size of the stack
-void stack_expand(struct script_stack* stack)
-{
+void stack_expand(struct script_stack* stack) {
stack->sp_max += 64;
stack->stack_data = (struct script_data*)aRealloc(stack->stack_data,
stack->sp_max * sizeof(stack->stack_data[0]) );
@@ -2657,12 +2615,8 @@ void stack_expand(struct script_stack* stack)
64 * sizeof(stack->stack_data[0]) );
}
-/// Pushes a value into the stack
-#define push_val(stack,type,val) push_val2(stack, type, val, NULL)
-
/// Pushes a value into the stack (with reference)
-struct script_data* push_val2(struct script_stack* stack, enum c_op type, int val, struct DBMap** ref)
-{
+struct script_data* push_val(struct script_stack* stack, enum c_op type, int val, struct DBMap** ref) {
if( stack->sp >= stack->sp_max )
stack_expand(stack);
stack->stack_data[stack->sp].type = type;
@@ -2697,28 +2651,26 @@ struct script_data* push_retinfo(struct script_stack* stack, struct script_retin
}
/// Pushes a copy of the target position into the stack
-struct script_data* push_copy(struct script_stack* stack, int pos)
-{
- switch( stack->stack_data[pos].type )
- {
- case C_CONSTSTR:
- return push_str(stack, C_CONSTSTR, stack->stack_data[pos].u.str);
- break;
- case C_STR:
- return push_str(stack, C_STR, aStrdup(stack->stack_data[pos].u.str));
- break;
- case C_RETINFO:
- ShowFatalError("script:push_copy: can't create copies of C_RETINFO. Exiting...\n");
- exit(1);
- break;
- default:
- return push_val2(
- stack,stack->stack_data[pos].type,
- stack->stack_data[pos].u.num,
- stack->stack_data[pos].ref
- );
- break;
- }
+struct script_data* push_copy(struct script_stack* stack, int pos) {
+ switch( stack->stack_data[pos].type ) {
+ case C_CONSTSTR:
+ return script->push_str(stack, C_CONSTSTR, stack->stack_data[pos].u.str);
+ break;
+ case C_STR:
+ return script->push_str(stack, C_STR, aStrdup(stack->stack_data[pos].u.str));
+ break;
+ case C_RETINFO:
+ ShowFatalError("script:push_copy: can't create copies of C_RETINFO. Exiting...\n");
+ exit(1);
+ break;
+ default:
+ return script->push_val(
+ stack,stack->stack_data[pos].type,
+ stack->stack_data[pos].u.num,
+ stack->stack_data[pos].ref
+ );
+ break;
+ }
}
/// Removes the values in indexes [start,end[ from the stack.
@@ -2799,45 +2751,64 @@ void script_free_code(struct script_code* code)
/// @param rid Who is running the script (attached player)
/// @param oid Where the code is being run (npc 'object')
/// @return Script state
-struct script_state* script_alloc_state(struct script_code* script, int pos, int rid, int oid)
-{
+struct script_state* script_alloc_state(struct script_code* rootscript, int pos, int rid, int oid) {
struct script_state* st;
- CREATE(st, struct script_state, 1);
- st->stack = (struct script_stack*)aMalloc(sizeof(struct script_stack));
+
+ st = ers_alloc(script->st_ers, struct script_state);
+ st->stack = ers_alloc(script->stack_ers, struct script_stack);
st->stack->sp = 0;
st->stack->sp_max = 64;
CREATE(st->stack->stack_data, struct script_data, st->stack->sp_max);
st->stack->defsp = st->stack->sp;
st->stack->var_function = idb_alloc(DB_OPT_RELEASE_DATA);
st->state = RUN;
- st->script = script;
- //st->scriptroot = script;
+ st->script = rootscript;
st->pos = pos;
st->rid = rid;
st->oid = oid;
st->sleep.timer = INVALID_TIMER;
st->npc_item_flag = battle_config.item_enabled_npc;
+
+ if( !st->script->script_vars )
+ st->script->script_vars = idb_alloc(DB_OPT_RELEASE_DATA);
+
+ st->id = script->next_id++;
+ script->active_scripts++;
+
+ idb_put(script->st_db, st->id, st);
+
return st;
}
/// Frees a script state.
///
/// @param st Script state
-void script_free_state(struct script_state* st)
-{
- if(st->bk_st)
- {// backup was not restored
- ShowDebug("script_free_state: Previous script state lost (rid=%d, oid=%d, state=%d, bk_npcid=%d).\n", st->bk_st->rid, st->bk_st->oid, st->bk_st->state, st->bk_npcid);
+void script_free_state(struct script_state* st) {
+ if( idb_exists(script->st_db,st->id) ) {
+ if(st->bk_st) {// backup was not restored
+ ShowDebug("script_free_state: Previous script state lost (rid=%d, oid=%d, state=%d, bk_npcid=%d).\n", st->bk_st->rid, st->bk_st->oid, st->bk_st->state, st->bk_npcid);
+ }
+
+ if( st->sleep.timer != INVALID_TIMER )
+ iTimer->delete_timer(st->sleep.timer, run_script_timer);
+ if( st->stack ) {
+ script_free_vars(st->stack->var_function);
+ script->pop_stack(st, 0, st->stack->sp);
+ aFree(st->stack->stack_data);
+ ers_free(script->stack_ers, st->stack);
+ st->stack = NULL;
+ }
+ if( st->script && st->script->script_vars && !db_size(st->script->script_vars) ) {
+ script_free_vars(st->script->script_vars);
+ st->script->script_vars = NULL;
+ }
+ st->pos = -1;
+ idb_remove(script->st_db, st->id);
+ ers_free(script->st_ers, st);
+ if( --script->active_scripts == 0 ) {
+ script->next_id = 0;
+ }
}
- if( st->sleep.timer != INVALID_TIMER )
- delete_timer(st->sleep.timer, run_script_timer);
- script_free_vars(st->stack->var_function);
- pop_stack(st, 0, st->stack->sp);
- aFree(st->stack->stack_data);
- aFree(st->stack);
- st->stack = NULL;
- st->pos = -1;
- aFree(st);
}
//
@@ -2882,7 +2853,7 @@ int pop_val(struct script_state* st)
if(st->stack->sp<=0)
return 0;
st->stack->sp--;
- get_val(st,&(st->stack->stack_data[st->stack->sp]));
+ script->get_val(st,&(st->stack->stack_data[st->stack->sp]));
if(st->stack->stack_data[st->stack->sp].type==C_INT)
return st->stack->stack_data[st->stack->sp].u.num;
return 0;
@@ -2896,7 +2867,7 @@ void op_3(struct script_state* st, int op)
int flag = 0;
data = script_getdatatop(st, -3);
- get_val(st, data);
+ script->get_val(st, data);
if( data_isstring(data) )
flag = data->u.str[0];// "" -> false
@@ -3040,8 +3011,8 @@ void op_2(struct script_state *st, int op)
st->op2ref = 0;
}
- get_val(st, left);
- get_val(st, right);
+ script->get_val(st, left);
+ script->get_val(st, right);
// automatic conversions
switch( op )
@@ -3102,7 +3073,7 @@ void op_1(struct script_state* st, int op)
int i1;
data = script_getdatatop(st, -1);
- get_val(st, data);
+ script->get_val(st, data);
if( !data_isint(data) )
{// not a number
@@ -3140,7 +3111,7 @@ static void script_check_buildin_argtype(struct script_state* st, int func)
{
char type;
int idx, invalid = 0;
- char* sf = script->buildin[str_data[func].val];
+ char* sf = script->buildin[script->str_data[func].val];
for( idx = 2; script_hasdata(st, idx); idx++ ) {
struct script_data* data = script_getdata(st, idx);
@@ -3236,7 +3207,7 @@ int run_func(struct script_state *st)
st->end = end_sp;
data = &st->stack->stack_data[st->start];
- if( data->type == C_NAME && str_data[data->u.num].type == C_FUNC )
+ if( data->type == C_NAME && script->str_data[data->u.num].type == C_FUNC )
func = data->u.num;
else
{
@@ -3252,11 +3223,11 @@ int run_func(struct script_state *st)
script_check_buildin_argtype(st, func);
}
- if(str_data[func].func){
- if (!(str_data[func].func(st))) //Report error
+ if(script->str_data[func].func){
+ if (!(script->str_data[func].func(st))) //Report error
script_reportsrc(st);
} else {
- ShowError("script:run_func: '%s' (id=%d type=%s) has no C function. please report this!!!\n", get_str(func), func, script_op2name(str_data[func].type));
+ ShowError("script:run_func: '%s' (id=%d type=%s) has no C function. please report this!!!\n", get_str(func), func, script_op2name(script->str_data[func].type));
script_reportsrc(st);
st->state = END;
}
@@ -3265,14 +3236,14 @@ int run_func(struct script_state *st)
if( st->state == RERUNLINE )
return 0;
- pop_stack(st, st->start, st->end);
+ script->pop_stack(st, st->start, st->end);
if( st->state == RETFUNC )
{// return from a user-defined function
struct script_retinfo* ri;
int olddefsp = st->stack->defsp;
int nargs;
- pop_stack(st, st->stack->defsp, st->start);// pop distractions from the stack
+ script->pop_stack(st, st->stack->defsp, st->start);// pop distractions from the stack
if( st->stack->defsp < 1 || st->stack->stack_data[st->stack->defsp-1].type != C_RETINFO )
{
ShowWarning("script:run_func: return without callfunc or callsub!\n");
@@ -3290,7 +3261,7 @@ int run_func(struct script_state *st)
st->stack->defsp = ri->defsp;
memset(ri, 0, sizeof(struct script_retinfo));
- pop_stack(st, olddefsp-nargs-1, olddefsp);// pop arguments and retinfo
+ script->pop_stack(st, olddefsp-nargs-1, olddefsp);// pop arguments and retinfo
st->state = GOTO;
}
@@ -3301,74 +3272,50 @@ int run_func(struct script_state *st)
/*==========================================
* script execution
*------------------------------------------*/
-void run_script(struct script_code *rootscript,int pos,int rid,int oid)
-{
+void run_script(struct script_code *rootscript,int pos,int rid,int oid) {
struct script_state *st;
if( rootscript == NULL || pos < 0 )
return;
-
+
// TODO In jAthena, this function can take over the pending script in the player. [FlavioJS]
// It is unclear how that can be triggered, so it needs the be traced/checked in more detail.
// NOTE At the time of this change, this function wasn't capable of taking over the script state because st->scriptroot was never set.
st = script_alloc_state(rootscript, pos, rid, oid);
+
run_script_main(st);
}
-void script_stop_sleeptimers(int id)
-{
+void script_stop_instances(int id) {
+ DBIterator *iter;
struct script_state* st;
- for(;;)
- {
- st = (struct script_state*)linkdb_erase(&sleep_db,(void*)__64BPTRSIZE(id));
- if( st == NULL )
- break; // no more sleep timers
- script_free_state(st);
+
+ if( !script->active_scripts )
+ return;//dont even bother.
+
+ iter = db_iterator(script->st_db);
+
+ for( st = dbi_first(iter); dbi_exists(iter); st = dbi_next(iter) ) {
+ if( st->oid == id ) {
+ script_free_state(st);
+ }
}
-}
-
-/*==========================================
- * Delete the specified node from sleep_db
- *------------------------------------------*/
-struct linkdb_node* script_erase_sleepdb(struct linkdb_node *n)
-{
- struct linkdb_node *retnode;
-
- if( n == NULL)
- return NULL;
- if( n->prev == NULL )
- sleep_db = n->next;
- else
- n->prev->next = n->next;
- if( n->next )
- n->next->prev = n->prev;
- retnode = n->next;
- aFree( n );
- return retnode; // The following; return retnode
+
+ dbi_destroy(iter);
}
/*==========================================
* Timer function for sleep
*------------------------------------------*/
-int run_script_timer(int tid, unsigned int tick, int id, intptr_t data)
-{
+int run_script_timer(int tid, unsigned int tick, int id, intptr_t data) {
struct script_state *st = (struct script_state *)data;
- struct linkdb_node *node = (struct linkdb_node *)sleep_db;
- TBL_PC *sd = map_id2sd(st->rid);
+ TBL_PC *sd = iMap->id2sd(st->rid);
- if((sd && sd->status.char_id != id) || (st->rid && !sd))
- { //Character mismatch. Cancel execution.
+ if((sd && sd->status.char_id != id) || (st->rid && !sd)) { //Character mismatch. Cancel execution.
st->rid = 0;
st->state = END;
}
- while( node && st->sleep.timer != INVALID_TIMER ) {
- if( (int)__64BPTRSIZE(node->key) == st->oid && ((struct script_state *)node->data)->sleep.timer == st->sleep.timer ) {
- script_erase_sleepdb(node);
- st->sleep.timer = INVALID_TIMER;
- break;
- }
- node = node->next;
- }
+ st->sleep.timer = INVALID_TIMER;
if(st->state != RERUNLINE)
st->sleep.tick = 0;
run_script_main(st);
@@ -3383,9 +3330,10 @@ static void script_detach_state(struct script_state* st, bool dequeue_event)
{
struct map_session_data* sd;
- if(st->rid && (sd = map_id2sd(st->rid))!=NULL) {
+ if(st->rid && (sd = iMap->id2sd(st->rid))!=NULL) {
sd->st = st->bk_st;
sd->npc_id = st->bk_npcid;
+ sd->state.dialog = 0;
if(st->bk_st) {
//Remove tag for removal.
st->bk_st = NULL;
@@ -3399,15 +3347,13 @@ static void script_detach_state(struct script_state* st, bool dequeue_event)
* We're done with this NPC session, so we cancel the timer (if existent) and move on
**/
if( sd->npc_idle_timer != INVALID_TIMER ) {
- delete_timer(sd->npc_idle_timer,npc_rr_secure_timeout_timer);
+ iTimer->delete_timer(sd->npc_idle_timer,npc_rr_secure_timeout_timer);
sd->npc_idle_timer = INVALID_TIMER;
}
#endif
npc_event_dequeue(sd);
}
- }
- else if(st->bk_st)
- {// rid was set to 0, before detaching the script state
+ } else if(st->bk_st) { // rid was set to 0, before detaching the script state
ShowError("script_detach_state: Found previous script state without attached player (rid=%d, oid=%d, state=%d, bk_npcid=%d)\n", st->bk_st->rid, st->bk_st->oid, st->bk_st->state, st->bk_npcid);
script_reportsrc(st->bk_st);
@@ -3423,7 +3369,7 @@ static void script_attach_state(struct script_state* st)
{
struct map_session_data* sd;
- if(st->rid && (sd = map_id2sd(st->rid))!=NULL)
+ if(st->rid && (sd = iMap->id2sd(st->rid))!=NULL)
{
if(st!=sd->st)
{
@@ -3442,8 +3388,8 @@ static void script_attach_state(struct script_state* st)
**/
#ifdef SECURE_NPCTIMEOUT
if( sd->npc_idle_timer == INVALID_TIMER )
- sd->npc_idle_timer = add_timer(gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc_rr_secure_timeout_timer,sd->bl.id,0);
- sd->npc_idle_tick = gettick();
+ sd->npc_idle_timer = iTimer->add_timer(iTimer->gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc_rr_secure_timeout_timer,sd->bl.id,0);
+ sd->npc_idle_tick = iTimer->gettick();
#endif
}
}
@@ -3456,14 +3402,16 @@ void run_script_main(struct script_state *st)
int cmdcount = script_config.check_cmdcount;
int gotocount = script_config.check_gotocount;
TBL_PC *sd;
- struct script_stack *stack=st->stack;
+ struct script_stack *stack = st->stack;
struct npc_data *nd;
script_attach_state(st);
- nd = map_id2nd(st->oid);
- if( nd && map[nd->bl.m].instance_id > 0 )
+ nd = iMap->id2nd(st->oid);
+ if( nd && nd->bl.m >= 0 )
st->instance_id = map[nd->bl.m].instance_id;
+ else
+ st->instance_id = -1;
if(st->state == RERUNLINE) {
run_func(st);
@@ -3472,86 +3420,85 @@ void run_script_main(struct script_state *st)
} else if(st->state != END)
st->state = RUN;
- while(st->state == RUN)
- {
+ while( st->state == RUN ){
enum c_op c = get_com(st->script->script_buf,&st->pos);
switch(c){
- case C_EOL:
- if( stack->defsp > stack->sp )
- ShowError("script:run_script_main: unexpected stack position (defsp=%d sp=%d). please report this!!!\n", stack->defsp, stack->sp);
- else
- pop_stack(st, stack->defsp, stack->sp);// pop unused stack data. (unused return value)
- break;
- case C_INT:
- push_val(stack,C_INT,get_num(st->script->script_buf,&st->pos));
- break;
- case C_POS:
- case C_NAME:
- push_val(stack,c,GETVALUE(st->script->script_buf,st->pos));
- st->pos+=3;
- break;
- case C_ARG:
- push_val(stack,c,0);
- break;
- case C_STR:
- push_str(stack,C_CONSTSTR,(char*)(st->script->script_buf+st->pos));
- while(st->script->script_buf[st->pos++]);
- break;
- case C_FUNC:
- run_func(st);
- if(st->state==GOTO){
- st->state = RUN;
- if( !st->freeloop && gotocount>0 && (--gotocount)<=0 ){
- ShowError("run_script: infinity loop !\n");
- script_reportsrc(st);
- st->state=END;
+ case C_EOL:
+ if( stack->defsp > stack->sp )
+ ShowError("script:run_script_main: unexpected stack position (defsp=%d sp=%d). please report this!!!\n", stack->defsp, stack->sp);
+ else
+ script->pop_stack(st, stack->defsp, stack->sp);// pop unused stack data. (unused return value)
+ break;
+ case C_INT:
+ script->push_val(stack,C_INT,get_num(st->script->script_buf,&st->pos),NULL);
+ break;
+ case C_POS:
+ case C_NAME:
+ script->push_val(stack,c,GETVALUE(st->script->script_buf,st->pos),NULL);
+ st->pos+=3;
+ break;
+ case C_ARG:
+ script->push_val(stack,c,0,NULL);
+ break;
+ case C_STR:
+ script->push_str(stack,C_CONSTSTR,(char*)(st->script->script_buf+st->pos));
+ while(st->script->script_buf[st->pos++]);
+ break;
+ case C_FUNC:
+ run_func(st);
+ if(st->state==GOTO){
+ st->state = RUN;
+ if( !st->freeloop && gotocount>0 && (--gotocount)<=0 ){
+ ShowError("run_script: infinity loop !\n");
+ script_reportsrc(st);
+ st->state=END;
+ }
}
- }
- break;
+ break;
- case C_REF:
- st->op2ref = 1;
- break;
+ case C_REF:
+ st->op2ref = 1;
+ break;
- case C_NEG:
- case C_NOT:
- case C_LNOT:
- op_1(st ,c);
- break;
+ case C_NEG:
+ case C_NOT:
+ case C_LNOT:
+ op_1(st ,c);
+ break;
- case C_ADD:
- case C_SUB:
- case C_MUL:
- case C_DIV:
- case C_MOD:
- case C_EQ:
- case C_NE:
- case C_GT:
- case C_GE:
- case C_LT:
- case C_LE:
- case C_AND:
- case C_OR:
- case C_XOR:
- case C_LAND:
- case C_LOR:
- case C_R_SHIFT:
- case C_L_SHIFT:
- op_2(st, c);
- break;
+ case C_ADD:
+ case C_SUB:
+ case C_MUL:
+ case C_DIV:
+ case C_MOD:
+ case C_EQ:
+ case C_NE:
+ case C_GT:
+ case C_GE:
+ case C_LT:
+ case C_LE:
+ case C_AND:
+ case C_OR:
+ case C_XOR:
+ case C_LAND:
+ case C_LOR:
+ case C_R_SHIFT:
+ case C_L_SHIFT:
+ op_2(st, c);
+ break;
- case C_OP3:
- op_3(st, c);
- break;
+ case C_OP3:
+ op_3(st, c);
+ break;
- case C_NOP:
- st->state=END;
- break;
+ case C_NOP:
+ st->state=END;
+ break;
- default:
- ShowError("unknown command : %d @ %d\n",c,st->pos);
- st->state=END;
- break;
+ default:
+ ShowError("unknown command : %d @ %d\n",c,st->pos);
+ st->state=END;
+ break;
}
if( !st->freeloop && cmdcount>0 && (--cmdcount)<=0 ){
ShowError("run_script: infinity loop !\n");
@@ -3564,13 +3511,11 @@ void run_script_main(struct script_state *st)
//Restore previous script
script_detach_state(st, false);
//Delay execution
- sd = map_id2sd(st->rid); // Get sd since script might have attached someone while running. [Inkfish]
+ sd = iMap->id2sd(st->rid); // Get sd since script might have attached someone while running. [Inkfish]
st->sleep.charid = sd?sd->status.char_id:0;
- st->sleep.timer = add_timer(gettick()+st->sleep.tick,
+ st->sleep.timer = iTimer->add_timer(iTimer->gettick()+st->sleep.tick,
run_script_timer, st->sleep.charid, (intptr_t)st);
- linkdb_insert(&sleep_db, (void*)__64BPTRSIZE(st->oid), st);
- }
- else if(st->state != END && st->rid){
+ } else if(st->state != END && st->rid){
//Resume later (st is already attached to player).
if(st->bk_st) {
ShowWarning("Unable to restore stack! Double continuation!\n");
@@ -3585,8 +3530,7 @@ void run_script_main(struct script_state *st)
}
} else {
//Dispose of script.
- if ((sd = map_id2sd(st->rid))!=NULL)
- { //Restore previous stack and save char.
+ if ((sd = iMap->id2sd(st->rid))!=NULL) { //Restore previous stack and save char.
if(sd->state.using_fake_npc){
clif->clearunit_single(sd->npc_id, CLR_OUTSIGHT, sd->fd);
sd->state.using_fake_npc = 0;
@@ -3705,14 +3649,14 @@ void script_cleararray_pc(struct map_session_data* sd, const char* varname, void
{
for( idx = 0; idx < SCRIPT_MAX_ARRAYSIZE; idx++ )
{
- pc_setregstr(sd, reference_uid(key, idx), (const char*)value);
+ pc->setregstr(sd, reference_uid(key, idx), (const char*)value);
}
}
else
{
for( idx = 0; idx < SCRIPT_MAX_ARRAYSIZE; idx++ )
{
- pc_setreg(sd, reference_uid(key, idx), (int)__64BPTRSIZE(value));
+ pc->setreg(sd, reference_uid(key, idx), (int)__64BPTRSIZE(value));
}
}
}
@@ -3740,11 +3684,11 @@ void script_setarray_pc(struct map_session_data* sd, const char* varname, uint8
if( is_string_variable(varname) )
{
- pc_setregstr(sd, reference_uid(key, idx), (const char*)value);
+ pc->setregstr(sd, reference_uid(key, idx), (const char*)value);
}
else
{
- pc_setreg(sd, reference_uid(key, idx), (int)__64BPTRSIZE(value));
+ pc->setreg(sd, reference_uid(key, idx), (int)__64BPTRSIZE(value));
}
if( refcache )
@@ -3757,6 +3701,9 @@ void script_setarray_pc(struct map_session_data* sd, const char* varname, uint8
*------------------------------------------*/
void do_final_script(void) {
int i;
+ DBIterator *iter;
+ struct script_state *st;
+
#ifdef DEBUG_HASH
if (battle_config.etc_log)
{
@@ -3773,7 +3720,7 @@ void do_final_script(void) {
memset(count, 0, sizeof(count));
fprintf(fp,"num : hash : data_name\n");
fprintf(fp,"---------------------------------------------------------------\n");
- for(i=LABEL_START; i<str_num; i++) {
+ for(i=LABEL_START; i<script->str_num; i++) {
unsigned int h = calc_hash(get_str(i));
fprintf(fp,"%04d : %4u : %s\n",i,h, get_str(i));
++count[h];
@@ -3817,20 +3764,19 @@ void do_final_script(void) {
db_destroy(scriptlabel_db);
userfunc_db->destroy(userfunc_db, db_script_free_code_sub);
autobonus_db->destroy(autobonus_db, db_script_free_code_sub);
- if(sleep_db) {
- struct linkdb_node *n = (struct linkdb_node *)sleep_db;
- while(n) {
- struct script_state *st = (struct script_state *)n->data;
- script_free_state(st);
- n = n->next;
- }
- linkdb_final(&sleep_db);
- }
- if (str_data)
- aFree(str_data);
- if (str_buf)
- aFree(str_buf);
+ iter = db_iterator(script->st_db);
+
+ for( st = dbi_first(iter); dbi_exists(iter); st = dbi_next(iter) ) {
+ script_free_state(st);
+ }
+
+ dbi_destroy(iter);
+
+ if (script->str_data)
+ aFree(script->str_data);
+ if (script->str_buf)
+ aFree(script->str_buf);
for( i = 0; i < atcommand->binding_count; i++ ) {
aFree(atcommand->binding[i]);
@@ -3845,17 +3791,48 @@ void do_final_script(void) {
script->buildin[i] = NULL;
}
}
-
- aFree(script->buildin);
+ aFree(script->buildin);
+
+ if( script->hqs ) {
+ for( i = 0; i < script->hqs; i++ ) {
+ if( script->hq[i].item != NULL )
+ aFree(script->hq[i].item);
+ }
+ }
+ if( script->hqis ) {
+ for( i = 0; i < script->hqis; i++ ) {
+ if( script->hqi[i].item != NULL )
+ aFree(script->hqi[i].item);
+ }
+ }
+ if( script->hq != NULL )
+ aFree(script->hq);
+ if( script->hqi != NULL )
+ aFree(script->hqi);
+ if( script->word_buf != NULL )
+ aFree(script->word_buf);
+
+ ers_destroy(script->st_ers);
+ ers_destroy(script->stack_ers);
+
+ db_destroy(script->st_db);
}
/*==========================================
* Initialization
*------------------------------------------*/
void do_init_script(void) {
+ script->st_db = idb_alloc(DB_OPT_BASE);
userfunc_db = strdb_alloc(DB_OPT_DUP_KEY,0);
scriptlabel_db = strdb_alloc(DB_OPT_DUP_KEY,50);
autobonus_db = strdb_alloc(DB_OPT_DUP_KEY,0);
+
+ script->st_ers = ers_new(sizeof(struct script_state), "script.c::st_ers", ERS_OPT_NONE);
+ script->stack_ers = ers_new(sizeof(struct script_stack), "script.c::script_stack", ERS_OPT_NONE);
+
+ ers_chunk_size(script->st_ers, 10);
+ ers_chunk_size(script->stack_ers, 10);
+
script->parse_builtin();
read_constdb();
mapreg_init();
@@ -3863,6 +3840,8 @@ void do_init_script(void) {
int script_reload() {
int i;
+ DBIterator *iter;
+ struct script_state *st;
userfunc_db->clear(userfunc_db, db_script_free_code_sub);
db_clear(scriptlabel_db);
@@ -3876,15 +3855,16 @@ int script_reload() {
atcommand->binding_count = 0;
- if(sleep_db) {
- struct linkdb_node *n = (struct linkdb_node *)sleep_db;
- while(n) {
- struct script_state *st = (struct script_state *)n->data;
- script_free_state(st);
- n = n->next;
- }
- linkdb_final(&sleep_db);
+ iter = db_iterator(script->st_db);
+
+ for( st = dbi_first(iter); dbi_exists(iter); st = dbi_next(iter) ) {
+ script_free_state(st);
}
+
+ dbi_destroy(iter);
+
+ db_clear(script->st_db);
+
mapreg_reload();
return 0;
}
@@ -3904,22 +3884,17 @@ int script_reload() {
/// If a dialog doesn't exist yet, one is created.
///
/// mes "<message>";
-BUILDIN(mes)
-{
+BUILDIN(mes) {
TBL_PC* sd = script_rid2sd(st);
if( sd == NULL )
return true;
- if( !script_hasdata(st, 3) )
- {// only a single line detected in the script
+ if( !script_hasdata(st, 3) ) {// only a single line detected in the script
clif->scriptmes(sd, st->oid, script_getstr(st, 2));
- }
- else
- {// parse multiple lines as they exist
+ } else {// parse multiple lines as they exist
int i;
- for( i = 2; script_hasdata(st, i); i++ )
- {
+ for( i = 2; script_hasdata(st, i); i++ ) {
// send the message to the client
clif->scriptmes(sd, st->oid, script_getstr(st, i));
}
@@ -3951,15 +3926,14 @@ BUILDIN(next)
/// The dialog is closed when the button is pressed.
///
/// close;
-BUILDIN(close)
-{
+BUILDIN(close) {
TBL_PC* sd;
sd = script_rid2sd(st);
if( sd == NULL )
return true;
- st->state = CLOSE;
+ st->state = sd->state.dialog == 1 ? CLOSE : END;
clif->scriptclose(sd, st->oid);
return true;
}
@@ -3968,8 +3942,7 @@ BUILDIN(close)
/// The dialog is closed and the script continues when the button is pressed.
///
/// close2;
-BUILDIN(close2)
-{
+BUILDIN(close2) {
TBL_PC* sd;
sd = script_rid2sd(st);
@@ -4093,7 +4066,7 @@ BUILDIN(menu)
* menus beyond this length crash the client (see bugreport:6402)
**/
if( StrBuf->Length(&buf) >= 2047 ) {
- struct npc_data * nd = map_id2nd(st->oid);
+ struct npc_data * nd = iMap->id2nd(st->oid);
char* menu;
CREATE(menu, char, 2048);
safestrncpy(menu, StrBuf->Value(&buf), 2047);
@@ -4149,7 +4122,7 @@ BUILDIN(menu)
st->state = END;
return false;
}
- pc_setreg(sd, add_str("@menu"), menu);
+ pc->setreg(sd, add_str("@menu"), menu);
st->pos = script_getnum(st, i + 1);
st->state = GOTO;
}
@@ -4198,7 +4171,7 @@ BUILDIN(select)
* menus beyond this length crash the client (see bugreport:6402)
**/
if( StrBuf->Length(&buf) >= 2047 ) {
- struct npc_data * nd = map_id2nd(st->oid);
+ struct npc_data * nd = iMap->id2nd(st->oid);
char* menu;
CREATE(menu, char, 2048);
safestrncpy(menu, StrBuf->Value(&buf), 2047);
@@ -4226,7 +4199,7 @@ BUILDIN(select)
if( sd->npc_menu <= 0 )
break;// entry found
}
- pc_setreg(sd, add_str("@menu"), menu);
+ pc->setreg(sd, add_str("@menu"), menu);
script_pushint(st, menu);
st->state = RUN;
}
@@ -4277,7 +4250,7 @@ BUILDIN(prompt)
* menus beyond this length crash the client (see bugreport:6402)
**/
if( StrBuf->Length(&buf) >= 2047 ) {
- struct npc_data * nd = map_id2nd(st->oid);
+ struct npc_data * nd = iMap->id2nd(st->oid);
char* menu;
CREATE(menu, char, 2048);
safestrncpy(menu, StrBuf->Value(&buf), 2047);
@@ -4297,7 +4270,7 @@ BUILDIN(prompt)
else if( sd->npc_menu == 0xff )
{// Cancel was pressed
sd->state.menu_or_input = 0;
- pc_setreg(sd, add_str("@menu"), 0xff);
+ pc->setreg(sd, add_str("@menu"), 0xff);
script_pushint(st, 0xff);
st->state = RUN;
}
@@ -4313,7 +4286,7 @@ BUILDIN(prompt)
if( sd->npc_menu <= 0 )
break;// entry found
}
- pc_setreg(sd, add_str("@menu"), menu);
+ pc->setreg(sd, add_str("@menu"), menu);
script_pushint(st, menu);
st->state = RUN;
}
@@ -4363,7 +4336,7 @@ BUILDIN(callfunc)
for( i = st->start+3, j = 0; i < st->end; i++, j++ )
{
- struct script_data* data = push_copy(st->stack,i);
+ struct script_data* data = script->push_copy(st->stack,i);
if( data_isreference(data) && !data->ref )
{
const char* name = reference_getname(data);
@@ -4411,7 +4384,7 @@ BUILDIN(callsub)
for( i = st->start+3, j = 0; i < st->end; i++, j++ )
{
- struct script_data* data = push_copy(st->stack,i);
+ struct script_data* data = script->push_copy(st->stack,i);
if( data_isreference(data) && !data->ref )
{
const char* name = reference_getname(data);
@@ -4461,7 +4434,7 @@ BUILDIN(getarg)
idx = script_getnum(st,2);
if( idx >= 0 && idx < ri->nargs )
- push_copy(st->stack, st->stack->defsp - 1 - ri->nargs + idx);
+ script->push_copy(st->stack, st->stack->defsp - 1 - ri->nargs + idx);
else if( script_hasdata(st,3) )
script_pushcopy(st, 3);
else
@@ -4492,7 +4465,7 @@ BUILDIN(return)
if( name[0] == '.' && name[1] == '@' )
{// scope variable
if( !data->ref || data->ref == (DBMap**)&st->stack->var_function )
- get_val(st, data);// current scope, convert to value
+ script->get_val(st, data);// current scope, convert to value
}
else if( name[0] == '.' && !data->ref )
{// script variable, link to current script
@@ -4559,11 +4532,11 @@ BUILDIN(warp)
y = script_getnum(st,4);
if(strcmp(str,"Random")==0)
- ret = pc_randomwarp(sd,CLR_TELEPORT);
+ ret = pc->randomwarp(sd,CLR_TELEPORT);
else if(strcmp(str,"SavePoint")==0 || strcmp(str,"Save")==0)
- ret = pc_setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
+ ret = pc->setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
else
- ret = pc_setpos(sd,mapindex_name2id(str),x,y,CLR_OUTSIGHT);
+ ret = pc->setpos(sd,mapindex_name2id(str),x,y,CLR_OUTSIGHT);
if( ret ) {
ShowError("buildin_warp: moving player '%s' to \"%s\",%d,%d failed.\n", sd->status.name, str, x, y);
@@ -4587,7 +4560,7 @@ static int buildin_areawarp_sub(struct block_list *bl,va_list ap)
y3 = va_arg(ap,int);
if(index == 0)
- pc_randomwarp((TBL_PC *)bl,CLR_TELEPORT);
+ pc->randomwarp((TBL_PC *)bl,CLR_TELEPORT);
else if(x3 && y3) {
int max, tx, ty, j = 0;
@@ -4600,12 +4573,12 @@ static int buildin_areawarp_sub(struct block_list *bl,va_list ap)
tx = rnd()%(x3-x2+1)+x2;
ty = rnd()%(y3-y2+1)+y2;
j++;
- } while( map_getcell(index,tx,ty,CELL_CHKNOPASS) && j < max );
+ } while( iMap->getcell(index,tx,ty,CELL_CHKNOPASS) && j < max );
- pc_setpos((TBL_PC *)bl,index,tx,ty,CLR_OUTSIGHT);
+ pc->setpos((TBL_PC *)bl,index,tx,ty,CLR_OUTSIGHT);
}
else
- pc_setpos((TBL_PC *)bl,index,x2,y2,CLR_OUTSIGHT);
+ pc->setpos((TBL_PC *)bl,index,x2,y2,CLR_OUTSIGHT);
return 0;
}
BUILDIN(areawarp)
@@ -4635,7 +4608,7 @@ BUILDIN(areawarp)
}
}
- if( (m = map_mapname2mapid(mapname)) < 0 )
+ if( (m = iMap->mapname2mapid(mapname)) < 0 )
return true;
if( strcmp(str,"Random") == 0 )
@@ -4643,7 +4616,7 @@ BUILDIN(areawarp)
else if( !(index=mapindex_name2id(str)) )
return true;
- map_foreachinarea(buildin_areawarp_sub, m,x0,y0,x1,y1, BL_PC, index,x2,y2,x3,y3);
+ iMap->foreachinarea(buildin_areawarp_sub, m,x0,y0,x1,y1, BL_PC, index,x2,y2,x3,y3);
return true;
}
@@ -4655,7 +4628,7 @@ static int buildin_areapercentheal_sub(struct block_list *bl,va_list ap)
int hp, sp;
hp = va_arg(ap, int);
sp = va_arg(ap, int);
- pc_percentheal((TBL_PC *)bl,hp,sp);
+ pc->percentheal((TBL_PC *)bl,hp,sp);
return 0;
}
BUILDIN(areapercentheal)
@@ -4672,10 +4645,10 @@ BUILDIN(areapercentheal)
hp=script_getnum(st,7);
sp=script_getnum(st,8);
- if( (m=map_mapname2mapid(mapname))< 0)
+ if( (m=iMap->mapname2mapid(mapname))< 0)
return true;
- map_foreachinarea(buildin_areapercentheal_sub,m,x0,y0,x1,y1,BL_PC,hp,sp);
+ iMap->foreachinarea(buildin_areapercentheal_sub,m,x0,y0,x1,y1,BL_PC,hp,sp);
return true;
}
@@ -4696,17 +4669,17 @@ BUILDIN(warpchar)
y=script_getnum(st,4);
a=script_getnum(st,5);
- sd = map_charid2sd(a);
+ sd = iMap->charid2sd(a);
if( sd == NULL )
return true;
if(strcmp(str, "Random") == 0)
- pc_randomwarp(sd, CLR_TELEPORT);
+ pc->randomwarp(sd, CLR_TELEPORT);
else
if(strcmp(str, "SavePoint") == 0)
- pc_setpos(sd, sd->status.save_point.map,sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
+ pc->setpos(sd, sd->status.save_point.map,sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
else
- pc_setpos(sd, mapindex_name2id(str), x, y, CLR_TELEPORT);
+ pc->setpos(sd, mapindex_name2id(str), x, y, CLR_TELEPORT);
return true;
}
@@ -4732,7 +4705,7 @@ BUILDIN(warpparty)
if ( script_hasdata(st,6) )
str2 = script_getstr(st,6);
- p = party_search(p_id);
+ p = party->search(p_id);
if(!p)
return true;
@@ -4780,20 +4753,20 @@ BUILDIN(warpparty)
{
case 0: // Random
if(!map[pl_sd->bl.m].flag.nowarp)
- pc_randomwarp(pl_sd,CLR_TELEPORT);
+ pc->randomwarp(pl_sd,CLR_TELEPORT);
break;
case 1: // SavePointAll
if(!map[pl_sd->bl.m].flag.noreturn)
- pc_setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_TELEPORT);
+ pc->setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_TELEPORT);
break;
case 2: // SavePoint
if(!map[pl_sd->bl.m].flag.noreturn)
- pc_setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
+ pc->setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
break;
case 3: // Leader
case 4: // m,x,y
if(!map[pl_sd->bl.m].flag.noreturn && !map[pl_sd->bl.m].flag.nowarp)
- pc_setpos(pl_sd,mapindex,x,y,CLR_TELEPORT);
+ pc->setpos(pl_sd,mapindex,x,y,CLR_TELEPORT);
break;
}
}
@@ -4841,19 +4814,19 @@ BUILDIN(warpguild)
{
case 0: // Random
if(!map[pl_sd->bl.m].flag.nowarp)
- pc_randomwarp(pl_sd,CLR_TELEPORT);
+ pc->randomwarp(pl_sd,CLR_TELEPORT);
break;
case 1: // SavePointAll
if(!map[pl_sd->bl.m].flag.noreturn)
- pc_setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_TELEPORT);
+ pc->setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_TELEPORT);
break;
case 2: // SavePoint
if(!map[pl_sd->bl.m].flag.noreturn)
- pc_setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
+ pc->setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
break;
case 3: // m,x,y
if(!map[pl_sd->bl.m].flag.noreturn && !map[pl_sd->bl.m].flag.nowarp)
- pc_setpos(pl_sd,mapindex_name2id(str),x,y,CLR_TELEPORT);
+ pc->setpos(pl_sd,mapindex_name2id(str),x,y,CLR_TELEPORT);
break;
}
}
@@ -4896,7 +4869,7 @@ BUILDIN(itemheal)
sd = script_rid2sd(st);
if (!sd) return true;
- pc_itemheal(sd,sd->itemid,hp,sp);
+ pc->itemheal(sd,sd->itemid,hp,sp);
return true;
}
/*==========================================
@@ -4923,7 +4896,7 @@ BUILDIN(percentheal)
if( sd->sc.data[SC_EXTREMITYFIST2] )
sp = 0;
#endif
- pc_percentheal(sd,hp,sp);
+ pc->percentheal(sd,hp,sp);
return true;
}
@@ -4946,7 +4919,7 @@ BUILDIN(jobchange)
if( sd == NULL )
return true;
- pc_jobchange(sd, job, upper);
+ pc->jobchange(sd, job, upper);
}
return true;
@@ -4958,7 +4931,7 @@ BUILDIN(jobchange)
BUILDIN(jobname)
{
int class_=script_getnum(st,2);
- script_pushconststr(st, (char*)job_name(class_));
+ script_pushconststr(st, (char*)pc->job_name(class_));
return true;
}
@@ -5087,7 +5060,7 @@ BUILDIN(set)
}
// push the maximum number of array values to the stack
- push_val(st->stack, C_INT, SCRIPT_MAX_ARRAYSIZE);
+ script->push_val(st->stack, C_INT, SCRIPT_MAX_ARRAYSIZE,NULL);
// call the copy array method directly
return buildin_copyarray(st);
@@ -5119,7 +5092,7 @@ static int32 getarraysize(struct script_state* st, int32 id, int32 idx, int isst
{
for( ; idx < SCRIPT_MAX_ARRAYSIZE; ++idx )
{
- char* str = (char*)get_val2(st, reference_uid(id, idx), ref);
+ char* str = (char*)script->get_val2(st, reference_uid(id, idx), ref);
if( str && *str )
ret = idx + 1;
script_removetop(st, -1, 0);
@@ -5129,7 +5102,7 @@ static int32 getarraysize(struct script_state* st, int32 id, int32 idx, int isst
{
for( ; idx < SCRIPT_MAX_ARRAYSIZE; ++idx )
{
- int32 num = (int32)__64BPTRSIZE(get_val2(st, reference_uid(id, idx), ref));
+ int32 num = (int32)__64BPTRSIZE(script->get_val2(st, reference_uid(id, idx), ref));
if( num )
ret = idx + 1;
script_removetop(st, -1, 0);
@@ -5322,7 +5295,7 @@ BUILDIN(copyarray)
{// destination might be overlapping the source - copy in reverse order
for( i = count - 1; i >= 0; --i )
{
- v = get_val2(st, reference_uid(id2, idx2 + i), reference_getref(data2));
+ v = script->get_val2(st, reference_uid(id2, idx2 + i), reference_getref(data2));
set_reg(st, sd, reference_uid(id1, idx1 + i), name1, v, reference_getref(data1));
script_removetop(st, -1, 0);
}
@@ -5333,7 +5306,7 @@ BUILDIN(copyarray)
{
if( idx2 + i < SCRIPT_MAX_ARRAYSIZE )
{
- v = get_val2(st, reference_uid(id2, idx2 + i), reference_getref(data2));
+ v = script->get_val2(st, reference_uid(id2, idx2 + i), reference_getref(data2));
set_reg(st, sd, reference_uid(id1, idx1 + i), name1, v, reference_getref(data1));
script_removetop(st, -1, 0);
}
@@ -5435,7 +5408,7 @@ BUILDIN(deletearray)
// move rest of the elements backward
for( ; start + count < end; ++start )
{
- void* v = get_val2(st, reference_uid(id, start + count), reference_getref(data));
+ void* v = script->get_val2(st, reference_uid(id, start + count), reference_getref(data));
set_reg(st, sd, reference_uid(id, start), name, v, reference_getref(data));
script_removetop(st, -1, 0);
}
@@ -5497,7 +5470,7 @@ BUILDIN(getelementofarray)
return false;// out of range
}
- push_val2(st->stack, C_NAME, reference_uid(id, i), reference_getref(data));
+ script->push_val(st->stack, C_NAME, reference_uid(id, i), reference_getref(data));
return true;
}
@@ -5520,7 +5493,7 @@ BUILDIN(setlook)
if( sd == NULL )
return true;
- pc_changelook(sd,type,val);
+ pc->changelook(sd,type,val);
return true;
}
@@ -5597,15 +5570,15 @@ BUILDIN(countitem)
}
data = script_getdata(st,2);
- get_val(st, data); // convert into value in case of a variable
+ script->get_val(st, data); // convert into value in case of a variable
if( data_isstring(data) )
{// item name
- id = itemdb_searchname(script->conv_str(st, data));
+ id = itemdb->search_name(script->conv_str(st, data));
}
else
{// item id
- id = itemdb_exists(script->conv_num(st, data));
+ id = itemdb->exists(script->conv_num(st, data));
}
if( id == NULL )
@@ -5644,15 +5617,15 @@ BUILDIN(countitem2)
}
data = script_getdata(st,2);
- get_val(st, data); // convert into value in case of a variable
+ script->get_val(st, data); // convert into value in case of a variable
if( data_isstring(data) )
{// item name
- id = itemdb_searchname(script->conv_str(st, data));
+ id = itemdb->search_name(script->conv_str(st, data));
}
else
{// item id
- id = itemdb_exists(script->conv_num(st, data));
+ id = itemdb->exists(script->conv_num(st, data));
}
if( id == NULL )
@@ -5709,15 +5682,15 @@ BUILDIN(checkweight)
script_pushint(st,0);
return false;
}
- slots = pc_inventoryblank(sd); //nb of empty slot
+ slots = pc->inventoryblank(sd); //nb of empty slot
for(i=2; i<nbargs; i=i+2){
data = script_getdata(st,i);
- get_val(st, data); // convert into value in case of a variable
+ script->get_val(st, data); // convert into value in case of a variable
if( data_isstring(data) ){// item name
- id = itemdb_searchname(script->conv_str(st, data));
+ id = itemdb->search_name(script->conv_str(st, data));
} else {// item id
- id = itemdb_exists(script->conv_num(st, data));
+ id = itemdb->exists(script->conv_num(st, data));
}
if( id == NULL ) {
ShowError("buildin_checkweight: Invalid item '%s'.\n", script_getstr(st,i)); // returns string, regardless of what it was
@@ -5740,7 +5713,7 @@ BUILDIN(checkweight)
return true;
}
- switch( pc_checkadditem(sd, nameid, amount) )
+ switch( pc->checkadditem(sd, nameid, amount) )
{
case ADDITEM_EXIST:
// item is already in inventory, but there is still space for the requested amount
@@ -5823,15 +5796,15 @@ BUILDIN(checkweight2)
fail = 1;
}
- slots = pc_inventoryblank(sd);
+ slots = pc->inventoryblank(sd);
for(i=0; i<nb_it; i++){
- nameid = (int32)__64BPTRSIZE(get_val2(st,reference_uid(id_it,idx_it+i),reference_getref(data_it)));
+ nameid = (int32)__64BPTRSIZE(script->get_val2(st,reference_uid(id_it,idx_it+i),reference_getref(data_it)));
script_removetop(st, -1, 0);
- amount = (int32)__64BPTRSIZE(get_val2(st,reference_uid(id_nb,idx_nb+i),reference_getref(data_nb)));
+ amount = (int32)__64BPTRSIZE(script->get_val2(st,reference_uid(id_nb,idx_nb+i),reference_getref(data_nb)));
script_removetop(st, -1, 0);
if(fail) continue; //cpntonie to depop rest
- if(itemdb_exists(nameid) == NULL ){
+ if(itemdb->exists(nameid) == NULL ){
ShowError("buildin_checkweight2: Invalid item '%d'.\n", nameid);
fail=1;
continue;
@@ -5846,7 +5819,7 @@ BUILDIN(checkweight2)
fail = 1;
continue;
}
- switch( pc_checkadditem(sd, nameid, amount) ) {
+ switch( pc->checkadditem(sd, nameid, amount) ) {
case ADDITEM_EXIST:
// item is already in inventory, but there is still space for the requested amount
break;
@@ -5885,11 +5858,11 @@ BUILDIN(getitem)
struct item_data *item_data;
data=script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) )
{// "<item name>"
const char *name=script->conv_str(st,data);
- if( (item_data = itemdb_searchname(name)) == NULL ){
+ if( (item_data = itemdb->search_name(name)) == NULL ){
ShowError("buildin_getitem: Nonexistant item %s requested.\n", name);
return false; //No item created.
}
@@ -5901,7 +5874,7 @@ BUILDIN(getitem)
nameid = -nameid;
flag = 1;
}
- if( nameid <= 0 || !(item_data = itemdb_exists(nameid)) ){
+ if( nameid <= 0 || !(item_data = itemdb->exists(nameid)) ){
ShowError("buildin_getitem: Nonexistant item %d requested.\n", nameid);
return false; //No item created.
}
@@ -5922,7 +5895,7 @@ BUILDIN(getitem)
it.identify=itemdb_isidentified2(item_data);
if( script_hasdata(st,4) )
- sd=map_id2sd(script_getnum(st,4)); // <Account ID>
+ sd=iMap->id2sd(script_getnum(st,4)); // <Account ID>
else
sd=script_rid2sd(st); // Attached player
@@ -5940,11 +5913,11 @@ BUILDIN(getitem)
// if not pet egg
if (!pet_create_egg(sd, nameid))
{
- if ((flag = pc_additem(sd, &it, get_count, LOG_TYPE_SCRIPT)))
+ if ((flag = pc->additem(sd, &it, get_count, LOG_TYPE_SCRIPT)))
{
clif->additem(sd, 0, 0, flag);
- if( pc_candrop(sd,&it) )
- map_addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ if( pc->candrop(sd,&it) )
+ iMap->addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
}
}
@@ -5965,7 +5938,7 @@ BUILDIN(getitem2)
struct script_data *data;
if( script_hasdata(st,11) )
- sd=map_id2sd(script_getnum(st,11)); // <Account ID>
+ sd=iMap->id2sd(script_getnum(st,11)); // <Account ID>
else
sd=script_rid2sd(st); // Attached player
@@ -5973,10 +5946,10 @@ BUILDIN(getitem2)
return true;
data=script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) ){
const char *name=script->conv_str(st,data);
- struct item_data *item_data = itemdb_searchname(name);
+ struct item_data *item_data = itemdb->search_name(name);
if( item_data )
nameid=item_data->nameid;
else
@@ -6000,7 +5973,7 @@ BUILDIN(getitem2)
if(nameid > 0) {
memset(&item_tmp,0,sizeof(item_tmp));
- item_data=itemdb_exists(nameid);
+ item_data=itemdb->exists(nameid);
if (item_data == NULL)
return -1;
if(item_data->type==IT_WEAPON || item_data->type==IT_ARMOR){
@@ -6038,11 +6011,11 @@ BUILDIN(getitem2)
// if not pet egg
if (!pet_create_egg(sd, nameid))
{
- if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_SCRIPT)))
+ if ((flag = pc->additem(sd, &item_tmp, get_count, LOG_TYPE_SCRIPT)))
{
clif->additem(sd, 0, 0, flag);
- if( pc_candrop(sd,&item_tmp) )
- map_addflooritem(&item_tmp,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ if( pc->candrop(sd,&item_tmp) )
+ iMap->addflooritem(&item_tmp,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
}
}
@@ -6064,7 +6037,7 @@ BUILDIN(rentitem)
int nameid = 0, flag;
data = script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( (sd = script_rid2sd(st)) == NULL )
return true;
@@ -6072,7 +6045,7 @@ BUILDIN(rentitem)
if( data_isstring(data) )
{
const char *name = script->conv_str(st,data);
- struct item_data *itd = itemdb_searchname(name);
+ struct item_data *itd = itemdb->search_name(name);
if( itd == NULL )
{
ShowError("buildin_rentitem: Nonexistant item %s requested.\n", name);
@@ -6083,7 +6056,7 @@ BUILDIN(rentitem)
else if( data_isint(data) )
{
nameid = script->conv_num(st,data);
- if( nameid <= 0 || !itemdb_exists(nameid) )
+ if( nameid <= 0 || !itemdb->exists(nameid) )
{
ShowError("buildin_rentitem: Nonexistant item %d requested.\n", nameid);
return false;
@@ -6101,7 +6074,7 @@ BUILDIN(rentitem)
it.identify = 1;
it.expire_time = (unsigned int)(time(NULL) + seconds);
- if( (flag = pc_additem(sd, &it, 1, LOG_TYPE_SCRIPT)) )
+ if( (flag = pc->additem(sd, &it, 1, LOG_TYPE_SCRIPT)) )
{
clif->additem(sd, 0, 0, flag);
return false;
@@ -6131,10 +6104,10 @@ BUILDIN(getnameditem)
}
data=script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) ){
const char *name=script->conv_str(st,data);
- struct item_data *item_data = itemdb_searchname(name);
+ struct item_data *item_data = itemdb->search_name(name);
if( item_data == NULL)
{ //Failed
script_pushint(st,0);
@@ -6144,18 +6117,18 @@ BUILDIN(getnameditem)
}else
nameid = script->conv_num(st,data);
- if(!itemdb_exists(nameid)/* || itemdb_isstackable(nameid)*/)
+ if(!itemdb->exists(nameid)/* || itemdb_isstackable(nameid)*/)
{ //Even though named stackable items "could" be risky, they are required for certain quests.
script_pushint(st,0);
return true;
}
data=script_getdata(st,3);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) ) //Char Name
- tsd=map_nick2sd(script->conv_str(st,data));
+ tsd=iMap->nick2sd(script->conv_str(st,data));
else //Char Id was given
- tsd=map_charid2sd(script->conv_num(st,data));
+ tsd=iMap->charid2sd(script->conv_num(st,data));
if( tsd == NULL )
{ //Failed
@@ -6170,7 +6143,7 @@ BUILDIN(getnameditem)
item_tmp.card[0]=CARD0_CREATE; //we don't use 255! because for example SIGNED WEAPON shouldn't get TOP10 BS Fame bonus [Lupus]
item_tmp.card[2]=tsd->status.char_id;
item_tmp.card[3]=tsd->status.char_id >> 16;
- if(pc_additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT)) {
+ if(pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT)) {
script_pushint(st,0);
return true; //Failed to add item, we will not drop if they don't fit
}
@@ -6183,12 +6156,30 @@ BUILDIN(getnameditem)
* gets a random item ID from an item group [Skotlex]
* groupranditem group_num
*------------------------------------------*/
-BUILDIN(grouprandomitem)
-{
- int group;
+BUILDIN(grouprandomitem) {
+ struct item_data *data;
+ int nameid;
+
+ if( script_hasdata(st, 2) )
+ nameid = script_getnum(st, 2);
+ else if ( script->current_item_id )
+ nameid = script->current_item_id;
+ else {
+ ShowWarning("buildin_grouprandomitem: no item id provided and no item attached\n");
+ script_pushint(st, 0);
+ return true;
+ }
- group = script_getnum(st,2);
- script_pushint(st,itemdb_searchrandomid(group));
+ if( !(data = itemdb->exists(nameid)) ) {
+ ShowWarning("buildin_grouprandomitem: unknown item id %d\n",nameid);
+ script_pushint(st, 0);
+ } else if ( !data->group ) {
+ ShowWarning("buildin_grouprandomitem: item '%s' (%d) isn't a group!\n",data->name,nameid);
+ script_pushint(st, 0);
+ } else {
+ script_pushint(st, itemdb->group_item(data->group));
+ }
+
return true;
}
@@ -6205,16 +6196,16 @@ BUILDIN(makeitem)
struct item_data *item_data;
data=script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) ){
const char *name=script->conv_str(st,data);
- if( (item_data = itemdb_searchname(name)) )
+ if( (item_data = itemdb->search_name(name)) )
nameid=item_data->nameid;
else
nameid=UNKNOWN_ITEM_ID;
} else {
nameid=script->conv_num(st,data);
- if( nameid <= 0 || !(item_data = itemdb_exists(nameid)) ){
+ if( nameid <= 0 || !(item_data = itemdb->exists(nameid)) ){
ShowError("makeitem: Nonexistant item %d requested.\n", nameid);
return false; //No item created.
}
@@ -6231,7 +6222,7 @@ BUILDIN(makeitem)
if (!sd) return true; //Failed...
m=sd->bl.m;
} else
- m=map_mapname2mapid(mapname);
+ m=iMap->mapname2mapid(mapname);
memset(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid=nameid;
@@ -6240,7 +6231,7 @@ BUILDIN(makeitem)
else
item_tmp.identify=itemdb_isidentified2(item_data);
- map_addflooritem(&item_tmp,amount,m,x,y,0,0,0,0);
+ iMap->addflooritem(&item_tmp,amount,m,x,y,0,0,0,0);
return true;
}
@@ -6262,7 +6253,7 @@ static void buildin_delitem_delete(struct map_session_data* sd, int idx, int* am
{// delete associated pet
intif_delete_petdata(MakeDWord(inv->card[1], inv->card[2]));
}
- pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_SCRIPT);
+ pc->delitem(sd, idx, delamount, 0, 0, LOG_TYPE_SCRIPT);
}
amount[0]-= delamount;
@@ -6401,7 +6392,7 @@ BUILDIN(delitem)
if( script_hasdata(st,4) )
{
int account_id = script_getnum(st,4);
- sd = map_id2sd(account_id); // <account id>
+ sd = iMap->id2sd(account_id); // <account id>
if( sd == NULL )
{
ShowError("script:delitem: player not found (AID=%d).\n", account_id);
@@ -6417,11 +6408,11 @@ BUILDIN(delitem)
}
data = script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) )
{
const char* item_name = script->conv_str(st,data);
- struct item_data* id = itemdb_searchname(item_name);
+ struct item_data* id = itemdb->search_name(item_name);
if( id == NULL )
{
ShowError("script:delitem: unknown item \"%s\".\n", item_name);
@@ -6433,7 +6424,7 @@ BUILDIN(delitem)
else
{
it.nameid = script->conv_num(st,data);// <item id>
- if( !itemdb_exists( it.nameid ) )
+ if( !itemdb->exists( it.nameid ) )
{
ShowError("script:delitem: unknown item \"%d\".\n", it.nameid);
st->state = END;
@@ -6470,7 +6461,7 @@ BUILDIN(delitem2)
if( script_hasdata(st,11) )
{
int account_id = script_getnum(st,11);
- sd = map_id2sd(account_id); // <account id>
+ sd = iMap->id2sd(account_id); // <account id>
if( sd == NULL )
{
ShowError("script:delitem2: player not found (AID=%d).\n", account_id);
@@ -6486,11 +6477,11 @@ BUILDIN(delitem2)
}
data = script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) )
{
const char* item_name = script->conv_str(st,data);
- struct item_data* id = itemdb_searchname(item_name);
+ struct item_data* id = itemdb->search_name(item_name);
if( id == NULL )
{
ShowError("script:delitem2: unknown item \"%s\".\n", item_name);
@@ -6502,7 +6493,7 @@ BUILDIN(delitem2)
else
{
it.nameid = script->conv_num(st,data);// <item id>
- if( !itemdb_exists( it.nameid ) )
+ if( !itemdb->exists( it.nameid ) )
{
ShowError("script:delitem: unknown item \"%d\".\n", it.nameid);
st->state = END;
@@ -6556,7 +6547,7 @@ BUILDIN(disableitemuse)
/*==========================================
* return the basic stats of sd
- * chk pc_readparam for available type
+ * chk pc->readparam for available type
*------------------------------------------*/
BUILDIN(readparam)
{
@@ -6565,7 +6556,7 @@ BUILDIN(readparam)
type=script_getnum(st,2);
if( script_hasdata(st,3) )
- sd=map_nick2sd(script_getstr(st,3));
+ sd=iMap->nick2sd(script_getstr(st,3));
else
sd=script_rid2sd(st);
@@ -6574,7 +6565,7 @@ BUILDIN(readparam)
return true;
}
- script_pushint(st,pc_readparam(sd,type));
+ script_pushint(st,pc->readparam(sd,type));
return true;
}
@@ -6595,7 +6586,7 @@ BUILDIN(getcharid)
num = script_getnum(st,2);
if( script_hasdata(st,3) )
- sd=map_nick2sd(script_getstr(st,3));
+ sd=iMap->nick2sd(script_getstr(st,3));
else
sd=script_rid2sd(st);
@@ -6660,7 +6651,7 @@ BUILDIN(getpartyname)
party_id = script_getnum(st,2);
- if( ( p = party_search(party_id) ) != NULL )
+ if( ( p = party->search(party_id) ) != NULL )
{
script_pushstrcopy(st,p->party.name);
}
@@ -6684,7 +6675,7 @@ BUILDIN(getpartymember)
struct party_data *p;
int i,j=0,type=0;
- p=party_search(script_getnum(st,2));
+ p=party->search(script_getnum(st,2));
if( script_hasdata(st,3) )
type=script_getnum(st,3);
@@ -6724,7 +6715,7 @@ BUILDIN(getpartyleader)
if( script_hasdata(st,3) )
type=script_getnum(st,3);
- p=party_search(party_id);
+ p=party->search(party_id);
if (p) //Search leader
for(i = 0; i < MAX_PARTY && !p->party.member[i].leader; i++);
@@ -6837,7 +6828,7 @@ BUILDIN(strcharinfo)
script_pushstrcopy(st,sd->status.name);
break;
case 1:
- if( ( p = party_search(sd->status.party_id) ) != NULL ) {
+ if( ( p = party->search(sd->status.party_id) ) != NULL ) {
script_pushstrcopy(st,p->party.name);
} else {
script_pushconststr(st,"");
@@ -6877,7 +6868,7 @@ BUILDIN(strnpcinfo)
int num;
char *buf,*name=NULL;
- nd = map_id2nd(st->oid);
+ nd = iMap->id2nd(st->oid);
if (!nd) {
script_pushconststr(st, "");
return true;
@@ -6941,7 +6932,7 @@ BUILDIN(getequipid)
}
// get inventory position of item
- i = pc_checkequip(sd,equip[num]);
+ i = pc->checkequip(sd,equip[num]);
if( i < 0 )
{
script_pushint(st,-1);
@@ -6979,7 +6970,7 @@ BUILDIN(getequipname)
}
// get inventory position of item
- i = pc_checkequip(sd,equip[num]);
+ i = pc->checkequip(sd,equip[num]);
if( i < 0 )
{
script_pushconststr(st,"");
@@ -7098,7 +7089,7 @@ BUILDIN(getequipisequiped)
return true;
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=pc_checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if(i >= 0)
script_pushint(st,1);
@@ -7125,7 +7116,7 @@ BUILDIN(getequipisenableref)
return true;
if( num > 0 && num <= ARRAYLENGTH(equip) )
- i = pc_checkequip(sd,equip[num-1]);
+ i = pc->checkequip(sd,equip[num-1]);
if( i >= 0 && sd->inventory_data[i] && !sd->inventory_data[i]->flag.no_refine && !sd->status.inventory[i].expire_time )
script_pushint(st,1);
else
@@ -7151,7 +7142,7 @@ BUILDIN(getequipisidentify)
return true;
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=pc_checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if(i >= 0)
script_pushint(st,sd->status.inventory[i].identify);
else
@@ -7177,7 +7168,7 @@ BUILDIN(getequiprefinerycnt)
return true;
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=pc_checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if(i >= 0)
script_pushint(st,sd->status.inventory[i].refine);
else
@@ -7204,7 +7195,7 @@ BUILDIN(getequipweaponlv)
return true;
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=pc_checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if(i >= 0 && sd->inventory_data[i])
script_pushint(st,sd->inventory_data[i]->wlv);
else
@@ -7230,7 +7221,7 @@ BUILDIN(getequippercentrefinery)
return true;
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=pc_checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if(i >= 0 && sd->status.inventory[i].nameid && sd->status.inventory[i].refine < MAX_REFINE)
script_pushint(st,status_get_refine_chance(itemdb_wlv(sd->status.inventory[i].nameid), (int)sd->status.inventory[i].refine));
else
@@ -7253,15 +7244,18 @@ BUILDIN(successrefitem)
return true;
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=pc_checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if(i >= 0) {
ep=sd->status.inventory[i].equip;
//Logs items, got from (N)PC scripts [Lupus]
logs->pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->status.inventory[i],sd->inventory_data[i]);
+ if (sd->status.inventory[i].refine >= MAX_REFINE)
+ return true;
+
sd->status.inventory[i].refine++;
- pc_unequipitem(sd,i,2); // status calc will happen in pc_equipitem() below
+ pc->unequipitem(sd,i,2); // status calc will happen in pc->equipitem() below
clif->refine(sd->fd,0,i,sd->status.inventory[i].refine);
clif->delitem(sd,i,1,3);
@@ -7270,21 +7264,21 @@ BUILDIN(successrefitem)
logs->pick_pc(sd, LOG_TYPE_SCRIPT, 1, &sd->status.inventory[i],sd->inventory_data[i]);
clif->additem(sd,i,1,0);
- pc_equipitem(sd,i,ep);
+ pc->equipitem(sd,i,ep);
clif->misceffect(&sd->bl,3);
- if(sd->status.inventory[i].refine == MAX_REFINE &&
+ if(sd->status.inventory[i].refine == 10 &&
sd->status.inventory[i].card[0] == CARD0_FORGE &&
sd->status.char_id == (int)MakeDWord(sd->status.inventory[i].card[2],sd->status.inventory[i].card[3])
){ // Fame point system [DracoRPG]
switch (sd->inventory_data[i]->wlv){
case 1:
- pc_addfame(sd,1); // Success to refine to +10 a lv1 weapon you forged = +1 fame point
+ pc->addfame(sd,1); // Success to refine to +10 a lv1 weapon you forged = +1 fame point
break;
case 2:
- pc_addfame(sd,25); // Success to refine to +10 a lv2 weapon you forged = +25 fame point
+ pc->addfame(sd,25); // Success to refine to +10 a lv2 weapon you forged = +25 fame point
break;
case 3:
- pc_addfame(sd,1000); // Success to refine to +10 a lv3 weapon you forged = +1000 fame point
+ pc->addfame(sd,1000); // Success to refine to +10 a lv3 weapon you forged = +1000 fame point
break;
}
}
@@ -7307,13 +7301,13 @@ BUILDIN(failedrefitem)
return true;
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=pc_checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if(i >= 0) {
sd->status.inventory[i].refine = 0;
- pc_unequipitem(sd,i,3); //recalculate bonus
+ pc->unequipitem(sd,i,3); //recalculate bonus
clif->refine(sd->fd,1,i,sd->status.inventory[i].refine); //notify client of failure
- pc_delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
+ pc->delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
clif->misceffect(&sd->bl,2); // display failure effect
}
@@ -7335,7 +7329,7 @@ BUILDIN(downrefitem)
return true;
if (num > 0 && num <= ARRAYLENGTH(equip))
- i = pc_checkequip(sd,equip[num-1]);
+ i = pc->checkequip(sd,equip[num-1]);
if(i >= 0) {
ep = sd->status.inventory[i].equip;
@@ -7343,7 +7337,7 @@ BUILDIN(downrefitem)
logs->pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->status.inventory[i],sd->inventory_data[i]);
sd->status.inventory[i].refine++;
- pc_unequipitem(sd,i,2); // status calc will happen in pc_equipitem() below
+ pc->unequipitem(sd,i,2); // status calc will happen in pc->equipitem() below
clif->refine(sd->fd,2,i,sd->status.inventory[i].refine = sd->status.inventory[i].refine - 2);
clif->delitem(sd,i,1,3);
@@ -7352,7 +7346,7 @@ BUILDIN(downrefitem)
logs->pick_pc(sd, LOG_TYPE_SCRIPT, 1, &sd->status.inventory[i],sd->inventory_data[i]);
clif->additem(sd,i,1,0);
- pc_equipitem(sd,i,ep);
+ pc->equipitem(sd,i,ep);
clif->misceffect(&sd->bl,2);
}
@@ -7373,10 +7367,10 @@ BUILDIN(delequip)
return true;
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=pc_checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if(i >= 0) {
- pc_unequipitem(sd,i,3); //recalculate bonus
- pc_delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
+ pc->unequipitem(sd,i,3); //recalculate bonus
+ pc->delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
}
return true;
@@ -7395,7 +7389,7 @@ BUILDIN(statusup)
if( sd == NULL )
return true;
- pc_statusup(sd,type);
+ pc->statusup(sd,type);
return true;
}
@@ -7413,7 +7407,7 @@ BUILDIN(statusup2)
if( sd == NULL )
return true;
- pc_statusup2(sd,type,val);
+ pc->statusup2(sd,type,val);
return true;
}
@@ -7467,16 +7461,16 @@ BUILDIN(bonus)
switch( script_lastdata(st)-2 ) {
case 1:
- pc_bonus(sd, type, val1);
+ pc->bonus(sd, type, val1);
break;
case 2:
val2 = script_getnum(st,4);
- pc_bonus2(sd, type, val1, val2);
+ pc->bonus2(sd, type, val1, val2);
break;
case 3:
val2 = script_getnum(st,4);
val3 = script_getnum(st,5);
- pc_bonus3(sd, type, val1, val2, val3);
+ pc->bonus3(sd, type, val1, val2, val3);
break;
case 4:
if( type == SP_AUTOSPELL_ONSKILL && script_isstring(st,4) )
@@ -7486,7 +7480,7 @@ BUILDIN(bonus)
val3 = script_getnum(st,5);
val4 = script_getnum(st,6);
- pc_bonus4(sd, type, val1, val2, val3, val4);
+ pc->bonus4(sd, type, val1, val2, val3, val4);
break;
case 5:
if( type == SP_AUTOSPELL_ONSKILL && script_isstring(st,4) )
@@ -7497,7 +7491,7 @@ BUILDIN(bonus)
val3 = script_getnum(st,5);
val4 = script_getnum(st,6);
val5 = script_getnum(st,7);
- pc_bonus5(sd, type, val1, val2, val3, val4, val5);
+ pc->bonus5(sd, type, val1, val2, val3, val4, val5);
break;
default:
ShowDebug("buildin_bonus: unexpected number of arguments (%d)\n", (script_lastdata(st) - 1));
@@ -7533,7 +7527,7 @@ BUILDIN(autobonus)
if( script_hasdata(st,6) )
other_script = script_getstr(st,6);
- if( pc_addautobonus(sd->autobonus,ARRAYLENGTH(sd->autobonus),
+ if( pc->addautobonus(sd->autobonus,ARRAYLENGTH(sd->autobonus),
bonus_script,rate,dur,atk_type,other_script,sd->status.inventory[current_equip_item_index].equip,false) )
{
script_add_autobonus(bonus_script);
@@ -7570,7 +7564,7 @@ BUILDIN(autobonus2)
if( script_hasdata(st,6) )
other_script = script_getstr(st,6);
- if( pc_addautobonus(sd->autobonus2,ARRAYLENGTH(sd->autobonus2),
+ if( pc->addautobonus(sd->autobonus2,ARRAYLENGTH(sd->autobonus2),
bonus_script,rate,dur,atk_type,other_script,sd->status.inventory[current_equip_item_index].equip,false) )
{
script_add_autobonus(bonus_script);
@@ -7605,7 +7599,7 @@ BUILDIN(autobonus3)
if( script_hasdata(st,6) )
other_script = script_getstr(st,6);
- if( pc_addautobonus(sd->autobonus3,ARRAYLENGTH(sd->autobonus3),
+ if( pc->addautobonus(sd->autobonus3,ARRAYLENGTH(sd->autobonus3),
bonus_script,rate,dur,atk_type,other_script,sd->status.inventory[current_equip_item_index].equip,true) )
{
script_add_autobonus(bonus_script);
@@ -7641,7 +7635,7 @@ BUILDIN(skill)
level = script_getnum(st,3);
if( script_hasdata(st,4) )
flag = script_getnum(st,4);
- pc_skill(sd, id, level, flag);
+ pc->skill(sd, id, level, flag);
return true;
}
@@ -7670,7 +7664,7 @@ BUILDIN(addtoskill)
level = script_getnum(st,3);
if( script_hasdata(st,4) )
flag = script_getnum(st,4);
- pc_skill(sd, id, level, flag);
+ pc->skill(sd, id, level, flag);
return true;
}
@@ -7712,7 +7706,7 @@ BUILDIN(getskilllv)
return true;// no player attached, report source
id = ( script_isstring(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) );
- script_pushint(st, pc_checkskill(sd,id));
+ script_pushint(st, pc->checkskill(sd,id));
return true;
}
@@ -7760,7 +7754,7 @@ BUILDIN(getgmlevel)
if( sd == NULL )
return true;// no player attached, report source
- script_pushint(st, pc_get_group_level(sd));
+ script_pushint(st, pc->get_group_level(sd));
return true;
}
@@ -7783,8 +7777,7 @@ BUILDIN(getgroupid)
/// Terminates the execution of this script instance.
///
/// end
-BUILDIN(end)
-{
+BUILDIN(end) {
st->state = END;
return true;
}
@@ -7882,9 +7875,9 @@ BUILDIN(setoption)
if( flag ){// Add option
if( option&OPTION_WEDDING && !battle_config.wedding_modifydisplay )
option &= ~OPTION_WEDDING;// Do not show the wedding sprites
- pc_setoption(sd, sd->sc.option|option);
+ pc->setoption(sd, sd->sc.option|option);
} else// Remove option
- pc_setoption(sd, sd->sc.option&~option);
+ pc->setoption(sd, sd->sc.option&~option);
return true;
}
@@ -7932,7 +7925,7 @@ BUILDIN(setcart)
if( script_hasdata(st,2) )
type = script_getnum(st,2);
- pc_setcart(sd, type);
+ pc->setcart(sd, type);
return true;
}
@@ -7975,7 +7968,7 @@ BUILDIN(setfalcon)
if( script_hasdata(st,2) )
flag = script_getnum(st,2);
- pc_setfalcon(sd, flag);
+ pc->setfalcon(sd, flag);
return true;
}
@@ -8017,7 +8010,7 @@ BUILDIN(setriding)
if( script_hasdata(st,2) )
flag = script_getnum(st,2);
- pc_setriding(sd, flag);
+ pc->setriding(sd, flag);
return true;
}
@@ -8078,7 +8071,7 @@ BUILDIN(setmadogear)
if( script_hasdata(st,2) )
flag = script_getnum(st,2);
- pc_setmadogear(sd, flag);
+ pc->setmadogear(sd, flag);
return true;
}
@@ -8104,7 +8097,7 @@ BUILDIN(savepoint)
y = script_getnum(st,4);
map = mapindex_name2id(str);
if( map )
- pc_setsavepoint(sd, map, x, y);
+ pc->setsavepoint(sd, map, x, y);
return true;
}
@@ -8135,7 +8128,7 @@ BUILDIN(gettimetick) /* Asgard Version */
case 0:
default:
//type 0:(System Ticks)
- script_pushint(st,gettick());
+ script_pushint(st,iTimer->gettick());
break;
}
return true;
@@ -8214,20 +8207,18 @@ BUILDIN(gettimestr)
/*==========================================
* Open player storage
*------------------------------------------*/
-BUILDIN(openstorage)
-{
+BUILDIN(openstorage) {
TBL_PC* sd;
sd = script_rid2sd(st);
if( sd == NULL )
return true;
- storage_storageopen(sd);
+ storage->open(sd);
return true;
}
-BUILDIN(guildopenstorage)
-{
+BUILDIN(guildopenstorage) {
TBL_PC* sd;
int ret;
@@ -8235,7 +8226,7 @@ BUILDIN(guildopenstorage)
if( sd == NULL )
return true;
- ret = storage_guild_storageopen(sd);
+ ret = gstorage->open(sd);
script_pushint(st,ret);
return true;
}
@@ -8351,7 +8342,7 @@ BUILDIN(getexp)
base = (int) cap_value(base * bonus, 0, INT_MAX);
job = (int) cap_value(job * bonus, 0, INT_MAX);
- pc_gainexp(sd, NULL, base, job, true);
+ pc->gainexp(sd, NULL, base, job, true);
return true;
}
@@ -8388,7 +8379,7 @@ BUILDIN(guildchangegm)
guild_id = script_getnum(st,2);
name = script_getstr(st,3);
- sd=map_nick2sd(name);
+ sd=iMap->nick2sd(name);
if (!sd)
script_pushint(st,0);
@@ -8417,6 +8408,7 @@ BUILDIN(monster)
const char* event = "";
unsigned int size = SZ_SMALL;
unsigned int ai = AI_NONE;
+ int mob_id;
struct map_session_data* sd;
int16 m;
@@ -8453,24 +8445,27 @@ BUILDIN(monster)
return false;
}
- sd = map_id2sd(st->rid);
+ sd = iMap->id2sd(st->rid);
if (sd && strcmp(mapn, "this") == 0)
m = sd->bl.m;
- else
- {
- m = map_mapname2mapid(mapn);
- if (map[m].flag.src4instance && st->instance_id)
- { // Try to redirect to the instance map, not the src map
- if ((m = instance_mapid2imapid(m, st->instance_id)) < 0)
- {
+ else {
+
+ if ( ( m = iMap->mapname2mapid(mapn) ) == -1 ) {
+ ShowWarning("buildin_monster: Attempted to spawn monster class %d on non-existing map '%s'\n",class_, mapn);
+ return false;
+ }
+
+ if (map[m].flag.src4instance && st->instance_id >= 0) { // Try to redirect to the instance map, not the src map
+ if ((m = instance->mapid2imapid(m, st->instance_id)) < 0) {
ShowError("buildin_monster: Trying to spawn monster (%d) on instance map (%s) without instance attached.\n", class_, mapn);
return false;
}
}
}
- mob_once_spawn(sd, m, x, y, str, class_, amount, event, size, ai);
+ mob_id = mob_once_spawn(sd, m, x, y, str, class_, amount, event, size, ai);
+ script_pushint(st, mob_id);
return true;
}
/*==========================================
@@ -8494,7 +8489,7 @@ BUILDIN(getmobdrops)
{
if( mob->dropitem[i].nameid < 1 )
continue;
- if( itemdb_exists(mob->dropitem[i].nameid) == NULL )
+ if( itemdb->exists(mob->dropitem[i].nameid) == NULL )
continue;
mapreg_setreg(reference_uid(add_str("$@MobDrop_item"), j), mob->dropitem[i].nameid);
@@ -8524,54 +8519,49 @@ BUILDIN(areamonster)
const char* event = "";
unsigned int size = SZ_SMALL;
unsigned int ai = AI_NONE;
+ int mob_id;
struct map_session_data* sd;
int16 m;
- if (script_hasdata(st,10))
- {
+ if (script_hasdata(st,10)) {
event = script_getstr(st, 10);
check_event(st, event);
}
- if (script_hasdata(st, 11))
- {
+ if (script_hasdata(st, 11)) {
size = script_getnum(st, 11);
- if (size > 3)
- {
+ if (size > 3) {
ShowWarning("buildin_monster: Attempted to spawn non-existing size %d for monster class %d\n", size, class_);
return false;
}
}
- if (script_hasdata(st, 12))
- {
+ if (script_hasdata(st, 12)) {
ai = script_getnum(st, 12);
- if (ai > 4)
- {
+ if (ai > 4) {
ShowWarning("buildin_monster: Attempted to spawn non-existing ai %d for monster class %d\n", ai, class_);
return false;
}
}
- sd = map_id2sd(st->rid);
+ sd = iMap->id2sd(st->rid);
if (sd && strcmp(mapn, "this") == 0)
m = sd->bl.m;
- else
- {
- m = map_mapname2mapid(mapn);
- if (map[m].flag.src4instance && st->instance_id)
- { // Try to redirect to the instance map, not the src map
- if ((m = instance_mapid2imapid(m, st->instance_id)) < 0)
- {
+ else {
+ m = iMap->mapname2mapid(mapn);
+ if (map[m].flag.src4instance && st->instance_id >= 0) { // Try to redirect to the instance map, not the src map
+ if ((m = instance->mapid2imapid(m, st->instance_id)) < 0) {
ShowError("buildin_areamonster: Trying to spawn monster (%d) on instance map (%s) without instance attached.\n", class_, mapn);
return false;
}
}
}
- mob_once_spawn_area(sd, m, x0, y0, x1, y1, str, class_, amount, event, size, ai);
+ mob_id = mob_once_spawn_area(sd, m, x0, y0, x1, y1, str, class_, amount, event, size, ai);
+ script_pushint(st, mob_id);
+
return true;
}
/*==========================================
@@ -8621,22 +8611,22 @@ BUILDIN(killmonster)
else
check_event(st, event);
- if( (m=map_mapname2mapid(mapname))<0 )
+ if( (m=iMap->mapname2mapid(mapname))<0 )
return true;
- if( map[m].flag.src4instance && st->instance_id && (m = instance_mapid2imapid(m, st->instance_id)) < 0 )
+ if( map[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 )
return true;
if( script_hasdata(st,4) ) {
if ( script_getnum(st,4) == 1 ) {
- map_foreachinmap(buildin_killmonster_sub, m, BL_MOB, event ,allflag);
+ iMap->foreachinmap(buildin_killmonster_sub, m, BL_MOB, event ,allflag);
return true;
}
}
- map_freeblock_lock();
- map_foreachinmap(buildin_killmonster_sub_strip, m, BL_MOB, event ,allflag);
- map_freeblock_unlock();
+ iMap->freeblock_lock();
+ iMap->foreachinmap(buildin_killmonster_sub_strip, m, BL_MOB, event ,allflag);
+ iMap->freeblock_unlock();
return true;
}
@@ -8662,20 +8652,20 @@ BUILDIN(killmonsterall)
int16 m;
mapname=script_getstr(st,2);
- if( (m = map_mapname2mapid(mapname))<0 )
+ if( (m = iMap->mapname2mapid(mapname))<0 )
return true;
- if( map[m].flag.src4instance && st->instance_id && (m = instance_mapid2imapid(m, st->instance_id)) < 0 )
+ if( map[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 )
return true;
if( script_hasdata(st,3) ) {
if ( script_getnum(st,3) == 1 ) {
- map_foreachinmap(buildin_killmonsterall_sub,m,BL_MOB);
+ iMap->foreachinmap(buildin_killmonsterall_sub,m,BL_MOB);
return true;
}
}
- map_foreachinmap(buildin_killmonsterall_sub_strip,m,BL_MOB);
+ iMap->foreachinmap(buildin_killmonsterall_sub_strip,m,BL_MOB);
return true;
}
@@ -8710,13 +8700,13 @@ BUILDIN(clone)
check_event(st, event);
- m = map_mapname2mapid(map);
+ m = iMap->mapname2mapid(map);
if (m < 0) return true;
- sd = map_charid2sd(char_id);
+ sd = iMap->charid2sd(char_id);
if (master_id) {
- msd = map_charid2sd(master_id);
+ msd = iMap->charid2sd(master_id);
if (msd)
master_id = msd->bl.id;
else
@@ -8752,7 +8742,7 @@ BUILDIN(donpcevent)
const char* event = script_getstr(st,2);
check_event(st, event);
if( !npc_event_do(event) ) {
- struct npc_data * nd = map_id2nd(st->oid);
+ struct npc_data * nd = iMap->id2nd(st->oid);
ShowDebug("NPCEvent '%s' not found! (source: %s)\n",event,nd?nd->name:"Unknown");
script_pushint(st, 0);
} else
@@ -8786,7 +8776,7 @@ BUILDIN(addtimer)
if( sd == NULL )
return true;
- pc_addeventtimer(sd,tick,event);
+ pc->addeventtimer(sd,tick,event);
return true;
}
/*==========================================
@@ -8802,7 +8792,7 @@ BUILDIN(deltimer)
return true;
check_event(st, event);
- pc_deleventtimer(sd,event);
+ pc->deleventtimer(sd,event);
return true;
}
/*==========================================
@@ -8820,7 +8810,7 @@ BUILDIN(addtimercount)
return true;
check_event(st, event);
- pc_addeventtimercount(sd,event,tick);
+ pc->addeventtimercount(sd,event,tick);
return true;
}
@@ -8840,12 +8830,12 @@ BUILDIN(initnpctimer)
{ //Check if argument is numeric (flag) or string (npc name)
struct script_data *data;
data = script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) ) //NPC name
nd = npc_name2id(script->conv_str(st, data));
else if( data_isint(data) ) //Flag
{
- nd = (struct npc_data *)map_id2bl(st->oid);
+ nd = (struct npc_data *)iMap->id2bl(st->oid);
flag = script->conv_num(st,data);
}
else
@@ -8855,7 +8845,7 @@ BUILDIN(initnpctimer)
}
}
else
- nd = (struct npc_data *)map_id2bl(st->oid);
+ nd = (struct npc_data *)iMap->id2bl(st->oid);
if( !nd )
return true;
@@ -8888,12 +8878,12 @@ BUILDIN(startnpctimer)
{ //Check if argument is numeric (flag) or string (npc name)
struct script_data *data;
data = script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) ) //NPC name
nd = npc_name2id(script->conv_str(st, data));
else if( data_isint(data) ) //Flag
{
- nd = (struct npc_data *)map_id2bl(st->oid);
+ nd = (struct npc_data *)iMap->id2bl(st->oid);
flag = script->conv_num(st,data);
}
else
@@ -8903,7 +8893,7 @@ BUILDIN(startnpctimer)
}
}
else
- nd=(struct npc_data *)map_id2bl(st->oid);
+ nd=(struct npc_data *)iMap->id2bl(st->oid);
if( !nd )
return true;
@@ -8934,12 +8924,12 @@ BUILDIN(stopnpctimer)
{ //Check if argument is numeric (flag) or string (npc name)
struct script_data *data;
data = script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) ) //NPC name
nd = npc_name2id(script->conv_str(st, data));
else if( data_isint(data) ) //Flag
{
- nd = (struct npc_data *)map_id2bl(st->oid);
+ nd = (struct npc_data *)iMap->id2bl(st->oid);
flag = script->conv_num(st,data);
}
else
@@ -8949,7 +8939,7 @@ BUILDIN(stopnpctimer)
}
}
else
- nd=(struct npc_data *)map_id2bl(st->oid);
+ nd=(struct npc_data *)iMap->id2bl(st->oid);
if( !nd )
return true;
@@ -8971,7 +8961,7 @@ BUILDIN(getnpctimer)
if( script_hasdata(st,3) )
nd = npc_name2id(script_getstr(st,3));
else
- nd = (struct npc_data *)map_id2bl(st->oid);
+ nd = (struct npc_data *)iMap->id2bl(st->oid);
if( !nd || nd->bl.type != BL_NPC )
{
@@ -8986,7 +8976,7 @@ BUILDIN(getnpctimer)
case 1:
if( nd->u.scr.rid )
{
- sd = map_id2sd(nd->u.scr.rid);
+ sd = iMap->id2sd(nd->u.scr.rid);
if( !sd )
{
ShowError("buildin_getnpctimer: Attached player not found!\n");
@@ -9014,7 +9004,7 @@ BUILDIN(setnpctimer)
if( script_hasdata(st,3) )
nd = npc_name2id(script_getstr(st,3));
else
- nd = (struct npc_data *)map_id2bl(st->oid);
+ nd = (struct npc_data *)iMap->id2bl(st->oid);
if( !nd || nd->bl.type != BL_NPC )
{
@@ -9034,7 +9024,7 @@ BUILDIN(setnpctimer)
BUILDIN(attachnpctimer)
{
TBL_PC *sd;
- struct npc_data *nd = (struct npc_data *)map_id2bl(st->oid);
+ struct npc_data *nd = (struct npc_data *)iMap->id2bl(st->oid);
if( !nd || nd->bl.type != BL_NPC )
{
@@ -9044,7 +9034,7 @@ BUILDIN(attachnpctimer)
}
if( script_hasdata(st,2) )
- sd = map_nick2sd(script_getstr(st,2));
+ sd = iMap->nick2sd(script_getstr(st,2));
else
sd = script_rid2sd(st);
@@ -9070,7 +9060,7 @@ BUILDIN(detachnpctimer)
if( script_hasdata(st,2) )
nd = npc_name2id(script_getstr(st,2));
else
- nd = (struct npc_data *)map_id2bl(st->oid);
+ nd = (struct npc_data *)iMap->id2bl(st->oid);
if( !nd || nd->bl.type != BL_NPC )
{
@@ -9091,7 +9081,7 @@ BUILDIN(detachnpctimer)
*------------------------------------------*/
BUILDIN(playerattached)
{
- if(st->rid == 0 || map_id2sd(st->rid) == NULL)
+ if(st->rid == 0 || iMap->id2sd(st->rid) == NULL)
script_pushint(st,0);
else
script_pushint(st,st->rid);
@@ -9113,7 +9103,7 @@ BUILDIN(announce)
if (flag&0x0f) // Broadcast source or broadcast region defined
{
send_target target;
- struct block_list *bl = (flag&0x08) ? map_id2bl(st->oid) : (struct block_list *)script_rid2sd(st); // If bc_npc flag is set, use NPC as broadcast source
+ struct block_list *bl = (flag&0x08) ? iMap->id2bl(st->oid) : (struct block_list *)script_rid2sd(st); // If bc_npc flag is set, use NPC as broadcast source
if (bl == NULL)
return true;
@@ -9164,22 +9154,22 @@ BUILDIN(itemeffect) {
struct item_data *item_data;
nullpo_retr( 1, ( sd = script_rid2sd( st ) ) );
- nullpo_retr( 1, ( nd = (TBL_NPC *)map_id2bl( sd->npc_id ) ) );
+ nullpo_retr( 1, ( nd = (TBL_NPC *)iMap->id2bl( sd->npc_id ) ) );
data = script_getdata( st, 2 );
- get_val( st, data );
+ script->get_val( st, data );
if( data_isstring( data ) ){
const char *name = script->conv_str( st, data );
- if( ( item_data = itemdb_searchname( name ) ) == NULL ){
+ if( ( item_data = itemdb->search_name( name ) ) == NULL ){
ShowError( "buildin_itemeffect: Nonexistant item %s requested.\n", name );
return false;
}
} else if( data_isint( data ) ){
int nameid = script->conv_num( st, data );
- if( ( item_data = itemdb_exists( nameid ) ) == NULL ){
+ if( ( item_data = itemdb->exists( nameid ) ) == NULL ){
ShowError("buildin_itemeffect: Nonexistant item %d requested.\n", nameid );
return false;
}
@@ -9205,10 +9195,10 @@ BUILDIN(mapannounce)
int fontY = script_hasdata(st,9) ? script_getnum(st,9) : 0; // default fontY
int16 m;
- if ((m = map_mapname2mapid(mapname)) < 0)
+ if ((m = iMap->mapname2mapid(mapname)) < 0)
return true;
- map_foreachinmap(buildin_announce_sub, m, BL_PC,
+ iMap->foreachinmap(buildin_announce_sub, m, BL_PC,
mes, strlen(mes)+1, flag&0xf0, fontColor, fontType, fontSize, fontAlign, fontY);
return true;
}
@@ -9230,10 +9220,10 @@ BUILDIN(areaannounce)
int fontY = script_hasdata(st,13) ? script_getnum(st,13) : 0; // default fontY
int16 m;
- if ((m = map_mapname2mapid(mapname)) < 0)
+ if ((m = iMap->mapname2mapid(mapname)) < 0)
return true;
- map_foreachinarea(buildin_announce_sub, m, x0, y0, x1, y1, BL_PC,
+ iMap->foreachinarea(buildin_announce_sub, m, x0, y0, x1, y1, BL_PC,
mes, strlen(mes)+1, flag&0xf0, fontColor, fontType, fontSize, fontAlign, fontY);
return true;
}
@@ -9253,7 +9243,7 @@ BUILDIN(getusers)
case 0:
if(flag&0x8)
{// npc
- bl = map_id2bl(st->oid);
+ bl = iMap->id2bl(st->oid);
}
else if((sd = script_rid2sd(st))!=NULL)
{// pc
@@ -9266,7 +9256,7 @@ BUILDIN(getusers)
}
break;
case 1:
- val = map_getusers();
+ val = iMap->getusers();
break;
default:
ShowWarning("buildin_getusers: Unknown type %d.\n", flag);
@@ -9289,11 +9279,11 @@ BUILDIN(getusersname)
sd = script_rid2sd(st);
if (!sd) return true;
- group_level = pc_get_group_level(sd);
+ group_level = pc->get_group_level(sd);
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
{
- if (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc_get_group_level(pl_sd) > group_level)
+ if (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc->get_group_level(pl_sd) > group_level)
continue; // skip hidden sessions
/* Temporary fix for bugreport:1023.
@@ -9318,7 +9308,7 @@ BUILDIN(getmapguildusers)
struct guild *g = NULL;
str=script_getstr(st,2);
gid=script_getnum(st,3);
- if ((m = map_mapname2mapid(str)) < 0) { // map id on this server (m == -1 if not in actual map-server)
+ if ((m = iMap->mapname2mapid(str)) < 0) { // map id on this server (m == -1 if not in actual map-server)
script_pushint(st,-1);
return true;
}
@@ -9342,7 +9332,7 @@ BUILDIN(getmapusers)
const char *str;
int16 m;
str=script_getstr(st,2);
- if( (m=map_mapname2mapid(str))< 0){
+ if( (m=iMap->mapname2mapid(str))< 0){
script_pushint(st,-1);
return true;
}
@@ -9366,11 +9356,11 @@ BUILDIN(getareausers)
y0=script_getnum(st,4);
x1=script_getnum(st,5);
y1=script_getnum(st,6);
- if( (m=map_mapname2mapid(str))< 0){
+ if( (m=iMap->mapname2mapid(str))< 0){
script_pushint(st,-1);
return true;
}
- map_foreachinarea(buildin_getareausers_sub,
+ iMap->foreachinarea(buildin_getareausers_sub,
m,x0,y0,x1,y1,BL_PC,&users);
script_pushint(st,users);
return true;
@@ -9403,21 +9393,21 @@ BUILDIN(getareadropitem)
y1=script_getnum(st,6);
data=script_getdata(st,7);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) ){
const char *name=script->conv_str(st,data);
- struct item_data *item_data = itemdb_searchname(name);
+ struct item_data *item_data = itemdb->search_name(name);
item=UNKNOWN_ITEM_ID;
if( item_data )
item=item_data->nameid;
}else
item=script->conv_num(st,data);
- if( (m=map_mapname2mapid(str))< 0){
+ if( (m=iMap->mapname2mapid(str))< 0){
script_pushint(st,-1);
return true;
}
- map_foreachinarea(buildin_getareadropitem_sub,
+ iMap->foreachinarea(buildin_getareadropitem_sub,
m,x0,y0,x1,y1,BL_ITEM,item,&amount);
script_pushint(st,amount);
return true;
@@ -9475,9 +9465,9 @@ BUILDIN(sc_start)
tick = script_getnum(st,3);
val1 = script_getnum(st,4);
if( script_hasdata(st,5) )
- bl = map_id2bl(script_getnum(st,5));
+ bl = iMap->id2bl(script_getnum(st,5));
else
- bl = map_id2bl(st->rid);
+ bl = iMap->id2bl(st->rid);
if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status_sc2skill(type) != 0 )
{// When there isn't a duration specified, try to get it from the skill_db
@@ -9486,7 +9476,7 @@ BUILDIN(sc_start)
if( potion_flag == 1 && potion_target )
{ //skill.c set the flags before running the script, this must be a potion-pitched effect.
- bl = map_id2bl(potion_target);
+ bl = iMap->id2bl(potion_target);
tick /= 2;// Thrown potions only last half.
val4 = 1;// Mark that this was a thrown sc_effect
}
@@ -9514,9 +9504,9 @@ BUILDIN(sc_start2)
val1 = script_getnum(st,4);
rate = script_getnum(st,5);
if( script_hasdata(st,6) )
- bl = map_id2bl(script_getnum(st,6));
+ bl = iMap->id2bl(script_getnum(st,6));
else
- bl = map_id2bl(st->rid);
+ bl = iMap->id2bl(st->rid);
if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status_sc2skill(type) != 0 )
{// When there isn't a duration specified, try to get it from the skill_db
@@ -9525,7 +9515,7 @@ BUILDIN(sc_start2)
if( potion_flag == 1 && potion_target )
{ //skill.c set the flags before running the script, this must be a potion-pitched effect.
- bl = map_id2bl(potion_target);
+ bl = iMap->id2bl(potion_target);
tick /= 2;// Thrown potions only last half.
val4 = 1;// Mark that this was a thrown sc_effect
}
@@ -9556,9 +9546,9 @@ BUILDIN(sc_start4)
val3 = script_getnum(st,6);
val4 = script_getnum(st,7);
if( script_hasdata(st,8) )
- bl = map_id2bl(script_getnum(st,8));
+ bl = iMap->id2bl(script_getnum(st,8));
else
- bl = map_id2bl(st->rid);
+ bl = iMap->id2bl(st->rid);
if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status_sc2skill(type) != 0 )
{// When there isn't a duration specified, try to get it from the skill_db
@@ -9567,7 +9557,7 @@ BUILDIN(sc_start4)
if( potion_flag == 1 && potion_target )
{ //skill.c set the flags before running the script, this must be a potion-pitched effect.
- bl = map_id2bl(potion_target);
+ bl = iMap->id2bl(potion_target);
tick /= 2;// Thrown potions only last half.
}
@@ -9587,12 +9577,12 @@ BUILDIN(sc_end)
type = script_getnum(st, 2);
if (script_hasdata(st, 3))
- bl = map_id2bl(script_getnum(st, 3));
+ bl = iMap->id2bl(script_getnum(st, 3));
else
- bl = map_id2bl(st->rid);
+ bl = iMap->id2bl(st->rid);
if (potion_flag == 1 && potion_target) //##TODO how does this work [FlavioJS]
- bl = map_id2bl(potion_target);
+ bl = iMap->id2bl(potion_target);
if (!bl)
return true;
@@ -9608,8 +9598,8 @@ BUILDIN(sc_end)
switch (type)
{
- case SC_WEIGHT50:
- case SC_WEIGHT90:
+ case SC_WEIGHTOVER50:
+ case SC_WEIGHTOVER90:
case SC_NOCHAT:
case SC_PUSH_CART:
return true;
@@ -9639,9 +9629,9 @@ BUILDIN(getscrate)
type=script_getnum(st,2);
rate=script_getnum(st,3);
if( script_hasdata(st,4) ) //get for the bl assigned
- bl = map_id2bl(script_getnum(st,4));
+ bl = iMap->id2bl(script_getnum(st,4));
else
- bl = map_id2bl(st->rid);
+ bl = iMap->id2bl(st->rid);
if (bl)
rate = status_get_sc_def(bl, (sc_type)type, 10000, 10000, 0);
@@ -9686,11 +9676,11 @@ BUILDIN(getstatus)
case 4: script_pushint(st, sd->sc.data[id]->val4); break;
case 5:
{
- struct TimerData* timer = (struct TimerData*)get_timer(sd->sc.data[id]->timer);
+ struct TimerData* timer = (struct TimerData*)iTimer->get_timer(sd->sc.data[id]->timer);
if( timer )
{// return the amount of time remaining
- script_pushint(st, timer->tick - gettick());
+ script_pushint(st, timer->tick - iTimer->gettick());
}
}
break;
@@ -9790,6 +9780,31 @@ BUILDIN(homunculus_shuffle) {
return true;
}
+/*==========================================
+ * Check for homunculus state.
+ * Return: -1 = No homunculus
+ * 0 = Homunculus is active
+ * 1 = Homunculus is vaporized (rest)
+ * 2 = Homunculus is in morph state
+ *------------------------------------------*/
+BUILDIN(checkhomcall)
+{
+ TBL_PC *sd = script_rid2sd(st);
+ TBL_HOM *hd;
+
+ if( sd == NULL )
+ return false;
+
+ hd = sd->hd;
+
+ if( !hd )
+ script_pushint(st, -1);
+ else
+ script_pushint(st, hd->homunculus.vaporize);
+
+ return true;
+}
+
//These two functions bring the eA MAPID_* class functionality to scripts.
BUILDIN(eaclass)
{
@@ -9805,7 +9820,7 @@ BUILDIN(eaclass)
}
class_ = sd->status.class_;
}
- script_pushint(st,pc_jobid2mapid(class_));
+ script_pushint(st,pc->jobid2mapid(class_));
return true;
}
@@ -9822,7 +9837,7 @@ BUILDIN(roclass)
else
sex = 1; //Just use male when not found.
}
- script_pushint(st,pc_mapid2jobid(class_, sex));
+ script_pushint(st,pc->mapid2jobid(class_, sex));
return true;
}
@@ -9863,7 +9878,7 @@ BUILDIN(resetlvl)
if( sd == NULL )
return true;
- pc_resetlvl(sd,type);
+ pc->resetlvl(sd,type);
return true;
}
/*==========================================
@@ -9873,7 +9888,7 @@ BUILDIN(resetstatus)
{
TBL_PC *sd;
sd=script_rid2sd(st);
- pc_resetstate(sd);
+ pc->resetstate(sd);
return true;
}
@@ -9884,7 +9899,7 @@ BUILDIN(resetskill)
{
TBL_PC *sd;
sd=script_rid2sd(st);
- pc_resetskill(sd,1);
+ pc->resetskill(sd,1);
return true;
}
@@ -9895,7 +9910,7 @@ BUILDIN(skillpointcount)
{
TBL_PC *sd;
sd=script_rid2sd(st);
- script_pushint(st,sd->status.skill_point + pc_resetskill(sd,2));
+ script_pushint(st,sd->status.skill_point + pc->resetskill(sd,2));
return true;
}
@@ -9908,7 +9923,7 @@ BUILDIN(changebase)
int vclass;
if( script_hasdata(st,3) )
- sd=map_id2sd(script_getnum(st,3));
+ sd=iMap->id2sd(script_getnum(st,3));
else
sd=script_rid2sd(st);
@@ -9946,10 +9961,10 @@ BUILDIN(changesex)
TBL_PC *sd = NULL;
sd = script_rid2sd(st);
- pc_resetskill(sd,4);
+ pc->resetskill(sd,4);
// to avoid any problem with equipment and invalid sex, equipment is unequiped.
for( i=0; i<EQI_MAX; i++ )
- if( sd->equip_index[i] >= 0 ) pc_unequipitem(sd, sd->equip_index[i], 3);
+ if( sd->equip_index[i] >= 0 ) pc->unequipitem(sd, sd->equip_index[i], 3);
chrif_changesex(sd);
return true;
}
@@ -9959,7 +9974,7 @@ BUILDIN(changesex)
*------------------------------------------*/
BUILDIN(globalmes)
{
- struct block_list *bl = map_id2bl(st->oid);
+ struct block_list *bl = iMap->id2bl(st->oid);
struct npc_data *nd = (struct npc_data *)bl;
const char *name=NULL,*mes;
@@ -9996,7 +10011,7 @@ BUILDIN(waitingroom)
int minLvl = script_hasdata(st,7) ? script_getnum(st,7) : 1;
int maxLvl = script_hasdata(st,8) ? script_getnum(st,8) : MAX_LEVEL;
- nd = (struct npc_data *)map_id2bl(st->oid);
+ nd = (struct npc_data *)iMap->id2bl(st->oid);
if( nd != NULL )
chat_createnpcchat(nd, title, limit, pub, trigger, ev, zeny, minLvl, maxLvl);
@@ -10013,7 +10028,7 @@ BUILDIN(delwaitingroom)
if( script_hasdata(st,2) )
nd = npc_name2id(script_getstr(st, 2));
else
- nd = (struct npc_data *)map_id2bl(st->oid);
+ nd = (struct npc_data *)iMap->id2bl(st->oid);
if( nd != NULL )
chat_deletenpcchat(nd);
return true;
@@ -10031,9 +10046,9 @@ BUILDIN(waitingroomkickall)
if( script_hasdata(st,2) )
nd = npc_name2id(script_getstr(st,2));
else
- nd = (struct npc_data *)map_id2bl(st->oid);
+ nd = (struct npc_data *)iMap->id2bl(st->oid);
- if( nd != NULL && (cd=(struct chat_data *)map_id2bl(nd->chat_id)) != NULL )
+ if( nd != NULL && (cd=(struct chat_data *)iMap->id2bl(nd->chat_id)) != NULL )
chat_npckickall(cd);
return true;
}
@@ -10050,9 +10065,9 @@ BUILDIN(enablewaitingroomevent)
if( script_hasdata(st,2) )
nd = npc_name2id(script_getstr(st, 2));
else
- nd = (struct npc_data *)map_id2bl(st->oid);
+ nd = (struct npc_data *)iMap->id2bl(st->oid);
- if( nd != NULL && (cd=(struct chat_data *)map_id2bl(nd->chat_id)) != NULL )
+ if( nd != NULL && (cd=(struct chat_data *)iMap->id2bl(nd->chat_id)) != NULL )
chat_enableevent(cd);
return true;
}
@@ -10069,9 +10084,9 @@ BUILDIN(disablewaitingroomevent)
if( script_hasdata(st,2) )
nd = npc_name2id(script_getstr(st, 2));
else
- nd = (struct npc_data *)map_id2bl(st->oid);
+ nd = (struct npc_data *)iMap->id2bl(st->oid);
- if( nd != NULL && (cd=(struct chat_data *)map_id2bl(nd->chat_id)) != NULL )
+ if( nd != NULL && (cd=(struct chat_data *)iMap->id2bl(nd->chat_id)) != NULL )
chat_disableevent(cd);
return true;
}
@@ -10100,9 +10115,9 @@ BUILDIN(getwaitingroomstate)
if( script_hasdata(st,3) )
nd = npc_name2id(script_getstr(st, 3));
else
- nd = (struct npc_data *)map_id2bl(st->oid);
+ nd = (struct npc_data *)iMap->id2bl(st->oid);
- if( nd == NULL || (cd=(struct chat_data *)map_id2bl(nd->chat_id)) == NULL )
+ if( nd == NULL || (cd=(struct chat_data *)iMap->id2bl(nd->chat_id)) == NULL )
{
script_pushint(st, -1);
return true;
@@ -10147,8 +10162,8 @@ BUILDIN(warpwaitingpc)
struct chat_data* cd;
TBL_PC* sd;
- nd = (struct npc_data *)map_id2bl(st->oid);
- if( nd == NULL || (cd=(struct chat_data *)map_id2bl(nd->chat_id)) == NULL )
+ nd = (struct npc_data *)iMap->id2bl(st->oid);
+ if( nd == NULL || (cd=(struct chat_data *)iMap->id2bl(nd->chat_id)) == NULL )
return true;
map_name = script_getstr(st,2);
@@ -10174,17 +10189,17 @@ BUILDIN(warpwaitingpc)
{// no zeny to cover set fee
break;
}
- pc_payzeny(sd, cd->zeny, LOG_TYPE_NPC, NULL);
+ pc->payzeny(sd, cd->zeny, LOG_TYPE_NPC, NULL);
}
mapreg_setreg(reference_uid(add_str("$@warpwaitingpc"), i), sd->bl.id);
if( strcmp(map_name,"Random") == 0 )
- pc_randomwarp(sd,CLR_TELEPORT);
+ pc->randomwarp(sd,CLR_TELEPORT);
else if( strcmp(map_name,"SavePoint") == 0 )
- pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
+ pc->setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
else
- pc_setpos(sd, mapindex_name2id(map_name), x, y, CLR_OUTSIGHT);
+ pc->setpos(sd, mapindex_name2id(map_name), x, y, CLR_OUTSIGHT);
}
mapreg_setreg(add_str("$@warpwaitingpcnum"), i);
return true;
@@ -10197,10 +10212,8 @@ BUILDIN(warpwaitingpc)
/// Detaches a character from a script.
///
/// @param st Script state to detach the character from.
-static void script_detach_rid(struct script_state* st)
-{
- if(st->rid)
- {
+void script_detach_rid(struct script_state* st) {
+ if(st->rid) {
script_detach_state(st, false);
st->rid = 0;
}
@@ -10213,7 +10226,7 @@ BUILDIN(attachrid)
{
int rid = script_getnum(st,2);
- if (map_id2sd(rid) != NULL) {
+ if (iMap->id2sd(rid) != NULL) {
script_detach_rid(st);
st->rid = rid;
@@ -10236,11 +10249,11 @@ BUILDIN(detachrid)
*------------------------------------------*/
BUILDIN(isloggedin)
{
- TBL_PC* sd = map_id2sd(script_getnum(st,2));
+ TBL_PC* sd = iMap->id2sd(script_getnum(st,2));
if (script_hasdata(st,3) && sd &&
sd->status.char_id != script_getnum(st,3))
sd = NULL;
- push_val(st->stack,C_INT,sd!=NULL);
+ script->push_val(st->stack,C_INT,sd!=NULL,NULL);
return true;
}
@@ -10258,7 +10271,7 @@ BUILDIN(setmapflagnosave)
str2=script_getstr(st,3);
x=script_getnum(st,4);
y=script_getnum(st,5);
- m = map_mapname2mapid(str);
+ m = iMap->mapname2mapid(str);
mapindex = mapindex_name2id(str2);
if(m >= 0 && mapindex) {
@@ -10279,7 +10292,7 @@ BUILDIN(getmapflag)
str=script_getstr(st,2);
i=script_getnum(st,3);
- m = map_mapname2mapid(str);
+ m = iMap->mapname2mapid(str);
if(m >= 0) {
switch(i) {
case MF_NOMEMO: script_pushint(st,map[m].flag.nomemo); break;
@@ -10340,7 +10353,7 @@ BUILDIN(getmapflag)
static int script_mapflag_pvp_sub(struct block_list *bl,va_list ap) {
TBL_PC* sd = (TBL_PC*)bl;
if (sd->pvp_timer == INVALID_TIMER) {
- sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
+ sd->pvp_timer = iTimer->add_timer(iTimer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0);
sd->pvp_rank = 0;
sd->pvp_lastusers = 0;
sd->pvp_point = 5;
@@ -10364,7 +10377,7 @@ BUILDIN(setmapflag)
if(script_hasdata(st,4)){
data = script_getdata(st,4);
- get_val(st, data);
+ script->get_val(st, data);
if( data_isstring(data) )
@@ -10373,7 +10386,7 @@ BUILDIN(setmapflag)
val = script_getnum(st, 4);
}
- m = map_mapname2mapid(str);
+ m = iMap->mapname2mapid(str);
if(m >= 0) {
switch(i) {
@@ -10386,7 +10399,7 @@ BUILDIN(setmapflag)
case MF_PVP:
map[m].flag.pvp = 1;
if( !battle_config.pk_mode ) {
- map_foreachinmap(script_mapflag_pvp_sub,m,BL_PC);
+ iMap->foreachinmap(script_mapflag_pvp_sub,m,BL_PC);
}
break;
case MF_PVP_NOPARTY: map[m].flag.pvp_noparty = 1; break;
@@ -10464,7 +10477,7 @@ BUILDIN(removemapflag)
if(script_hasdata(st,4)){
val=script_getnum(st,4);
}
- m = map_mapname2mapid(str);
+ m = iMap->mapname2mapid(str);
if(m >= 0) {
switch(i) {
case MF_NOMEMO: map[m].flag.nomemo = 0; break;
@@ -10517,7 +10530,7 @@ BUILDIN(removemapflag)
case MF_NOWARPTO: map[m].flag.nowarpto = 0; break;
case MF_NIGHTMAREDROP: map[m].flag.pvp_nightmaredrop = 0; break;
case MF_ZONE:
- map_zone_change2(m, map[m].prev_zone);
+ iMap->zone_change2(m, map[m].prev_zone);
break;
case MF_NOCOMMAND: map[m].nocommand = 0; break;
case MF_NODROP: map[m].flag.nodrop = 0; break;
@@ -10550,11 +10563,11 @@ BUILDIN(pvpon)
struct block_list bl;
str = script_getstr(st,2);
- m = map_mapname2mapid(str);
+ m = iMap->mapname2mapid(str);
if( m < 0 || map[m].flag.pvp )
return true; // nothing to do
- map_zone_change2(m, strdb_get(zone_db, MAP_ZONE_PVP_NAME));
+ iMap->zone_change2(m, strdb_get(zone_db, MAP_ZONE_PVP_NAME));
map[m].flag.pvp = 1;
clif->map_property_mapall(m, MAPPROPERTY_FREEPVPZONE);
bl.type = BL_NUL;
@@ -10571,7 +10584,7 @@ BUILDIN(pvpon)
if( sd->bl.m != m || sd->pvp_timer != INVALID_TIMER )
continue; // not applicable
- sd->pvp_timer = add_timer(gettick()+200,pc_calc_pvprank_timer,sd->bl.id,0);
+ sd->pvp_timer = iTimer->add_timer(iTimer->gettick()+200,pc->calc_pvprank_timer,sd->bl.id,0);
sd->pvp_rank = 0;
sd->pvp_lastusers = 0;
sd->pvp_point = 5;
@@ -10588,7 +10601,7 @@ static int buildin_pvpoff_sub(struct block_list *bl,va_list ap)
TBL_PC* sd = (TBL_PC*)bl;
clif->pvpset(sd, 0, 0, 2);
if (sd->pvp_timer != INVALID_TIMER) {
- delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
+ iTimer->delete_timer(sd->pvp_timer, pc->calc_pvprank_timer);
sd->pvp_timer = INVALID_TIMER;
}
return 0;
@@ -10601,11 +10614,11 @@ BUILDIN(pvpoff)
struct block_list bl;
str=script_getstr(st,2);
- m = map_mapname2mapid(str);
+ m = iMap->mapname2mapid(str);
if(m < 0 || !map[m].flag.pvp)
return true; //fixed Lupus
- map_zone_change2(m, map[m].prev_zone);
+ iMap->zone_change2(m, map[m].prev_zone);
map[m].flag.pvp = 0;
clif->map_property_mapall(m, MAPPROPERTY_NOTHING);
bl.type = BL_NUL;
@@ -10615,7 +10628,7 @@ BUILDIN(pvpoff)
if(battle_config.pk_mode) // disable ranking options if pk_mode is on [Valaris]
return true;
- map_foreachinmap(buildin_pvpoff_sub, m, BL_PC);
+ iMap->foreachinmap(buildin_pvpoff_sub, m, BL_PC);
return true;
}
@@ -10625,10 +10638,10 @@ BUILDIN(gvgon)
const char *str;
str=script_getstr(st,2);
- m = map_mapname2mapid(str);
+ m = iMap->mapname2mapid(str);
if(m >= 0 && !map[m].flag.gvg) {
struct block_list bl;
- map_zone_change2(m, strdb_get(zone_db, MAP_ZONE_GVG_NAME));
+ iMap->zone_change2(m, strdb_get(zone_db, MAP_ZONE_GVG_NAME));
map[m].flag.gvg = 1;
clif->map_property_mapall(m, MAPPROPERTY_AGITZONE);
bl.type = BL_NUL;
@@ -10644,10 +10657,10 @@ BUILDIN(gvgoff)
const char *str;
str=script_getstr(st,2);
- m = map_mapname2mapid(str);
+ m = iMap->mapname2mapid(str);
if(m >= 0 && map[m].flag.gvg) {
struct block_list bl;
- map_zone_change2(m, map[m].prev_zone);
+ iMap->zone_change2(m, map[m].prev_zone);
map[m].flag.gvg = 0;
clif->map_property_mapall(m, MAPPROPERTY_NOTHING);
bl.type = BL_NUL;
@@ -10677,7 +10690,7 @@ BUILDIN(emotion)
if (player) {
TBL_PC *sd = NULL;
if( script_hasdata(st,4) )
- sd = map_nick2sd(script_getstr(st,4));
+ sd = iMap->nick2sd(script_getstr(st,4));
else
sd = script_rid2sd(st);
if (sd)
@@ -10690,7 +10703,7 @@ BUILDIN(emotion)
clif->emotion(&nd->bl,type);
}
else
- clif->emotion(map_id2bl(st->oid),type);
+ clif->emotion(iMap->id2bl(st->oid),type);
return true;
}
@@ -10707,7 +10720,7 @@ static int buildin_maprespawnguildid_sub_pc(struct map_session_data* sd, va_list
(sd->status.guild_id != g_id && flag&2) || //Warp out outsiders
(sd->status.guild_id == 0) // Warp out players not in guild [Valaris]
)
- pc_setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
+ pc->setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
return 1;
}
@@ -10727,46 +10740,46 @@ BUILDIN(maprespawnguildid)
int g_id=script_getnum(st,3);
int flag=script_getnum(st,4);
- int16 m=map_mapname2mapid(mapname);
+ int16 m=iMap->mapname2mapid(mapname);
if(m == -1)
return true;
//Catch ALL players (in case some are 'between maps' on execution time)
- map_foreachpc(buildin_maprespawnguildid_sub_pc,m,g_id,flag);
+ iMap->map_foreachpc(buildin_maprespawnguildid_sub_pc,m,g_id,flag);
if (flag&4) //Remove script mobs.
- map_foreachinmap(buildin_maprespawnguildid_sub_mob,m,BL_MOB);
+ iMap->foreachinmap(buildin_maprespawnguildid_sub_mob,m,BL_MOB);
return true;
}
BUILDIN(agitstart)
{
- if(agit_flag==1) return true; // Agit already Start.
- agit_flag=1;
+ if(iMap->agit_flag==1) return true; // Agit already Start.
+ iMap->agit_flag=1;
guild->agit_start();
return true;
}
BUILDIN(agitend)
{
- if(agit_flag==0) return true; // Agit already End.
- agit_flag=0;
+ if(iMap->agit_flag==0) return true; // Agit already End.
+ iMap->agit_flag=0;
guild->agit_end();
return true;
}
BUILDIN(agitstart2)
{
- if(agit2_flag==1) return true; // Agit2 already Start.
- agit2_flag=1;
+ if(iMap->agit2_flag==1) return true; // Agit2 already Start.
+ iMap->agit2_flag=1;
guild->agit2_start();
return true;
}
BUILDIN(agitend2)
{
- if(agit2_flag==0) return true; // Agit2 already End.
- agit2_flag=0;
+ if(iMap->agit2_flag==0) return true; // Agit2 already End.
+ iMap->agit2_flag=0;
guild->agit2_end();
return true;
}
@@ -10776,7 +10789,7 @@ BUILDIN(agitend2)
*------------------------------------------*/
BUILDIN(agitcheck)
{
- script_pushint(st,agit_flag);
+ script_pushint(st,iMap->agit_flag);
return true;
}
@@ -10785,7 +10798,7 @@ BUILDIN(agitcheck)
*------------------------------------------*/
BUILDIN(agitcheck2)
{
- script_pushint(st,agit2_flag);
+ script_pushint(st,iMap->agit2_flag);
return true;
}
@@ -10799,7 +10812,7 @@ BUILDIN(flagemblem)
if(g_id < 0) return true;
- nd = (TBL_NPC*)map_id2nd(st->oid);
+ nd = (TBL_NPC*)iMap->id2nd(st->oid);
if( nd == NULL ) {
ShowError("script:flagemblem: npc %d not found\n", st->oid);
} else if( nd->subtype != SCRIPT ) {
@@ -10918,7 +10931,7 @@ BUILDIN(getequipcardcnt)
num=script_getnum(st,2);
sd=script_rid2sd(st);
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=pc_checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if (i < 0 || !sd->inventory_data[i]) {
script_pushint(st,0);
@@ -10950,7 +10963,7 @@ BUILDIN(successremovecards) {
int num = script_getnum(st,2);
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=pc_checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if (i < 0 || !sd->inventory_data[i]) {
return true;
@@ -10968,9 +10981,9 @@ BUILDIN(successremovecards) {
item_tmp.nameid = sd->status.inventory[i].card[c];
item_tmp.identify = 1;
- if((flag=pc_additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){ // get back the cart in inventory
+ if((flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){ // get back the cart in inventory
clif->additem(sd,0,0,flag);
- map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
}
}
@@ -10989,10 +11002,10 @@ BUILDIN(successremovecards) {
for (j = sd->inventory_data[i]->slot; j < MAX_SLOTS; j++)
item_tmp.card[j]=sd->status.inventory[i].card[j];
- pc_delitem(sd,i,1,0,3,LOG_TYPE_SCRIPT);
- if((flag=pc_additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){ //chk if can be spawn in inventory otherwise put on floor
+ pc->delitem(sd,i,1,0,3,LOG_TYPE_SCRIPT);
+ if((flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){ //chk if can be spawn in inventory otherwise put on floor
clif->additem(sd,0,0,flag);
- map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
clif->misceffect(&sd->bl,3);
@@ -11014,7 +11027,7 @@ BUILDIN(failedremovecards) {
int typefail = script_getnum(st,3);
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=pc_checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if (i < 0 || !sd->inventory_data[i])
return true;
@@ -11035,9 +11048,9 @@ BUILDIN(failedremovecards) {
item_tmp.nameid = sd->status.inventory[i].card[c];
item_tmp.identify = 1;
- if((flag=pc_additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){
+ if((flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){
clif->additem(sd,0,0,flag);
- map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
}
}
@@ -11045,7 +11058,7 @@ BUILDIN(failedremovecards) {
if(cardflag == 1) {
if(typefail == 0 || typefail == 2){ // destroy the item
- pc_delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
+ pc->delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
}
if(typefail == 1){ // destroy the card
int flag;
@@ -11062,11 +11075,11 @@ BUILDIN(failedremovecards) {
for (j = sd->inventory_data[i]->slot; j < MAX_SLOTS; j++)
item_tmp.card[j]=sd->status.inventory[i].card[j];
- pc_delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
+ pc->delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
- if((flag=pc_additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){
+ if((flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){
clif->additem(sd,0,0,flag);
- map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
}
clif->misceffect(&sd->bl,2);
@@ -11097,7 +11110,7 @@ BUILDIN(mapwarp) // Added by RoVeRT
check_ID=script_getnum(st,7);
}
- if((m=map_mapname2mapid(mapname))< 0)
+ if((m=iMap->mapname2mapid(mapname))< 0)
return true;
if(!(index=mapindex_name2id(str)))
@@ -11110,23 +11123,23 @@ BUILDIN(mapwarp) // Added by RoVeRT
for( i=0; i < g->max_member; i++)
{
if(g->member[i].sd && g->member[i].sd->bl.m==m){
- pc_setpos(g->member[i].sd,index,x,y,CLR_TELEPORT);
+ pc->setpos(g->member[i].sd,index,x,y,CLR_TELEPORT);
}
}
}
break;
case 2:
- p = party_search(check_ID);
+ p = party->search(check_ID);
if(p){
for(i=0;i<MAX_PARTY; i++){
if(p->data[i].sd && p->data[i].sd->bl.m == m){
- pc_setpos(p->data[i].sd,index,x,y,CLR_TELEPORT);
+ pc->setpos(p->data[i].sd,index,x,y,CLR_TELEPORT);
}
}
}
break;
default:
- map_foreachinmap(buildin_areawarp_sub,m,BL_PC,index,x,y,0,0);
+ iMap->foreachinmap(buildin_areawarp_sub,m,BL_PC,index,x,y,0,0);
break;
}
@@ -11153,7 +11166,7 @@ BUILDIN(mobcount) // Added by RoVeRT
event = NULL;
else
check_event(st, event);
-
+
if( strcmp(mapname, "this") == 0 ) {
struct map_session_data *sd = script_rid2sd(st);
if( sd )
@@ -11162,19 +11175,17 @@ BUILDIN(mobcount) // Added by RoVeRT
script_pushint(st,-1);
return true;
}
- }
- else if( (m = map_mapname2mapid(mapname)) < 0 ) {
+ } else if( (m = iMap->mapname2mapid(mapname)) < 0 ) {
script_pushint(st,-1);
return true;
}
-
- if( map[m].flag.src4instance && map[m].instance_id == 0 && st->instance_id && (m = instance_mapid2imapid(m, st->instance_id)) < 0 )
- {
+
+ if( map[m].flag.src4instance && map[m].instance_id == -1 && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 ) {
script_pushint(st,-1);
return true;
}
-
- script_pushint(st,map_foreachinmap(buildin_mobcount_sub, m, BL_MOB, event));
+
+ script_pushint(st,iMap->foreachinmap(buildin_mobcount_sub, m, BL_MOB, event));
return true;
}
@@ -11183,9 +11194,9 @@ BUILDIN(marriage)
{
const char *partner=script_getstr(st,2);
TBL_PC *sd=script_rid2sd(st);
- TBL_PC *p_sd=map_nick2sd(partner);
+ TBL_PC *p_sd=iMap->nick2sd(partner);
- if(sd==NULL || p_sd==NULL || pc_marriage(sd,p_sd) < 0){
+ if(sd==NULL || p_sd==NULL || pc->marriage(sd,p_sd) < 0){
script_pushint(st,0);
return true;
}
@@ -11198,7 +11209,7 @@ BUILDIN(wedding_effect)
struct block_list *bl;
if(sd==NULL) {
- bl=map_id2bl(st->oid);
+ bl=iMap->id2bl(st->oid);
} else
bl=&sd->bl;
clif->wedding_effect(bl);
@@ -11207,7 +11218,7 @@ BUILDIN(wedding_effect)
BUILDIN(divorce)
{
TBL_PC *sd=script_rid2sd(st);
- if(sd==NULL || pc_divorce(sd) < 0){
+ if(sd==NULL || pc->divorce(sd) < 0){
script_pushint(st,0);
return true;
}
@@ -11219,8 +11230,8 @@ BUILDIN(ispartneron)
{
TBL_PC *sd=script_rid2sd(st);
- if(sd==NULL || !pc_ismarried(sd) ||
- map_charid2sd(sd->status.partner_id) == NULL) {
+ if(sd==NULL || !pc->ismarried(sd) ||
+ iMap->charid2sd(sd->status.partner_id) == NULL) {
script_pushint(st,0);
return true;
}
@@ -11285,8 +11296,8 @@ BUILDIN(warppartner)
TBL_PC *sd=script_rid2sd(st);
TBL_PC *p_sd=NULL;
- if(sd==NULL || !pc_ismarried(sd) ||
- (p_sd=map_charid2sd(sd->status.partner_id)) == NULL) {
+ if(sd==NULL || !pc->ismarried(sd) ||
+ (p_sd=iMap->charid2sd(sd->status.partner_id)) == NULL) {
script_pushint(st,0);
return true;
}
@@ -11297,7 +11308,7 @@ BUILDIN(warppartner)
mapindex = mapindex_name2id(str);
if (mapindex) {
- pc_setpos(p_sd,mapindex,x,y,CLR_OUTSIGHT);
+ pc->setpos(p_sd,mapindex,x,y,CLR_OUTSIGHT);
script_pushint(st,1);
} else
script_pushint(st,0);
@@ -11361,7 +11372,7 @@ BUILDIN(guardian)
has_index = true;
} else if( script_hasdata(st,7) ){
data=script_getdata(st,7);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) )
{// "<event label>"
evt=script_getstr(st,7);
@@ -11398,16 +11409,16 @@ BUILDIN(setwall)
shootable = script_getnum(st,7);
name = script_getstr(st,8);
- if( (m = map_mapname2mapid(map)) < 0 )
+ if( (m = iMap->mapname2mapid(map)) < 0 )
return true; // Invalid Map
- map_iwall_set(m, x, y, size, dir, shootable, name);
+ iMap->iwall_set(m, x, y, size, dir, shootable, name);
return true;
}
BUILDIN(delwall)
{
const char *name = script_getstr(st,2);
- map_iwall_remove(name);
+ iMap->iwall_remove(name);
return true;
}
@@ -11440,7 +11451,7 @@ BUILDIN(guardianinfo)
if( !gc->guardian[id].visible )
script_pushint(st,-1);
else
- if( (gd = map_id2md(gc->guardian[id].id)) == NULL )
+ if( (gd = iMap->id2md(gc->guardian[id].id)) == NULL )
script_pushint(st,-1);
else
{
@@ -11464,17 +11475,17 @@ BUILDIN(getitemname)
struct script_data *data;
data=script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) ){
const char *name=script->conv_str(st,data);
- struct item_data *item_data = itemdb_searchname(name);
+ struct item_data *item_data = itemdb->search_name(name);
if( item_data )
item_id=item_data->nameid;
}else
item_id=script->conv_num(st,data);
- i_data = itemdb_exists(item_id);
+ i_data = itemdb->exists(item_id);
if (i_data == NULL)
{
script_pushconststr(st,"null");
@@ -11496,7 +11507,7 @@ BUILDIN(getitemslots)
item_id=script_getnum(st,2);
- i_data = itemdb_exists(item_id);
+ i_data = itemdb->exists(item_id);
if (i_data)
script_pushint(st,i_data->slot);
@@ -11537,7 +11548,7 @@ BUILDIN(getiteminfo)
item_id = script_getnum(st,2);
n = script_getnum(st,3);
- i_data = itemdb_exists(item_id);
+ i_data = itemdb->exists(item_id);
if (i_data && n>=0 && n<=14) {
item_arr = (int*)&i_data->value_buy;
@@ -11579,7 +11590,7 @@ BUILDIN(setiteminfo)
item_id = script_getnum(st,2);
n = script_getnum(st,3);
value = script_getnum(st,4);
- i_data = itemdb_exists(item_id);
+ i_data = itemdb->exists(item_id);
if (i_data && n>=0 && n<=14) {
item_arr = (int*)&i_data->value_buy;
@@ -11592,7 +11603,7 @@ BUILDIN(setiteminfo)
/*==========================================
* Returns value from equipped item slot n [Lupus]
- getequipcardid(num,slot)
+ getequpcardid(num,slot)
where
num = eqip position slot
slot = 0,1,2,3 (Card Slot N)
@@ -11611,7 +11622,7 @@ BUILDIN(getequipcardid)
slot=script_getnum(st,3);
sd=script_rid2sd(st);
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=pc_checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if(i >= 0 && slot>=0 && slot<4)
script_pushint(st,sd->status.inventory[i].card[slot]);
else
@@ -11636,7 +11647,7 @@ BUILDIN(petskillbonus)
if (pd->bonus)
{ //Clear previous bonus
if (pd->bonus->timer != INVALID_TIMER)
- delete_timer(pd->bonus->timer, pet_skill_bonus_timer);
+ iTimer->delete_timer(pd->bonus->timer, pet_skill_bonus_timer);
} else //init
pd->bonus = (struct pet_bonus *) aMalloc(sizeof(struct pet_bonus));
@@ -11652,7 +11663,7 @@ BUILDIN(petskillbonus)
if (battle_config.pet_equip_required && pd->pet.equip == 0)
pd->bonus->timer = INVALID_TIMER;
else
- pd->bonus->timer = add_timer(gettick()+pd->bonus->delay*1000, pet_skill_bonus_timer, sd->bl.id, 0);
+ pd->bonus->timer = iTimer->add_timer(iTimer->gettick()+pd->bonus->delay*1000, pet_skill_bonus_timer, sd->bl.id, 0);
return true;
}
@@ -11709,22 +11720,22 @@ BUILDIN(getinventorylist)
if(!sd) return true;
for(i=0;i<MAX_INVENTORY;i++){
if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].amount > 0){
- pc_setreg(sd,reference_uid(add_str("@inventorylist_id"), j),sd->status.inventory[i].nameid);
- pc_setreg(sd,reference_uid(add_str("@inventorylist_amount"), j),sd->status.inventory[i].amount);
- pc_setreg(sd,reference_uid(add_str("@inventorylist_equip"), j),sd->status.inventory[i].equip);
- pc_setreg(sd,reference_uid(add_str("@inventorylist_refine"), j),sd->status.inventory[i].refine);
- pc_setreg(sd,reference_uid(add_str("@inventorylist_identify"), j),sd->status.inventory[i].identify);
- pc_setreg(sd,reference_uid(add_str("@inventorylist_attribute"), j),sd->status.inventory[i].attribute);
+ pc->setreg(sd,reference_uid(add_str("@inventorylist_id"), j),sd->status.inventory[i].nameid);
+ pc->setreg(sd,reference_uid(add_str("@inventorylist_amount"), j),sd->status.inventory[i].amount);
+ pc->setreg(sd,reference_uid(add_str("@inventorylist_equip"), j),sd->status.inventory[i].equip);
+ pc->setreg(sd,reference_uid(add_str("@inventorylist_refine"), j),sd->status.inventory[i].refine);
+ pc->setreg(sd,reference_uid(add_str("@inventorylist_identify"), j),sd->status.inventory[i].identify);
+ pc->setreg(sd,reference_uid(add_str("@inventorylist_attribute"), j),sd->status.inventory[i].attribute);
for (k = 0; k < MAX_SLOTS; k++)
{
sprintf(card_var, "@inventorylist_card%d",k+1);
- pc_setreg(sd,reference_uid(add_str(card_var), j),sd->status.inventory[i].card[k]);
+ pc->setreg(sd,reference_uid(add_str(card_var), j),sd->status.inventory[i].card[k]);
}
- pc_setreg(sd,reference_uid(add_str("@inventorylist_expire"), j),sd->status.inventory[i].expire_time);
+ pc->setreg(sd,reference_uid(add_str("@inventorylist_expire"), j),sd->status.inventory[i].expire_time);
j++;
}
}
- pc_setreg(sd,add_str("@inventorylist_count"),j);
+ pc->setreg(sd,add_str("@inventorylist_count"),j);
return true;
}
@@ -11735,13 +11746,13 @@ BUILDIN(getskilllist)
if(!sd) return true;
for(i=0;i<MAX_SKILL;i++){
if(sd->status.skill[i].id > 0 && sd->status.skill[i].lv > 0){
- pc_setreg(sd,reference_uid(add_str("@skilllist_id"), j),sd->status.skill[i].id);
- pc_setreg(sd,reference_uid(add_str("@skilllist_lv"), j),sd->status.skill[i].lv);
- pc_setreg(sd,reference_uid(add_str("@skilllist_flag"), j),sd->status.skill[i].flag);
+ pc->setreg(sd,reference_uid(add_str("@skilllist_id"), j),sd->status.skill[i].id);
+ pc->setreg(sd,reference_uid(add_str("@skilllist_lv"), j),sd->status.skill[i].lv);
+ pc->setreg(sd,reference_uid(add_str("@skilllist_flag"), j),sd->status.skill[i].flag);
j++;
}
}
- pc_setreg(sd,add_str("@skilllist_count"),j);
+ pc->setreg(sd,add_str("@skilllist_count"),j);
return true;
}
@@ -11752,7 +11763,7 @@ BUILDIN(clearitem)
if(sd==NULL) return true;
for (i=0; i<MAX_INVENTORY; i++) {
if (sd->status.inventory[i].amount) {
- pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_SCRIPT);
+ pc->delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_SCRIPT);
}
}
return true;
@@ -11770,7 +11781,7 @@ BUILDIN(disguise)
id = script_getnum(st,2);
if (mobdb_checkid(id) || npcdb_checkid(id)) {
- pc_disguise(sd, id);
+ pc->disguise(sd, id);
script_pushint(st,id);
} else
script_pushint(st,0);
@@ -11787,7 +11798,7 @@ BUILDIN(undisguise)
if (sd == NULL) return true;
if (sd->disguise != -1) {
- pc_disguise(sd, -1);
+ pc->disguise(sd, -1);
script_pushint(st,0);
} else {
script_pushint(st,1);
@@ -11802,7 +11813,7 @@ BUILDIN(undisguise)
BUILDIN(classchange)
{
int _class,type;
- struct block_list *bl=map_id2bl(st->oid);
+ struct block_list *bl=iMap->id2bl(st->oid);
if(bl==NULL) return true;
@@ -11821,7 +11832,7 @@ BUILDIN(misceffect)
type=script_getnum(st,2);
if(st->oid && st->oid != fake_nd->bl.id) {
- struct block_list *bl = map_id2bl(st->oid);
+ struct block_list *bl = iMap->id2bl(st->oid);
if (bl)
clif->specialeffect(bl,type,AREA);
} else{
@@ -11883,17 +11894,17 @@ BUILDIN(playBGMall)
int x1 = script_getnum(st,6);
int y1 = script_getnum(st,7);
- map_foreachinarea(playBGM_sub, map_mapname2mapid(map), x0, y0, x1, y1, BL_PC, name);
+ iMap->foreachinarea(playBGM_sub, iMap->mapname2mapid(map), x0, y0, x1, y1, BL_PC, name);
}
else if( script_hasdata(st,3) )
{// entire map
const char* map = script_getstr(st,3);
- map_foreachinmap(playBGM_sub, map_mapname2mapid(map), BL_PC, name);
+ iMap->foreachinmap(playBGM_sub, iMap->mapname2mapid(map), BL_PC, name);
}
else
{// entire server
- map_foreachpc(&playBGM_foreachpc_sub, name);
+ iMap->map_foreachpc(&playBGM_foreachpc_sub, name);
}
return true;
@@ -11935,14 +11946,14 @@ BUILDIN(soundeffectall)
const char* name;
int type;
- bl = (st->rid) ? &(script_rid2sd(st)->bl) : map_id2bl(st->oid);
+ bl = (st->rid) ? &(script_rid2sd(st)->bl) : iMap->id2bl(st->oid);
if (!bl)
return true;
name = script_getstr(st,2);
type = script_getnum(st,3);
- //FIXME: enumerating map squares (map_foreach) is slower than enumerating the list of online players (map_foreachpc?) [ultramage]
+ //FIXME: enumerating map squares (iMap->foreach) is slower than enumerating the list of online players (iMap->foreachpc?) [ultramage]
if(!script_hasdata(st,4))
{ // area around
@@ -11952,7 +11963,7 @@ BUILDIN(soundeffectall)
if(!script_hasdata(st,5))
{ // entire map
const char* map = script_getstr(st,4);
- map_foreachinmap(soundeffect_sub, map_mapname2mapid(map), BL_PC, name, type);
+ iMap->foreachinmap(soundeffect_sub, iMap->mapname2mapid(map), BL_PC, name, type);
}
else
if(script_hasdata(st,8))
@@ -11962,7 +11973,7 @@ BUILDIN(soundeffectall)
int y0 = script_getnum(st,6);
int x1 = script_getnum(st,7);
int y1 = script_getnum(st,8);
- map_foreachinarea(soundeffect_sub, map_mapname2mapid(map), x0, y0, x1, y1, BL_PC, name, type);
+ iMap->foreachinarea(soundeffect_sub, iMap->mapname2mapid(map), x0, y0, x1, y1, BL_PC, name, type);
}
else
{
@@ -11987,7 +11998,7 @@ BUILDIN(petrecovery)
if (pd->recovery)
{ //Halt previous bonus
if (pd->recovery->timer != INVALID_TIMER)
- delete_timer(pd->recovery->timer, pet_recovery_timer);
+ iTimer->delete_timer(pd->recovery->timer, pet_recovery_timer);
} else //Init
pd->recovery = (struct pet_recovery *)aMalloc(sizeof(struct pet_recovery));
@@ -12015,9 +12026,9 @@ BUILDIN(petheal)
if (pd->s_skill->timer != INVALID_TIMER)
{
if (pd->s_skill->id)
- delete_timer(pd->s_skill->timer, pet_skill_support_timer);
+ iTimer->delete_timer(pd->s_skill->timer, pet_skill_support_timer);
else
- delete_timer(pd->s_skill->timer, pet_heal_timer);
+ iTimer->delete_timer(pd->s_skill->timer, pet_heal_timer);
}
} else //init memory
pd->s_skill = (struct pet_skill_support *) aMalloc(sizeof(struct pet_skill_support));
@@ -12033,7 +12044,7 @@ BUILDIN(petheal)
if (battle_config.pet_equip_required && pd->pet.equip == 0)
pd->s_skill->timer = INVALID_TIMER;
else
- pd->s_skill->timer = add_timer(gettick()+pd->s_skill->delay*1000,pet_heal_timer,sd->bl.id,0);
+ pd->s_skill->timer = iTimer->add_timer(iTimer->gettick()+pd->s_skill->delay*1000,pet_heal_timer,sd->bl.id,0);
return true;
}
@@ -12109,9 +12120,9 @@ BUILDIN(petskillsupport)
if (pd->s_skill->timer != INVALID_TIMER)
{
if (pd->s_skill->id)
- delete_timer(pd->s_skill->timer, pet_skill_support_timer);
+ iTimer->delete_timer(pd->s_skill->timer, pet_skill_support_timer);
else
- delete_timer(pd->s_skill->timer, pet_heal_timer);
+ iTimer->delete_timer(pd->s_skill->timer, pet_heal_timer);
}
} else //init memory
pd->s_skill = (struct pet_skill_support *) aMalloc(sizeof(struct pet_skill_support));
@@ -12126,7 +12137,7 @@ BUILDIN(petskillsupport)
if (battle_config.pet_equip_required && pd->pet.equip == 0)
pd->s_skill->timer = INVALID_TIMER;
else
- pd->s_skill->timer = add_timer(gettick()+pd->s_skill->delay*1000,pet_skill_support_timer,sd->bl.id,0);
+ pd->s_skill->timer = iTimer->add_timer(iTimer->gettick()+pd->s_skill->delay*1000,pet_skill_support_timer,sd->bl.id,0);
return true;
}
@@ -12156,7 +12167,7 @@ BUILDIN(skilleffect)
/// npcskilleffect "<skill name>",<level>,<x>,<y>
BUILDIN(npcskilleffect)
{
- struct block_list *bl= map_id2bl(st->oid);
+ struct block_list *bl= iMap->id2bl(st->oid);
uint16 skill_id=( script_isstring(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) );
uint16 skill_lv=script_getnum(st,3);
@@ -12164,7 +12175,7 @@ BUILDIN(npcskilleffect)
int y=script_getnum(st,5);
if (bl)
- clif->skill_poseffect(bl,skill_id,skill_lv,x,y,gettick());
+ clif->skill_poseffect(bl,skill_id,skill_lv,x,y,iTimer->gettick());
return true;
}
@@ -12174,7 +12185,7 @@ BUILDIN(npcskilleffect)
*------------------------------------------*/
BUILDIN(specialeffect)
{
- struct block_list *bl=map_id2bl(st->oid);
+ struct block_list *bl=iMap->id2bl(st->oid);
int type = script_getnum(st,2);
enum send_target target = script_hasdata(st,3) ? (send_target)script_getnum(st,3) : AREA;
@@ -12208,7 +12219,7 @@ BUILDIN(specialeffect2)
enum send_target target = script_hasdata(st,3) ? (send_target)script_getnum(st,3) : AREA;
if( script_hasdata(st,4) )
- sd = map_nick2sd(script_getstr(st,4));
+ sd = iMap->nick2sd(script_getstr(st,4));
if (sd)
clif->specialeffect(&sd->bl, type, target);
@@ -12231,7 +12242,7 @@ BUILDIN(nude)
if( sd->equip_index[ i ] >= 0 ) {
if( !calcflag )
calcflag = 1;
- pc_unequipitem( sd , sd->equip_index[ i ] , 2);
+ pc->unequipitem( sd , sd->equip_index[ i ] , 2);
}
}
@@ -12263,7 +12274,7 @@ BUILDIN(atcommand)
memset(&dummy_sd, 0, sizeof(TBL_PC));
if (st->oid)
{
- struct block_list* bl = map_id2bl(st->oid);
+ struct block_list* bl = iMap->id2bl(st->oid);
memcpy(&dummy_sd.bl, bl, sizeof(struct block_list));
if (bl->type == BL_NPC)
safestrncpy(dummy_sd.status.name, ((TBL_NPC*)bl)->name, NAME_LENGTH);
@@ -12397,7 +12408,7 @@ BUILDIN(getmercinfo)
{
char_id = script_getnum(st,3);
- if( ( sd = map_charid2sd(char_id) ) == NULL )
+ if( ( sd = iMap->charid2sd(char_id) ) == NULL )
{
ShowError("buildin_getmercinfo: No such character (char_id=%d).\n", char_id);
script_pushnil(st);
@@ -12491,8 +12502,7 @@ BUILDIN(jump_zero)
/*==========================================
* movenpc [MouseJstr]
*------------------------------------------*/
-BUILDIN(movenpc)
-{
+BUILDIN(movenpc) {
TBL_NPC *nd = NULL;
const char *npc;
int x,y;
@@ -12505,7 +12515,7 @@ BUILDIN(movenpc)
return -1;
if (script_hasdata(st,5))
- nd->ud.dir = script_getnum(st,5) % 8;
+ nd->dir = script_getnum(st,5) % 8;
npc_movenpc(nd, x, y);
return true;
}
@@ -12521,7 +12531,7 @@ BUILDIN(message)
player = script_getstr(st,2);
msg = script_getstr(st,3);
- if((pl_sd=map_nick2sd((char *) player)) == NULL)
+ if((pl_sd=iMap->nick2sd((char *) player)) == NULL)
return true;
clif->message(pl_sd->fd, msg);
@@ -12536,7 +12546,7 @@ BUILDIN(npctalk)
const char* str;
char name[NAME_LENGTH], message[256];
- struct npc_data* nd = (struct npc_data *)map_id2bl(st->oid);
+ struct npc_data* nd = (struct npc_data *)iMap->id2bl(st->oid);
str = script_getstr(st,2);
if(nd)
@@ -12557,26 +12567,35 @@ BUILDIN(npcspeed)
int speed;
speed = script_getnum(st,2);
- nd =(struct npc_data *)map_id2bl(st->oid);
+ nd =(struct npc_data *)iMap->id2bl(st->oid);
- if( nd )
- {
+ if( nd ) {
+ if( nd->ud == &npc_base_ud ) {
+ nd->ud = NULL;
+ CREATE(nd->ud, struct unit_data, 1);
+ unit_dataset(&nd->bl);
+ }
nd->speed = speed;
- nd->ud.state.speed_changed = 1;
+ nd->ud->state.speed_changed = 1;
}
return true;
}
// make an npc walk to a position [Valaris]
-BUILDIN(npcwalkto)
-{
- struct npc_data *nd=(struct npc_data *)map_id2bl(st->oid);
+BUILDIN(npcwalkto) {
+ struct npc_data *nd=(struct npc_data *)iMap->id2bl(st->oid);
int x=0,y=0;
x=script_getnum(st,2);
y=script_getnum(st,3);
if(nd) {
+ if( nd->ud == &npc_base_ud ) {
+ nd->ud = NULL;
+ CREATE(nd->ud, struct unit_data, 1);
+ unit_dataset(&nd->bl);
+ }
+
if (!nd->status.hp) {
status_calc_npc(nd, true);
} else {
@@ -12590,7 +12609,7 @@ BUILDIN(npcwalkto)
// stop an npc's movement [Valaris]
BUILDIN(npcstop)
{
- struct npc_data *nd=(struct npc_data *)map_id2bl(st->oid);
+ struct npc_data *nd=(struct npc_data *)iMap->id2bl(st->oid);
if(nd) {
unit_stop_walking(&nd->bl,1|4);
@@ -12711,7 +12730,7 @@ BUILDIN(getmapxy)
switch (type){
case 0: //Get Character Position
if( script_hasdata(st,6) )
- sd=map_nick2sd(script_getstr(st,6));
+ sd=iMap->nick2sd(script_getstr(st,6));
else
sd=script_rid2sd(st);
@@ -12726,11 +12745,11 @@ BUILDIN(getmapxy)
if (nd)
bl = &nd->bl;
} else //In case the origin is not an npc?
- bl=map_id2bl(st->oid);
+ bl=iMap->id2bl(st->oid);
break;
case 2: //Get Pet Position
if(script_hasdata(st,6))
- sd=map_nick2sd(script_getstr(st,6));
+ sd=iMap->nick2sd(script_getstr(st,6));
else
sd=script_rid2sd(st);
@@ -12741,7 +12760,7 @@ BUILDIN(getmapxy)
break; //Not supported?
case 4: //Get Homun Position
if(script_hasdata(st,6))
- sd=map_nick2sd(script_getstr(st,6));
+ sd=iMap->nick2sd(script_getstr(st,6));
else
sd=script_rid2sd(st);
@@ -12750,7 +12769,7 @@ BUILDIN(getmapxy)
break;
case 5: //Get Mercenary Position
if(script_hasdata(st,6))
- sd=map_nick2sd(script_getstr(st,6));
+ sd=iMap->nick2sd(script_getstr(st,6));
else
sd=script_rid2sd(st);
@@ -12759,7 +12778,7 @@ BUILDIN(getmapxy)
break;
case 6: //Get Elemental Position
if(script_hasdata(st,6))
- sd=map_nick2sd(script_getstr(st,6));
+ sd=iMap->nick2sd(script_getstr(st,6));
else
sd=script_rid2sd(st);
@@ -12771,7 +12790,7 @@ BUILDIN(getmapxy)
script_pushint(st,-1);
return false;
}
- if (!bl) { //No object found.
+ if (!bl || bl->m == -1) { //No object found.
script_pushint(st,-1);
return true;
}
@@ -12841,7 +12860,7 @@ BUILDIN(summon)
const char *str,*event="";
TBL_PC *sd;
struct mob_data *md;
- int tick = gettick();
+ int tick = iTimer->gettick();
sd=script_rid2sd(st);
if (!sd) return true;
@@ -12862,8 +12881,8 @@ BUILDIN(summon)
md->master_id=sd->bl.id;
md->special_state.ai = AI_ATTACK;
if( md->deletetimer != INVALID_TIMER )
- delete_timer(md->deletetimer, mob_timer_delete);
- md->deletetimer = add_timer(tick+(timeout>0?timeout*1000:60000),mob_timer_delete,md->bl.id,0);
+ iTimer->delete_timer(md->deletetimer, mob_timer_delete);
+ md->deletetimer = iTimer->add_timer(tick+(timeout>0?timeout*1000:60000),mob_timer_delete,md->bl.id,0);
mob_spawn (md); //Now it is ready for spawning.
clif->specialeffect(&md->bl,344,AREA);
sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
@@ -12876,13 +12895,13 @@ BUILDIN(summon)
*------------------------------------------*/
BUILDIN(isnight)
{
- script_pushint(st,(night_flag == 1));
+ script_pushint(st,(iMap->night_flag == 1));
return true;
}
BUILDIN(isday)
{
- script_pushint(st,(night_flag == 0));
+ script_pushint(st,(iMap->night_flag == 0));
return true;
}
@@ -13082,12 +13101,12 @@ BUILDIN(getrefine)
*-------------------------------------------------------*/
BUILDIN(night)
{
- if (night_flag != 1) map_night_timer(night_timer_tid, 0, 0, 1);
+ if (iMap->night_flag != 1) pc->map_night_timer(pc->night_timer_tid, 0, 0, 1);
return true;
}
BUILDIN(day)
{
- if (night_flag != 0) map_day_timer(day_timer_tid, 0, 0, 1);
+ if (iMap->night_flag != 0) pc->map_day_timer(pc->day_timer_tid, 0, 0, 1);
return true;
}
@@ -13104,9 +13123,9 @@ BUILDIN(unequip)
sd = script_rid2sd(st);
if( sd != NULL && num >= 1 && num <= ARRAYLENGTH(equip) )
{
- i = pc_checkequip(sd,equip[num-1]);
+ i = pc->checkequip(sd,equip[num-1]);
if (i >= 0)
- pc_unequipitem(sd,i,1|2);
+ pc->unequipitem(sd,i,1|2);
}
return true;
}
@@ -13120,14 +13139,14 @@ BUILDIN(equip)
sd = script_rid2sd(st);
nameid=script_getnum(st,2);
- if((item_data = itemdb_exists(nameid)) == NULL)
+ if((item_data = itemdb->exists(nameid)) == NULL)
{
ShowError("wrong item ID : equipitem(%i)\n",nameid);
return false;
}
ARR_FIND( 0, MAX_INVENTORY, i, sd->status.inventory[i].nameid == nameid );
if( i < MAX_INVENTORY )
- pc_equipitem(sd,i,item_data->equip);
+ pc->equipitem(sd,i,item_data->equip);
return true;
}
@@ -13139,7 +13158,7 @@ BUILDIN(autoequip)
nameid=script_getnum(st,2);
flag=script_getnum(st,3);
- if( ( item_data = itemdb_exists(nameid) ) == NULL )
+ if( ( item_data = itemdb->exists(nameid) ) == NULL )
{
ShowError("buildin_autoequip: Invalid item '%d'.\n", nameid);
return false;
@@ -13516,7 +13535,7 @@ BUILDIN(implode)
sprintf(output,"%s","NULL");
} else {
for(i = 0; i <= array_size; ++i) {
- temp = (char*) get_val2(st, reference_uid(id, i), reference_getref(data));
+ temp = (char*) script->get_val2(st, reference_uid(id, i), reference_getref(data));
len += strlen(temp);
script_removetop(st, -1, 0);
}
@@ -13531,7 +13550,7 @@ BUILDIN(implode)
//build output
for(i = 0; i < array_size; ++i) {
- temp = (char*) get_val2(st, reference_uid(id, i), reference_getref(data));
+ temp = (char*) script->get_val2(st, reference_uid(id, i), reference_getref(data));
len = strlen(temp);
memcpy(&output[k], temp, len);
k += len;
@@ -13541,7 +13560,7 @@ BUILDIN(implode)
}
script_removetop(st, -1, 0);
}
- temp = (char*) get_val2(st, reference_uid(id, array_size), reference_getref(data));
+ temp = (char*) script->get_val2(st, reference_uid(id, array_size), reference_getref(data));
len = strlen(temp);
memcpy(&output[k], temp, len);
k += len;
@@ -13996,14 +14015,14 @@ BUILDIN(setnpcdisplay)
if( script_hasdata(st,5) )
size = script_getnum(st,5);
- get_val(st, data);
+ script->get_val(st, data);
if( data_isstring(data) )
newname = script->conv_str(st,data);
else if( data_isint(data) )
class_ = script->conv_num(st,data);
else
{
- ShowError("script:setnpcdisplay: expected a string or number\n");
+ ShowError("script:setnpcdisplay: expected string or number\n");
script_reportdata(data);
return false;
}
@@ -14261,7 +14280,7 @@ BUILDIN(getd)
elem = 0;
// Push the 'pointer' so it's more flexible [Lance]
- push_val(st->stack, C_NAME, reference_uid(add_str(varname), elem));
+ script->push_val(st->stack, C_NAME, reference_uid(add_str(varname), elem),NULL);
return true;
}
@@ -14450,7 +14469,7 @@ BUILDIN(npcshopattach)
}
if (flag)
- nd->master_nd = ((struct npc_data *)map_id2bl(st->oid));
+ nd->master_nd = ((struct npc_data *)iMap->id2bl(st->oid));
else
nd->master_nd = NULL;
@@ -14478,7 +14497,7 @@ BUILDIN(setitemscript)
new_bonus_script = script_getstr(st,3);
if( script_hasdata(st,4) )
n=script_getnum(st,4);
- i_data = itemdb_exists(item_id);
+ i_data = itemdb->exists(item_id);
if (!i_data || new_bonus_script==NULL || ( new_bonus_script[0] && new_bonus_script[0]!='{' )) {
script_pushint(st,0);
@@ -14584,7 +14603,7 @@ BUILDIN(checkvending) // check vending [Nab4]
TBL_PC *sd = NULL;
if(script_hasdata(st,2))
- sd = map_nick2sd(script_getstr(st,2));
+ sd = iMap->nick2sd(script_getstr(st,2));
else
sd = script_rid2sd(st);
@@ -14602,7 +14621,7 @@ BUILDIN(checkchatting) // check chatting [Marka]
TBL_PC *sd = NULL;
if(script_hasdata(st,2))
- sd = map_nick2sd(script_getstr(st,2));
+ sd = iMap->nick2sd(script_getstr(st,2));
else
sd = script_rid2sd(st);
@@ -14619,7 +14638,7 @@ BUILDIN(checkidle)
TBL_PC *sd = NULL;
if (script_hasdata(st, 2))
- sd = map_nick2sd(script_getstr(st, 2));
+ sd = iMap->nick2sd(script_getstr(st, 2));
else
sd = script_rid2sd(st);
@@ -14644,10 +14663,10 @@ BUILDIN(searchitem)
int32 i;
TBL_PC* sd = NULL;
- if ((items[0] = itemdb_exists(atoi(itemname))))
+ if ((items[0] = itemdb->exists(atoi(itemname))))
count = 1;
else {
- count = itemdb_searchname_array(items, ARRAYLENGTH(items), itemname);
+ count = itemdb->search_name_array(items, ARRAYLENGTH(items), itemname);
if (count > MAX_SEARCH) count = MAX_SEARCH;
}
@@ -14746,7 +14765,7 @@ BUILDIN(rid2name)
{
struct block_list *bl = NULL;
int rid = script_getnum(st,2);
- if((bl = map_id2bl(rid)))
+ if((bl = iMap->id2bl(rid)))
{
switch(bl->type) {
case BL_MOB: script_pushstrcopy(st,((TBL_MOB*)bl)->name); break;
@@ -14776,7 +14795,7 @@ BUILDIN(pcblockmove)
flag = script_getnum(st,3);
if(id)
- sd = map_id2sd(id);
+ sd = iMap->id2sd(id);
else
sd = script_rid2sd(st);
@@ -14796,12 +14815,12 @@ BUILDIN(pcfollow)
targetid = script_getnum(st,3);
if(id)
- sd = map_id2sd(id);
+ sd = iMap->id2sd(id);
else
sd = script_rid2sd(st);
if(sd)
- pc_follow(sd, targetid);
+ pc->follow(sd, targetid);
return true;
}
@@ -14815,12 +14834,12 @@ BUILDIN(pcstopfollow)
id = script_getnum(st,2);
if(id)
- sd = map_id2sd(id);
+ sd = iMap->id2sd(id);
else
sd = script_rid2sd(st);
if(sd)
- pc_stop_following(sd);
+ pc->stop_following(sd);
return true;
}
@@ -14837,7 +14856,7 @@ BUILDIN(unitwalk)
{
struct block_list* bl;
- bl = map_id2bl(script_getnum(st,2));
+ bl = iMap->id2bl(script_getnum(st,2));
if( bl == NULL )
{
script_pushint(st, 0);
@@ -14851,7 +14870,7 @@ BUILDIN(unitwalk)
else
{
int map_id = script_getnum(st,3);
- script_pushint(st, unit_walktobl(bl,map_id2bl(map_id),65025,1));
+ script_pushint(st, unit_walktobl(bl,iMap->id2bl(map_id),65025,1));
}
return true;
@@ -14862,7 +14881,7 @@ BUILDIN(unitwalk)
/// unitkill <unit_id>;
BUILDIN(unitkill)
{
- struct block_list* bl = map_id2bl(script_getnum(st,2));
+ struct block_list* bl = iMap->id2bl(script_getnum(st,2));
if( bl != NULL )
status_kill(bl);
@@ -14888,14 +14907,14 @@ BUILDIN(unitwarp)
y = (short)script_getnum(st,5);
if (!unit_id) //Warp the script's runner
- bl = map_id2bl(st->rid);
+ bl = iMap->id2bl(st->rid);
else
- bl = map_id2bl(unit_id);
+ bl = iMap->id2bl(unit_id);
if( strcmp(mapname,"this") == 0 )
map = bl?bl->m:-1;
else
- map = map_mapname2mapid(mapname);
+ map = iMap->mapname2mapid(mapname);
if( map >= 0 && bl != NULL )
script_pushint(st, unit_warp(bl,map,x,y,CLR_OUTSIGHT));
@@ -14920,21 +14939,21 @@ BUILDIN(unitattack)
int actiontype = 0;
// get unit
- unit_bl = map_id2bl(script_getnum(st,2));
+ unit_bl = iMap->id2bl(script_getnum(st,2));
if( unit_bl == NULL ) {
script_pushint(st, 0);
return true;
}
data = script_getdata(st, 3);
- get_val(st, data);
+ script->get_val(st, data);
if( data_isstring(data) )
{
- TBL_PC* sd = map_nick2sd(script->conv_str(st, data));
+ TBL_PC* sd = iMap->nick2sd(script->conv_str(st, data));
if( sd != NULL )
target_bl = &sd->bl;
} else
- target_bl = map_id2bl(script->conv_num(st, data));
+ target_bl = iMap->id2bl(script->conv_num(st, data));
// request the attack
if( target_bl == NULL )
{
@@ -14949,7 +14968,7 @@ BUILDIN(unitattack)
switch( unit_bl->type )
{
case BL_PC:
- clif->pActionRequest_sub(((TBL_PC *)unit_bl), actiontype > 0 ? 0x07 : 0x00, target_bl->id, gettick());
+ clif->pActionRequest_sub(((TBL_PC *)unit_bl), actiontype > 0 ? 0x07 : 0x00, target_bl->id, iTimer->gettick());
script_pushint(st, 1);
return true;
case BL_MOB:
@@ -14977,7 +14996,7 @@ BUILDIN(unitstop)
unit_id = script_getnum(st,2);
- bl = map_id2bl(unit_id);
+ bl = iMap->id2bl(unit_id);
if( bl != NULL )
{
unit_stop_attack(bl);
@@ -15001,7 +15020,7 @@ BUILDIN(unittalk)
unit_id = script_getnum(st,2);
message = script_getstr(st, 3);
- bl = map_id2bl(unit_id);
+ bl = iMap->id2bl(unit_id);
if( bl != NULL )
{
struct StringBuf sbuf;
@@ -15029,7 +15048,7 @@ BUILDIN(unitemote)
unit_id = script_getnum(st,2);
emotion = script_getnum(st,3);
- bl = map_id2bl(unit_id);
+ bl = iMap->id2bl(unit_id);
if( bl != NULL )
clif->emotion(bl, emotion);
@@ -15053,7 +15072,7 @@ BUILDIN(unitskilluseid)
skill_lv = script_getnum(st,4);
target_id = ( script_hasdata(st,5) ? script_getnum(st,5) : unit_id );
- bl = map_id2bl(unit_id);
+ bl = iMap->id2bl(unit_id);
if( bl != NULL )
unit_skilluse_id(bl, target_id, skill_id, skill_lv);
@@ -15079,7 +15098,7 @@ BUILDIN(unitskillusepos)
skill_x = script_getnum(st,5);
skill_y = script_getnum(st,6);
- bl = map_id2bl(unit_id);
+ bl = iMap->id2bl(unit_id);
if( bl != NULL )
unit_skilluse_pos(bl, skill_x, skill_y, skill_id, skill_lv);
@@ -15128,7 +15147,7 @@ BUILDIN(sleep2)
if( ticks <= 0 )
{// do nothing
- script_pushint(st, (map_id2sd(st->rid)!=NULL));
+ script_pushint(st, (iMap->id2sd(st->rid)!=NULL));
}
else if( !st->sleep.tick )
{// sleep for the target amount of time
@@ -15139,7 +15158,7 @@ BUILDIN(sleep2)
{// sleep time is over
st->state = RUN;
st->sleep.tick = 0;
- script_pushint(st, (map_id2sd(st->rid)!=NULL));
+ script_pushint(st, (iMap->id2sd(st->rid)!=NULL));
}
return true;
}
@@ -15147,47 +15166,41 @@ BUILDIN(sleep2)
/// Awakes all the sleep timers of the target npc
///
/// awake "<npc name>";
-BUILDIN(awake)
-{
+BUILDIN(awake) {
+ DBIterator *iter;
+ struct script_state *tst;
struct npc_data* nd;
- struct linkdb_node *node = (struct linkdb_node *)sleep_db;
- nd = npc_name2id(script_getstr(st, 2));
- if( nd == NULL ) {
+ if( ( nd = npc_name2id(script_getstr(st, 2)) ) == NULL ) {
ShowError("awake: NPC \"%s\" not found\n", script_getstr(st, 2));
return false;
}
- while( node )
- {
- if( (int)__64BPTRSIZE(node->key) == nd->bl.id )
- {// sleep timer for the npc
- struct script_state* tst = (struct script_state*)node->data;
- TBL_PC* sd = map_id2sd(tst->rid);
+ iter = db_iterator(script->st_db);
+
+ for( tst = dbi_first(iter); dbi_exists(iter); tst = dbi_next(iter) ) {
+ if( tst->oid == nd->bl.id ) {
+ TBL_PC* sd = iMap->id2sd(tst->rid);
- if( tst->sleep.timer == INVALID_TIMER )
- {// already awake ???
- node = node->next;
+ if( tst->sleep.timer == INVALID_TIMER ) {// already awake ???
continue;
}
- if( (sd && sd->status.char_id != tst->sleep.charid) || (tst->rid && !sd))
- {// char not online anymore / another char of the same account is online - Cancel execution
+ if( (sd && sd->status.char_id != tst->sleep.charid) || (tst->rid && !sd)) {
+ // char not online anymore / another char of the same account is online - Cancel execution
tst->state = END;
tst->rid = 0;
}
- delete_timer(tst->sleep.timer, run_script_timer);
- node = script_erase_sleepdb(node);
+ iTimer->delete_timer(tst->sleep.timer, run_script_timer);
tst->sleep.timer = INVALID_TIMER;
if(tst->state != RERUNLINE)
tst->sleep.tick = 0;
run_script_main(tst);
}
- else
- {
- node = node->next;
- }
}
+
+ dbi_destroy(iter);
+
return true;
}
@@ -15230,7 +15243,7 @@ BUILDIN(getvariableofnpc)
return false;
}
- push_val2(st->stack, C_NAME, reference_getuid(data), &nd->u.scr.script->script_vars );
+ script->push_val(st->stack, C_NAME, reference_getuid(data), &nd->u.scr.script->script_vars );
return true;
}
@@ -15250,7 +15263,7 @@ BUILDIN(warpportal)
struct skill_unit_group* group;
struct block_list* bl;
- bl = map_id2bl(st->oid);
+ bl = iMap->id2bl(st->oid);
if( bl == NULL )
{
ShowError("script:warpportal: npc is needed\n");
@@ -15284,7 +15297,7 @@ BUILDIN(openmail)
if( sd == NULL )
return true;
- mail_openmail(sd);
+ mail->openmail(sd);
return true;
}
@@ -15309,12 +15322,12 @@ BUILDIN(openauction)
/// @see cell_chk* constants in const.txt for the types
BUILDIN(checkcell)
{
- int16 m = map_mapname2mapid(script_getstr(st,2));
+ int16 m = iMap->mapname2mapid(script_getstr(st,2));
int16 x = script_getnum(st,3);
int16 y = script_getnum(st,4);
cell_chk type = (cell_chk)script_getnum(st,5);
- script_pushint(st, map_getcell(m, x, y, type));
+ script_pushint(st, iMap->getcell(m, x, y, type));
return true;
}
@@ -15326,7 +15339,7 @@ BUILDIN(checkcell)
/// @see cell_* constants in const.txt for the types
BUILDIN(setcell)
{
- int16 m = map_mapname2mapid(script_getstr(st,2));
+ int16 m = iMap->mapname2mapid(script_getstr(st,2));
int16 x1 = script_getnum(st,3);
int16 y1 = script_getnum(st,4);
int16 x2 = script_getnum(st,5);
@@ -15341,7 +15354,7 @@ BUILDIN(setcell)
for( y = y1; y <= y2; ++y )
for( x = x1; x <= x2; ++x )
- map_setcell(m, x, y, type, flag);
+ map[m].setcell(m, x, y, type, flag);
return true;
}
@@ -15596,7 +15609,7 @@ BUILDIN(checkquest)
BUILDIN(showevent)
{
TBL_PC *sd = script_rid2sd(st);
- struct npc_data *nd = map_id2nd(st->oid);
+ struct npc_data *nd = iMap->id2nd(st->oid);
int state, color;
if( sd == NULL || nd == NULL )
@@ -15625,9 +15638,9 @@ BUILDIN(waitingroom2bg)
if( script_hasdata(st,7) )
nd = npc_name2id(script_getstr(st,7));
else
- nd = (struct npc_data *)map_id2bl(st->oid);
+ nd = (struct npc_data *)iMap->id2bl(st->oid);
- if( nd == NULL || (cd = (struct chat_data *)map_id2bl(nd->chat_id)) == NULL )
+ if( nd == NULL || (cd = (struct chat_data *)iMap->id2bl(nd->chat_id)) == NULL )
{
script_pushint(st,0);
return true;
@@ -15686,7 +15699,7 @@ BUILDIN(waitingroom2bg_single)
y = script_getnum(st,5);
nd = npc_name2id(script_getstr(st,6));
- if( nd == NULL || (cd = (struct chat_data *)map_id2bl(nd->chat_id)) == NULL || cd->users <= 0 )
+ if( nd == NULL || (cd = (struct chat_data *)iMap->id2bl(nd->chat_id)) == NULL || cd->users <= 0 )
return true;
if( (sd = cd->usersd[0]) == NULL )
@@ -15694,7 +15707,7 @@ BUILDIN(waitingroom2bg_single)
if( bg_team_join(bg_id, sd) )
{
- pc_setpos(sd, mapindex, x, y, CLR_TELEPORT);
+ pc->setpos(sd, mapindex, x, y, CLR_TELEPORT);
script_pushint(st,1);
}
else
@@ -15756,7 +15769,7 @@ BUILDIN(bg_monster_set_team)
int id = script_getnum(st,2),
bg_id = script_getnum(st,3);
- if( (mbl = map_id2bl(id)) == NULL || mbl->type != BL_MOB )
+ if( (mbl = iMap->id2bl(id)) == NULL || mbl->type != BL_MOB )
return true;
md = (TBL_MOB *)mbl;
md->bg_id = bg_id;
@@ -15798,7 +15811,7 @@ BUILDIN(bg_getareausers)
bg_id = script_getnum(st,2);
str = script_getstr(st,3);
- if( (bg = bg_team_search(bg_id)) == NULL || (m = map_mapname2mapid(str)) < 0 )
+ if( (bg = bg_team_search(bg_id)) == NULL || (m = iMap->mapname2mapid(str)) < 0 )
{
script_pushint(st,0);
return true;
@@ -15828,7 +15841,7 @@ BUILDIN(bg_updatescore)
int16 m;
str = script_getstr(st,2);
- if( (m = map_mapname2mapid(str)) < 0 )
+ if( (m = iMap->mapname2mapid(str)) < 0 )
return true;
map[m].bgscore_lion = script_getnum(st,3);
@@ -15865,25 +15878,28 @@ BUILDIN(bg_get_data)
* Instancing Script Commands
*------------------------------------------*/
-BUILDIN(instance_create)
-{
+BUILDIN(instance_create) {
const char *name;
- int party_id, res;
+ int owner_id, res;
+ int type = IOT_PARTY;
name = script_getstr(st, 2);
- party_id = script_getnum(st, 3);
+ owner_id = script_getnum(st, 3);
+ if( script_hasdata(st,4) ) {
+ type = script_getnum(st, 4);
+ if( type < IOT_NONE || type >= IOT_MAX ) {
+ ShowError("buildin_instance_create: unknown instance type %d for '%s'\n",type,name);
+ return true;
+ }
+ }
- res = instance_create(party_id, name);
- if( res == -4 ) // Already exists
- {
+ res = instance->create(owner_id, name, (enum instance_owner_type) type);
+ if( res == -4 ) { // Already exists
script_pushint(st, -1);
return true;
- }
- else if( res < 0 )
- {
+ } else if( res < 0 ) {
const char *err;
- switch(res)
- {
+ switch(res) {
case -3: err = "No free instances"; break;
case -2: err = "Invalid party ID"; break;
case -1: err = "Invalid type"; break;
@@ -15898,44 +15914,39 @@ BUILDIN(instance_create)
return true;
}
-BUILDIN(instance_destroy)
-{
- int instance_id;
- struct map_session_data *sd;
- struct party_data *p;
+BUILDIN(instance_destroy) {
+ int instance_id = -1;
if( script_hasdata(st, 2) )
instance_id = script_getnum(st, 2);
- else if( st->instance_id )
+ else if( st->instance_id >= 0 )
instance_id = st->instance_id;
- else if( (sd = script_rid2sd(st)) != NULL && sd->status.party_id && (p = party_search(sd->status.party_id)) != NULL && p->instance_id )
- instance_id = p->instance_id;
else return true;
- if( instance_id <= 0 || instance_id >= MAX_INSTANCE )
- {
+ if( !instance->valid(instance_id) ) {
ShowError("buildin_instance_destroy: Trying to destroy invalid instance %d.\n", instance_id);
return true;
}
- instance_destroy(instance_id);
+ instance->destroy(instance_id);
return true;
}
-BUILDIN(instance_attachmap)
-{
- const char *name;
+BUILDIN(instance_attachmap) {
+ const char *name, *map_name = NULL;
int16 m;
- int instance_id;
+ int instance_id = -1;
bool usebasename = false;
name = script_getstr(st,2);
instance_id = script_getnum(st,3);
- if( script_hasdata(st,4) && script_getnum(st,4) > 0)
+ if( script_hasdata(st,4) && script_getnum(st,4) > 0 )
usebasename = true;
- if( (m = instance_add_map(name, instance_id, usebasename)) < 0 ) // [Saithis]
- {
+ if( script_hasdata(st, 5) )
+ map_name = script_getstr(st, 5);
+
+ if( (m = instance->add_map(name, instance_id, usebasename, map_name)) < 0 ) { // [Saithis]
ShowError("buildin_instance_attachmap: instance creation failed (%s): %d\n", name, m);
script_pushconststr(st, "");
return true;
@@ -15945,109 +15956,81 @@ BUILDIN(instance_attachmap)
return true;
}
-BUILDIN(instance_detachmap)
-{
- struct map_session_data *sd;
- struct party_data *p;
+BUILDIN(instance_detachmap) {
const char *str;
int16 m;
- int instance_id;
+ int instance_id = -1;
str = script_getstr(st, 2);
if( script_hasdata(st, 3) )
instance_id = script_getnum(st, 3);
- else if( st->instance_id )
+ else if( st->instance_id >= 0 )
instance_id = st->instance_id;
- else if( (sd = script_rid2sd(st)) != NULL && sd->status.party_id && (p = party_search(sd->status.party_id)) != NULL && p->instance_id )
- instance_id = p->instance_id;
else return true;
- if( (m = map_mapname2mapid(str)) < 0 || (m = instance_map2imap(m,instance_id)) < 0 )
- {
+ if( (m = iMap->mapname2mapid(str)) < 0 || (m = instance->map2imap(m,instance_id)) < 0 ) {
ShowError("buildin_instance_detachmap: Trying to detach invalid map %s\n", str);
return true;
}
- instance_del_map(m);
+ instance->del_map(m);
return true;
}
-BUILDIN(instance_attach)
-{
- int instance_id;
+BUILDIN(instance_attach) {
+ int instance_id = -1;
instance_id = script_getnum(st, 2);
- if( instance_id <= 0 || instance_id >= MAX_INSTANCE )
+ if( !instance->valid(instance_id) )
return true;
st->instance_id = instance_id;
return true;
}
-BUILDIN(instance_id)
-{
- int instance_id;
-
- if( script_hasdata(st, 2) )
- {
- struct party_data *p;
- struct map_session_data *sd;
- int type;
- type = script_getnum(st, 2);
- if( type == 0 )
- instance_id = st->instance_id;
- else if( type == 1 && (sd = script_rid2sd(st)) != NULL && sd->status.party_id && (p = party_search(sd->status.party_id)) != NULL )
- instance_id = p->instance_id;
- else
- instance_id = 0;
- }
- else
- instance_id = st->instance_id;
-
- script_pushint(st, instance_id);
+BUILDIN(instance_id) {
+ script_pushint(st, st->instance_id);
return true;
}
BUILDIN(instance_set_timeout)
{
int progress_timeout, idle_timeout;
- int instance_id;
- struct map_session_data *sd;
- struct party_data *p;
+ int instance_id = -1;
progress_timeout = script_getnum(st, 2);
idle_timeout = script_getnum(st, 3);
if( script_hasdata(st, 4) )
instance_id = script_getnum(st, 4);
- else if( st->instance_id )
+ else if( st->instance_id >= 0 )
instance_id = st->instance_id;
- else if( (sd = script_rid2sd(st)) != NULL && sd->status.party_id && (p = party_search(sd->status.party_id)) != NULL && p->instance_id )
- instance_id = p->instance_id;
else return true;
- if( instance_id > 0 )
- instance_set_timeout(instance_id, progress_timeout, idle_timeout);
+ if( instance_id >= 0 )
+ instance->set_timeout(instance_id, progress_timeout, idle_timeout);
return true;
}
-BUILDIN(instance_init)
-{
+BUILDIN(instance_init) {
int instance_id = script_getnum(st, 2);
- if( instance[instance_id].state != INSTANCE_IDLE )
- {
+ if( !instance->valid(instance_id) ) {
+ ShowError("instance_init: invalid instance id %d.\n",instance_id);
+ return true;
+ }
+
+ if( instances[instance_id].state != INSTANCE_IDLE ) {
ShowError("instance_init: instance already initialized.\n");
return true;
}
- instance_init(instance_id);
+ instance->start(instance_id);
return true;
}
-BUILDIN(instance_announce)
-{
+BUILDIN(instance_announce) {
int instance_id = script_getnum(st,2);
const char *mes = script_getstr(st,3);
int flag = script_getnum(st,4);
@@ -16058,53 +16041,40 @@ BUILDIN(instance_announce)
int fontY = script_hasdata(st,9) ? script_getnum(st,9) : 0; // default fontY
int i;
- struct map_session_data *sd;
- struct party_data *p;
- if( instance_id == 0 )
- {
- if( st->instance_id )
+ if( instance_id == -1 ) {
+ if( st->instance_id >= 0 )
instance_id = st->instance_id;
- else if( (sd = script_rid2sd(st)) != NULL && sd->status.party_id && (p = party_search(sd->status.party_id)) != NULL && p->instance_id )
- instance_id = p->instance_id;
- else return true;
+ else
+ return true;
}
- if( instance_id <= 0 || instance_id >= MAX_INSTANCE )
+ if( !instance->valid(instance_id) )
return true;
- for( i = 0; i < instance[instance_id].num_map; i++ )
- map_foreachinmap(buildin_announce_sub, instance[instance_id].map[i], BL_PC,
+ for( i = 0; i < instances[instance_id].num_map; i++ )
+ iMap->foreachinmap(buildin_announce_sub, instances[instance_id].map[i], BL_PC,
mes, strlen(mes)+1, flag&0xf0, fontColor, fontType, fontSize, fontAlign, fontY);
return true;
}
-BUILDIN(instance_npcname)
-{
+BUILDIN(instance_npcname) {
const char *str;
- int instance_id = 0;
-
- struct map_session_data *sd;
- struct party_data *p;
+ int instance_id = -1;
struct npc_data *nd;
str = script_getstr(st, 2);
if( script_hasdata(st, 3) )
instance_id = script_getnum(st, 3);
- else if( st->instance_id )
+ else if( st->instance_id >= 0 )
instance_id = st->instance_id;
- else if( (sd = script_rid2sd(st)) != NULL && sd->status.party_id && (p = party_search(sd->status.party_id)) != NULL && p->instance_id )
- instance_id = p->instance_id;
- if( instance_id && (nd = npc_name2id(str)) != NULL )
- {
+ if( instance_id >= 0 && (nd = npc_name2id(str)) != NULL ) {
static char npcname[NAME_LENGTH];
snprintf(npcname, sizeof(npcname), "dup_%d_%d", instance_id, nd->bl.id);
script_pushconststr(st,npcname);
- }
- else
- {
+ } else {
ShowError("script:instance_npcname: invalid instance NPC (instance_id: %d, NPC name: \"%s\".)\n", instance_id, str);
st->state = END;
return false;
@@ -16113,24 +16083,62 @@ BUILDIN(instance_npcname)
return true;
}
-BUILDIN(has_instance)
-{
+BUILDIN(has_instance) {
struct map_session_data *sd;
- struct party_data *p;
const char *str;
int16 m;
- int instance_id = 0;
+ int instance_id = -1;
str = script_getstr(st, 2);
+
+ if( (m = iMap->mapname2mapid(str)) < 0 ) {
+ script_pushconststr(st, "");
+ return true;
+ }
+
if( script_hasdata(st, 3) )
instance_id = script_getnum(st, 3);
- else if( st->instance_id )
+ else if( st->instance_id >= 0 )
instance_id = st->instance_id;
- else if( (sd = script_rid2sd(st)) != NULL && sd->status.party_id && (p = party_search(sd->status.party_id)) != NULL && p->instance_id )
- instance_id = p->instance_id;
+ else if( (sd = script_rid2sd(st)) != NULL ) {
+ struct party_data *p;
+ int i = 0, j = 0;
+ if( sd->instances ) {
+ for( i = 0; i < sd->instances; i++ ) {
+ if( sd->instance[i] >= 0 ) {
+ ARR_FIND(0, instances[sd->instance[i]].num_map, j, map[instances[sd->instance[i]].map[j]].instance_src_map == m);
+ if( j != instances[sd->instance[i]].num_map )
+ break;
+ }
+ }
+ if( i != sd->instances )
+ instance_id = sd->instance[i];
+ }
+ if( instance_id == -1 && sd->status.party_id && (p = party->search(sd->status.party_id)) && p->instances ) {
+ for( i = 0; i < p->instances; i++ ) {
+ if( p->instance[i] >= 0 ) {
+ ARR_FIND(0, instances[p->instance[i]].num_map, j, map[instances[p->instance[i]].map[j]].instance_src_map == m);
+ if( j != instances[p->instance[i]].num_map )
+ break;
+ }
+ }
+ if( i != p->instances )
+ instance_id = p->instance[i];
+ }
+ if( instance_id == -1 && sd->guild && sd->guild->instances ) {
+ for( i = 0; i < sd->guild->instances; i++ ) {
+ if( sd->guild->instance[i] >= 0 ) {
+ ARR_FIND(0, instances[sd->guild->instance[i]].num_map, j, map[instances[sd->guild->instance[i]].map[j]].instance_src_map == m);
+ if( j != instances[sd->guild->instance[i]].num_map )
+ break;
+ }
+ }
+ if( i != sd->guild->instances )
+ instance_id = sd->guild->instance[i];
+ }
+ }
- if( !instance_id || (m = map_mapname2mapid(str)) < 0 || (m = instance_map2imap(m, instance_id)) < 0 )
- {
+ if( !instance->valid(instance_id) || (m = instance->map2imap(m, instance_id)) < 0 ) {
script_pushconststr(st, "");
return true;
}
@@ -16138,38 +16146,41 @@ BUILDIN(has_instance)
script_pushconststr(st, map[m].name);
return true;
}
-
-BUILDIN(instance_warpall)
-{
- struct map_session_data *pl_sd;
- int16 m, i;
- int instance_id;
+static int buildin_instance_warpall_sub(struct block_list *bl,va_list ap) {
+ struct map_session_data *sd = ((TBL_PC*)bl);
+ int mapindex = va_arg(ap,int);
+ int x = va_arg(ap,int);
+ int y = va_arg(ap,int);
+
+ pc->setpos(sd,mapindex,x,y,CLR_TELEPORT);
+
+ return 0;
+}
+BUILDIN(instance_warpall) {
+ int16 m;
+ int instance_id = -1;
const char *mapn;
int x, y;
- unsigned short mapindex;
- struct party_data *p = NULL;
+ int mapindex;
mapn = script_getstr(st,2);
x = script_getnum(st,3);
y = script_getnum(st,4);
+
if( script_hasdata(st,5) )
instance_id = script_getnum(st,5);
- else if( st->instance_id )
+ else if( st->instance_id >= 0 )
instance_id = st->instance_id;
- else if( (pl_sd = script_rid2sd(st)) != NULL && pl_sd->status.party_id && (p = party_search(pl_sd->status.party_id)) != NULL && p->instance_id )
- instance_id = p->instance_id;
- else return true;
-
- if( (m = map_mapname2mapid(mapn)) < 0 || (map[m].flag.src4instance && (m = instance_mapid2imapid(m, instance_id)) < 0) )
+ else
return true;
- if( !(p = party_search(instance[instance_id].party_id)) )
+ if( (m = iMap->mapname2mapid(mapn)) < 0 || (map[m].flag.src4instance && (m = instance->mapid2imapid(m, instance_id)) < 0) )
return true;
-
+
mapindex = map_id2index(m);
- for( i = 0; i < MAX_PARTY; i++ )
- if( (pl_sd = p->data[i].sd) && map[pl_sd->bl.m].instance_id == st->instance_id ) pc_setpos(pl_sd,mapindex,x,y,CLR_TELEPORT);
+ iMap->foreachininstance(buildin_instance_warpall_sub, instance_id, BL_PC,mapindex,x,y);
+
return true;
}
@@ -16183,8 +16194,7 @@ BUILDIN(instance_warpall)
* Example: instance_check_party (getcharid(1){,amount}{,min}{,max});
* Example 2: instance_check_party (getcharid(1),1,1,99);
*------------------------------------------*/
-BUILDIN(instance_check_party)
-{
+BUILDIN(instance_check_party) {
struct map_session_data *pl_sd;
int amount, min, max, i, party_id, c = 0;
struct party_data *p = NULL;
@@ -16196,7 +16206,7 @@ BUILDIN(instance_check_party)
if( min < 1 || min > MAX_LEVEL){
ShowError("instance_check_party: Invalid min level, %d\n", min);
return true;
- }else if( max < 1 || max > MAX_LEVEL){
+ } else if( max < 1 || max > MAX_LEVEL){
ShowError("instance_check_party: Invalid max level, %d\n", max);
return true;
}
@@ -16205,14 +16215,14 @@ BUILDIN(instance_check_party)
party_id = script_getnum(st,2);
else return true;
- if( !(p = party_search(party_id)) ){
+ if( !(p = party->search(party_id)) ){
script_pushint(st, 0); // Returns false if party does not exist.
return true;
}
for( i = 0; i < MAX_PARTY; i++ )
if( (pl_sd = p->data[i].sd) )
- if(map_id2bl(pl_sd->bl.id)){
+ if(iMap->id2bl(pl_sd->bl.id)){
if(pl_sd->status.base_level < min){
script_pushint(st, 0);
return true;
@@ -16268,9 +16278,9 @@ static int buildin_mobuseskill_sub(struct block_list *bl,va_list ap)
// 0:self, 1:target, 2:master, default:random
switch( target )
{
- case 0: tbl = map_id2bl(md->bl.id); break;
- case 1: tbl = map_id2bl(md->target_id); break;
- case 2: tbl = map_id2bl(md->master_id); break;
+ case 0: tbl = iMap->id2bl(md->bl.id); break;
+ case 1: tbl = iMap->id2bl(md->target_id); break;
+ case 2: tbl = iMap->id2bl(md->master_id); break;
default:tbl = battle->get_enemy(&md->bl, DEFAULT_ENEMY_TYPE(md),skill->get_range2(&md->bl, skill_id, skill_lv)); break;
}
@@ -16298,13 +16308,12 @@ BUILDIN(areamobuseskill)
int16 m;
int range,mobid,skill_id,skill_lv,casttime,emotion,target,cancel;
- if( (m = map_mapname2mapid(script_getstr(st,2))) < 0 )
- {
+ if( (m = iMap->mapname2mapid(script_getstr(st,2))) < 0 ) {
ShowError("areamobuseskill: invalid map name.\n");
return true;
}
- if( map[m].flag.src4instance && st->instance_id && (m = instance_mapid2imapid(m, st->instance_id)) < 0 )
+ if( map[m].flag.src4instance && st->instance_id >= 0 && (m = instance->mapid2imapid(m, st->instance_id)) < 0 )
return true;
center.m = m;
@@ -16319,7 +16328,7 @@ BUILDIN(areamobuseskill)
emotion = script_getnum(st,11);
target = script_getnum(st,12);
- map_foreachinrange(buildin_mobuseskill_sub, &center, range, BL_MOB, mobid, skill_id, skill_lv, casttime, cancel, emotion, target);
+ iMap->foreachinrange(buildin_mobuseskill_sub, &center, range, BL_MOB, mobid, skill_id, skill_lv, casttime, cancel, emotion, target);
return true;
}
@@ -16339,7 +16348,8 @@ BUILDIN(progressbar)
second = script_getnum(st,3);
sd->progressbar.npc_id = st->oid;
- sd->progressbar.timeout = gettick() + second*1000;
+ sd->progressbar.timeout = iTimer->gettick() + second*1000;
+ sd->state.workinprogress = 3;
clif->progressbar(sd, strtol(color, (char **)NULL, 0), second);
return true;
@@ -16500,10 +16510,10 @@ BUILDIN(setdragon) {
if( (sd = script_rid2sd(st)) == NULL )
return true;
- if( !pc_checkskill(sd,RK_DRAGONTRAINING) || (sd->class_&MAPID_THIRDMASK) != MAPID_RUNE_KNIGHT )
+ if( !pc->checkskill(sd,RK_DRAGONTRAINING) || (sd->class_&MAPID_THIRDMASK) != MAPID_RUNE_KNIGHT )
script_pushint(st,0);//Doesn't have the skill or it's not a Rune Knight
else if ( pc_isridingdragon(sd) ) {//Is mounted; release
- pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
+ pc->setoption(sd, sd->sc.option&~OPTION_DRAGON);
script_pushint(st,1);
} else {//Not mounted; Mount now.
unsigned int option = OPTION_DRAGON1;
@@ -16518,7 +16528,7 @@ BUILDIN(setdragon) {
option = OPTION_DRAGON1;
}
}
- pc_setoption(sd, sd->sc.option|option);
+ pc->setoption(sd, sd->sc.option|option);
script_pushint(st,1);
}
return true;
@@ -16548,9 +16558,10 @@ BUILDIN(setmounting) {
TBL_PC* sd;
if( (sd = script_rid2sd(st)) == NULL )
return true;
- if( sd->sc.option&(OPTION_WUGRIDER|OPTION_RIDING|OPTION_DRAGON|OPTION_MADOGEAR) )
+ if( sd->sc.option&(OPTION_WUGRIDER|OPTION_RIDING|OPTION_DRAGON|OPTION_MADOGEAR) ){
+ clif->msgtable(sd->fd, 0X78b);
script_pushint(st,0);//can't mount with one of these
- else {
+ }else {
if( sd->sc.data[SC_ALL_RIDING] )
status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER);
else
@@ -16588,12 +16599,12 @@ BUILDIN(getcharip)
if( script_hasdata(st, 2) )
{
if (script_isstring(st, 2))
- sd = map_nick2sd(script_getstr(st, 2));
+ sd = iMap->nick2sd(script_getstr(st, 2));
else if (script_isint(st, 2) || script_getnum(st, 2))
{
int id;
id = script_getnum(st, 2);
- sd = (map_id2sd(id) ? map_id2sd(id) : map_charid2sd(id));
+ sd = (iMap->id2sd(id) ? iMap->id2sd(id) : iMap->charid2sd(id));
}
}
else
@@ -16779,7 +16790,7 @@ BUILDIN(useatcmd)
memset(&dummy_sd, 0, sizeof(TBL_PC));
if( st->oid )
{
- struct block_list* bl = map_id2bl(st->oid);
+ struct block_list* bl = iMap->id2bl(st->oid);
memcpy(&dummy_sd.bl, bl, sizeof(struct block_list));
if( bl->type == BL_NPC )
safestrncpy(dummy_sd.status.name, ((TBL_NPC*)bl)->name, NAME_LENGTH);
@@ -16859,50 +16870,53 @@ BUILDIN(checkre)
return true;
}
-/* getrandgroupitem <group_id>,<quantity> */
+/* getrandgroupitem <container_item_id>,<quantity> */
BUILDIN(getrandgroupitem) {
- TBL_PC* sd;
- int i, get_count = 0, flag, nameid, group = script_getnum(st, 2), qty = script_getnum(st,3);
- struct item item_tmp;
-
- if( !( sd = script_rid2sd(st) ) )
- return true;
-
- if( qty <= 0 ) {
- ShowError("getrandgroupitem: qty is <= 0!\n");
- return false;
- }
-
- if(group < 1 || group >= MAX_ITEMGROUP) {
- ShowError("getrandgroupitem: Invalid group id %d\n", group);
- return false;
- }
- if (!itemgroup_db[group].qty) {
- ShowError("getrandgroupitem: group id %d is empty!\n", group);
- return false;
- }
-
- nameid = itemdb_searchrandomid(group);
- memset(&item_tmp,0,sizeof(item_tmp));
-
- item_tmp.nameid = nameid;
- item_tmp.identify = itemdb_isidentified(nameid);
-
- //Check if it's stackable.
- if (!itemdb_isstackable(nameid))
- get_count = 1;
- else
- get_count = qty;
+ struct item_data *data = NULL;
+ struct map_session_data *sd = NULL;
+ int nameid = script_getnum(st, 2);
+ int count = script_getnum(st, 3);
- for (i = 0; i < qty; i += get_count) {
- // if not pet egg
- if (!pet_create_egg(sd, nameid)) {
- if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_SCRIPT))) {
- clif->additem(sd, 0, 0, flag);
- if( pc_candrop(sd,&item_tmp) )
- map_addflooritem(&item_tmp,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ if( !(data = itemdb->exists(nameid)) ) {
+ ShowWarning("buildin_getrandgroupitem: unknown item id %d\n",nameid);
+ script_pushint(st, 1);
+ } else if ( count <= 0 ) {
+ ShowError("buildin_getrandgroupitem: qty is <= 0!\n");
+ script_pushint(st, 1);
+ } else if ( !data->group ) {
+ ShowWarning("buildin_getrandgroupitem: item '%s' (%d) isn't a group!\n",data->name,nameid);
+ script_pushint(st, 1);
+ } else if( !( sd = script->rid2sd(st) ) ) {
+ ShowWarning("buildin_getrandgroupitem: no player attached!! (item %s (%d))\n",data->name,nameid);
+ script_pushint(st, 1);
+ } else {
+ int i, get_count, flag;
+ struct item it;
+
+ memset(&it,0,sizeof(it));
+
+ nameid = itemdb->group_item(data->group);
+
+ it.nameid = nameid;
+ it.identify = itemdb_isidentified(nameid);
+
+ if (!itemdb_isstackable(nameid))
+ get_count = 1;
+ else
+ get_count = count;
+
+ for (i = 0; i < count; i += get_count) {
+ // if not pet egg
+ if (!pet_create_egg(sd, nameid)) {
+ if ((flag = pc->additem(sd, &it, get_count, LOG_TYPE_SCRIPT))) {
+ clif->additem(sd, 0, 0, flag);
+ if( pc->candrop(sd,&it) )
+ iMap->addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ }
}
}
+
+ script_pushint(st, 0);
}
return true;
@@ -16913,7 +16927,7 @@ BUILDIN(getrandgroupitem) {
static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
{
nullpo_ret(bl);
- map_clearflooritem(bl);
+ iMap->clearflooritem(bl);
return 0;
}
@@ -16925,19 +16939,19 @@ BUILDIN(cleanmap)
int16 x0 = 0, y0 = 0, x1 = 0, y1 = 0;
map = script_getstr(st, 2);
- m = map_mapname2mapid(map);
+ m = iMap->mapname2mapid(map);
if (!m)
return false;
if ((script_lastdata(st) - 2) < 4) {
- map_foreachinmap(atcommand_cleanfloor_sub, m, BL_ITEM);
+ iMap->foreachinmap(atcommand_cleanfloor_sub, m, BL_ITEM);
} else {
x0 = script_getnum(st, 3);
y0 = script_getnum(st, 4);
x1 = script_getnum(st, 5);
y1 = script_getnum(st, 6);
if (x0 > 0 && y0 > 0 && x1 > 0 && y1 > 0) {
- map_foreachinarea(atcommand_cleanfloor_sub, m, x0, y0, x1, y1, BL_ITEM);
+ iMap->foreachinarea(atcommand_cleanfloor_sub, m, x0, y0, x1, y1, BL_ITEM);
} else {
ShowError("cleanarea: invalid coordinate defined!\n");
return false;
@@ -16963,7 +16977,7 @@ BUILDIN(npcskill)
stat_point = script_getnum(st, 4);
npc_level = script_getnum(st, 5);
sd = script_rid2sd(st);
- nd = (struct npc_data *)map_id2bl(sd->npc_id);
+ nd = (struct npc_data *)iMap->id2bl(sd->npc_id);
if (stat_point > battle_config.max_third_parameter) {
ShowError("npcskill: stat point exceeded maximum of %d.\n",battle_config.max_third_parameter );
@@ -16994,6 +17008,344 @@ BUILDIN(npcskill)
return true;
}
+struct hQueue *script_hqueue_get(int idx) {
+ if( idx < 0 || idx >= script->hqs || script->hq[idx].items == -1 )
+ return NULL;
+ return &script->hq[idx];
+}
+/* set .@id,queue(); */
+/* creates queue, returns created queue id */
+BUILDIN(queue) {
+ int idx = script->hqs;
+ int i;
+
+ for(i = 0; i < script->hqs; i++) {
+ if( script->hq[i].items == -1 ) {
+ break;
+ }
+ }
+
+ if( i == script->hqs ) {
+ RECREATE(script->hq, struct hQueue, ++script->hqs);
+ script->hq[ idx ].item = NULL;
+ } else
+ idx = i;
+
+ script->hq[ idx ].id = idx;
+ script->hq[ idx ].items = 0;
+ script->hq[ idx ].onDeath[0] = '\0';
+ script->hq[ idx ].onLogOut[0] = '\0';
+ script->hq[ idx ].onMapChange[0] = '\0';
+
+ script_pushint(st,idx);
+ return true;
+}
+/* set .@length,queuesize(.@queue_id); */
+/* returns queue length */
+BUILDIN(queuesize) {
+ int idx = script_getnum(st, 2);
+
+ if( idx < 0 || idx >= script->hqs || script->hq[idx].items == -1 ) {
+ ShowWarning("buildin_queuesize: unknown queue id %d\n",idx);
+ script_pushint(st, 0);
+ } else
+ script_pushint(st, script->hq[ idx ].items );
+
+ return true;
+}
+bool script_hqueue_add(int idx, int var) {
+ if( idx < 0 || idx >= script->hqs || script->hq[idx].items == -1 ) {
+ ShowWarning("script_hqueue_add: unknown queue id %d\n",idx);
+ return true;
+ } else {
+ struct map_session_data *sd;
+ int i;
+
+ for(i = 0; i < script->hq[idx].items; i++) {
+ if( script->hq[idx].item[i] == var ) {
+ return true;
+ }
+ }
+
+ if( i == script->hq[idx].items ) {
+
+ for(i = 0; i < script->hq[idx].items; i++) {
+ if( script->hq[idx].item[i] == 0 ) {
+ break;
+ }
+ }
+
+ if( i == script->hq[idx].items )
+ RECREATE(script->hq[idx].item, int, ++script->hq[idx].items);
+
+ script->hq[idx].item[i] = var;
+
+ if( var >= START_ACCOUNT_NUM && (sd = iMap->id2sd(var)) ) {
+ for(i = 0; i < sd->queues_count; i++) {
+ if( sd->queues[i] == -1 ) {
+ break;
+ }
+ }
+
+ if( i == sd->queues_count )
+ RECREATE(sd->queues, int, ++sd->queues_count);
+
+ sd->queues[i] = idx;
+ }
+
+ }
+ }
+ return false;
+}
+/* queueadd(.@queue_id,.@var_id); */
+/* adds a new entry to the queue, returns 1 if already in queue, 0 otherwise */
+BUILDIN(queueadd) {
+ int idx = script_getnum(st, 2);
+ int var = script_getnum(st, 3);
+
+ script_pushint(st,script->queue_add(idx,var)?1:0);
+
+ return true;
+}
+bool script_hqueue_remove(int idx, int var) {
+ if( idx < 0 || idx >= script->hqs || script->hq[idx].items == -1 ) {
+ ShowWarning("script_hqueue_remove: unknown queue id %d (used with var %d)\n",idx,var);
+ return true;
+ } else {
+ int i;
+
+ for(i = 0; i < script->hq[idx].items; i++) {
+ if( script->hq[idx].item[i] == var ) {
+ return true;
+ }
+ }
+
+ if( i != script->hq[idx].items ) {
+ struct map_session_data *sd;
+ script->hq[idx].item[i] = 0;
+
+ if( var >= START_ACCOUNT_NUM && (sd = iMap->id2sd(var)) ) {
+ for(i = 0; i < sd->queues_count; i++) {
+ if( sd->queues[i] == var ) {
+ break;
+ }
+ }
+
+ if( i != sd->queues_count )
+ sd->queues[i] = -1;
+ }
+
+ }
+ }
+ return false;
+}
+/* queueremove(.@queue_id,.@var_id); */
+/* removes a entry from the queue, returns 1 if not in queue, 0 otherwise */
+BUILDIN(queueremove) {
+ int idx = script_getnum(st, 2);
+ int var = script_getnum(st, 3);
+
+ script_pushint(st, script->queue_remove(idx,var)?1:0);
+
+ return true;
+}
+
+/* queueopt(.@queue_id,optionType,<optional val>); */
+/* modifies the queue's options, when val is not provided the option is removed */
+/* when OnMapChange event is triggered, it sets a temp char var @QMapChangeTo$ with the destination map name */
+/* returns 1 when fails, 0 on success */
+BUILDIN(queueopt) {
+ int idx = script_getnum(st, 2);
+ int var = script_getnum(st, 3);
+
+ if( idx < 0 || idx >= script->hqs || script->hq[idx].items == -1 ) {
+ ShowWarning("buildin_queueopt: unknown queue id %d\n",idx);
+ script_pushint(st, 1);
+ } else if( var <= HQO_NONE || var >= HQO_MAX ) {
+ ShowWarning("buildin_queueopt: unknown optionType %d\n",var);
+ script_pushint(st, 1);
+ } else {
+ switch( (enum hQueueOpt)var ) {
+ case HQO_OnDeath:
+ if( script_hasdata(st, 4) )
+ safestrncpy(script->hq[idx].onDeath, script_getstr(st, 4), EVENT_NAME_LENGTH);
+ else
+ script->hq[idx].onDeath[0] = '\0';
+ break;
+ case HQO_onLogOut:
+ if( script_hasdata(st, 4) )
+ safestrncpy(script->hq[idx].onLogOut, script_getstr(st, 4), EVENT_NAME_LENGTH);
+ else
+ script->hq[idx].onLogOut[0] = '\0';
+ break;
+ case HQO_OnMapChange:
+ if( script_hasdata(st, 4) )
+ safestrncpy(script->hq[idx].onMapChange, script_getstr(st, 4), EVENT_NAME_LENGTH);
+ else
+ script->hq[idx].onMapChange[0] = '\0';
+ break;
+ default:
+ ShowWarning("buildin_queueopt: unsupported optionType %d\n",var);
+ script_pushint(st, 1);
+ break;
+ }
+ }
+
+ return true;
+}
+bool script_hqueue_del(int idx) {
+ if( idx < 0 || idx >= script->hqs || script->hq[idx].items == -1 ) {
+ ShowWarning("script_queue_del: unknown queue id %d\n",idx);
+ return true;
+ } else {
+ struct map_session_data *sd;
+ int i;
+
+ for(i = 0; i < script->hq[idx].items; i++) {
+ if( script->hq[idx].item[i] >= START_ACCOUNT_NUM && (sd = iMap->id2sd(script->hq[idx].item[i])) ) {
+ int j;
+ for(j = 0; j < sd->queues_count; j++) {
+ if( sd->queues[j] == script->hq[idx].item[i] ) {
+ break;
+ }
+ }
+
+ if( j != sd->queues_count )
+ sd->queues[j] = -1;
+ }
+ }
+
+ script->hq[idx].items = -1;
+ }
+ return false;
+}
+/* queuedel(.@queue_id); */
+/* deletes queue of id .@queue_id, returns 1 if id not found, 0 otherwise */
+BUILDIN(queuedel) {
+ int idx = script_getnum(st, 2);
+
+ script_pushint(st,script->queue_del(idx)?1:0);
+
+ return true;
+}
+
+/* set .@id, queueiterator(.@queue_id); */
+/* creates a new queue iterator, returns its id */
+BUILDIN(queueiterator) {
+ int qid = script_getnum(st, 2);
+ struct hQueue *queue = NULL;
+ int idx = script->hqis;
+ int i;
+
+ if( qid < 0 || qid >= script->hqs || script->hq[idx].items == -1 || !(queue = script->queue(qid)) ) {
+ ShowWarning("queueiterator: invalid queue id %d\n",qid);
+ return true;
+ }
+
+ for(i = 0; i < script->hqis; i++) {
+ if( script->hqi[i].items == -1 ) {
+ break;
+ }
+ }
+
+ if( i == script->hqis )
+ RECREATE(script->hqi, struct hQueueIterator, ++script->hqis);
+ else
+ idx = i;
+
+ RECREATE(script->hqi[ idx ].item, int, queue->items);
+
+ memcpy(&script->hqi[idx].item, &queue->item, sizeof(int)*queue->items);
+
+ script->hqi[ idx ].items = queue->items;
+ script->hqi[ idx ].pos = 0;
+
+ script_pushint(st,idx);
+ return true;
+}
+/* Queue Iterator Get Next */
+/* returns next/first member in the iterator, 0 if none */
+BUILDIN(qiget) {
+ int idx = script_getnum(st, 2);
+
+ if( idx < 0 || idx >= script->hqis ) {
+ ShowWarning("buildin_qiget: unknown queue iterator id %d\n",idx);
+ script_pushint(st, 0);
+ } else if ( script->hqi[idx].pos == script->hqi[idx].items ) {
+ script_pushint(st, 0);
+ } else {
+ struct hQueueIterator *it = &script->hqi[idx];
+ script_pushint(st, it->item[it->pos++]);
+ }
+
+ return true;
+}
+/* Queue Iterator Check */
+/* returns 1:0 if there is a next member in the iterator */
+BUILDIN(qicheck) {
+ int idx = script_getnum(st, 2);
+
+ if( idx < 0 || idx >= script->hqis ) {
+ ShowWarning("buildin_qicheck: unknown queue iterator id %d\n",idx);
+ script_pushint(st, 0);
+ } else if ( script->hqi[idx].pos == script->hqi[idx].items ) {
+ script_pushint(st, 0);
+ } else {
+ script_pushint(st, 1);
+ }
+
+ return true;
+}
+/* Queue Iterator Check */
+BUILDIN(qiclear) {
+ int idx = script_getnum(st, 2);
+
+ if( idx < 0 || idx >= script->hqis ) {
+ ShowWarning("buildin_qiclear: unknown queue iterator id %d\n",idx);
+ script_pushint(st, 1);
+ } else {
+ script->hqi[idx].items = -1;
+ script_pushint(st, 0);
+ }
+
+ return true;
+}
+/**
+ * packageitem({<optional container_item_id>})
+ * when no item id is provided it tries to assume it comes from the current item id being processed (if any)
+ **/
+BUILDIN(packageitem) {
+ struct item_data *data = NULL;
+ struct map_session_data *sd = NULL;
+ int nameid;
+
+ if( script_hasdata(st, 2) )
+ nameid = script_getnum(st, 2);
+ else if ( script->current_item_id )
+ nameid = script->current_item_id;
+ else {
+ ShowWarning("buildin_packageitem: no item id provided and no item attached\n");
+ script_pushint(st, 1);
+ return true;
+ }
+
+ if( !(data = itemdb->exists(nameid)) ) {
+ ShowWarning("buildin_packageitem: unknown item id %d\n",nameid);
+ script_pushint(st, 1);
+ } else if ( !data->package ) {
+ ShowWarning("buildin_packageitem: item '%s' (%d) isn't a package!\n",data->name,nameid);
+ script_pushint(st, 1);
+ } else if( !( sd = script->rid2sd(st) ) ) {
+ ShowWarning("buildin_packageitem: no player attached!! (item %s (%d))\n",data->name,nameid);
+ script_pushint(st, 1);
+ } else {
+ itemdb->package_item(sd,data->package);
+ script_pushint(st, 0);
+ }
+
+ return true;
+}
+
// declarations that were supposed to be exported from npc_chat.c
#ifdef PCRE_SUPPORT
BUILDIN(defpattern);
@@ -17005,9 +17357,9 @@ BUILDIN(npcskill)
bool script_hp_add(char *name, char *args, bool (*func)(struct script_state *st)) {
int n = add_str(name), i = 0;
- if( str_data[n].type == C_FUNC ) {
- str_data[n].func = func;
- i = str_data[n].val;
+ if( script->str_data[n].type == C_FUNC ) {
+ script->str_data[n].func = func;
+ i = script->str_data[n].val;
if( args ) {
int slen = strlen(args);
if( script->buildin[i] ) {
@@ -17023,9 +17375,9 @@ bool script_hp_add(char *name, char *args, bool (*func)(struct script_state *st)
} else {
i = script->buildin_count;
- str_data[n].type = C_FUNC;
- str_data[n].val = i;
- str_data[n].func = func;
+ script->str_data[n].type = C_FUNC;
+ script->str_data[n].val = i;
+ script->str_data[n].func = func;
RECREATE(script->buildin, char *, ++script->buildin_count);
@@ -17396,6 +17748,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF2(homunculus_evolution,"homevolution",""), //[orn]
BUILDIN_DEF2(homunculus_mutate,"hommutate","?"),
BUILDIN_DEF2(homunculus_shuffle,"homshuffle",""), //[Zephyrus]
+ BUILDIN_DEF(checkhomcall,""),
BUILDIN_DEF(eaclass,"?"), //[Skotlex]
BUILDIN_DEF(roclass,"i?"), //[Skotlex]
BUILDIN_DEF(checkvending,"?"),
@@ -17442,12 +17795,12 @@ void script_parse_builtin(void) {
BUILDIN_DEF(bg_updatescore,"sii"),
// Instancing
- BUILDIN_DEF(instance_create,"si"),
+ BUILDIN_DEF(instance_create,"si?"),
BUILDIN_DEF(instance_destroy,"?"),
- BUILDIN_DEF(instance_attachmap,"si?"),
+ BUILDIN_DEF(instance_attachmap,"si??"),
BUILDIN_DEF(instance_detachmap,"s?"),
BUILDIN_DEF(instance_attach,"i"),
- BUILDIN_DEF(instance_id,"?"),
+ BUILDIN_DEF(instance_id,""),
BUILDIN_DEF(instance_set_timeout,"ii?"),
BUILDIN_DEF(instance_init,"i"),
BUILDIN_DEF(instance_announce,"isi?????"),
@@ -17492,6 +17845,23 @@ void script_parse_builtin(void) {
BUILDIN_DEF(checkquest, "i?"),
BUILDIN_DEF(changequest, "ii"),
BUILDIN_DEF(showevent, "ii"),
+
+ /**
+ * hQueue [Ind/Hercules]
+ **/
+ BUILDIN_DEF(queue,""),
+ BUILDIN_DEF(queuesize,"i"),
+ BUILDIN_DEF(queueadd,"ii"),
+ BUILDIN_DEF(queueremove,"ii"),
+ BUILDIN_DEF(queueopt,"ii?"),
+ BUILDIN_DEF(queuedel,"i"),
+ BUILDIN_DEF(queueiterator,"i"),
+ BUILDIN_DEF(qicheck,"i"),
+ BUILDIN_DEF(qiget,"i"),
+ BUILDIN_DEF(qiclear,"i"),
+
+ BUILDIN_DEF(packageitem,"?"),
+
};
int i,n, len = ARRAYLENGTH(BUILDIN), start = script->buildin_count;
char* p;
@@ -17522,12 +17892,12 @@ void script_parse_builtin(void) {
else if (!strcmp(BUILDIN[i].name, "callfunc")) buildin_callfunc_ref = n;
else if (!strcmp(BUILDIN[i].name, "getelementofarray") ) buildin_getelementofarray_ref = n;
- if( str_data[n].func && str_data[n].func != BUILDIN[i].func )
+ if( script->str_data[n].func && script->str_data[n].func != BUILDIN[i].func )
continue;/* something replaced it, skip. */
- str_data[n].type = C_FUNC;
- str_data[n].val = offset;
- str_data[n].func = BUILDIN[i].func;
+ script->str_data[n].type = C_FUNC;
+ script->str_data[n].val = offset;
+ script->str_data[n].func = BUILDIN[i].func;
/* we only store the arguments, its the only thing used out of this */
if( slen ) {
@@ -17545,9 +17915,32 @@ void script_parse_builtin(void) {
void script_defaults(void) {
script = &script_s;
+ script->st_db = NULL;
+ script->active_scripts = 0;
+ script->next_id = 0;
+ script->st_ers = NULL;
+ script->stack_ers = NULL;
+
+ script->hq = NULL;
+ script->hqi = NULL;
+ script->hqs = script->hqis = 0;
+ memset(&script->hqe, 0, sizeof(script->hqe));
+
script->buildin_count = 0;
script->buildin = NULL;
+ script->str_data = NULL;
+ script->str_data_size = 0;
+ script->str_num = LABEL_START;
+ script->str_buf = NULL;
+ script->str_size = 0;
+ script->str_pos = 0;
+
+ script->word_buf = NULL;
+ script->word_size = 0;
+
+ script->current_item_id = 0;
+
script->init = do_init_script;
script->final = do_final_script;
@@ -17555,4 +17948,20 @@ void script_defaults(void) {
script->addScript = script_hp_add;
script->conv_num = conv_num;
script->conv_str = conv_str;
+ script->rid2sd = script_rid2sd;
+ script->detach_rid = script_detach_rid;
+ script->push_val = push_val;
+ script->get_val = get_val;
+ script->get_val2 = get_val2;
+ script->push_str = push_str;
+ script->push_copy = push_copy;
+ script->pop_stack = pop_stack;
+ script->set_constant = script_set_constant;
+ script->set_constant2 = script_set_constant2;
+ script->get_constant = script_get_constant;
+
+ script->queue = script_hqueue_get;
+ script->queue_add = script_hqueue_add;
+ script->queue_del = script_hqueue_del;
+ script->queue_remove = script_hqueue_remove;
}
diff --git a/src/map/script.h b/src/map/script.h
index a0d282bfe..a047779a8 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -4,9 +4,12 @@
#ifndef _SCRIPT_H_
#define _SCRIPT_H_
+#include "map.h" //EVENT_NAME_LENGTH
+
#define NUM_WHISPER_VAR 10
struct map_session_data;
+struct eri;
extern int potion_flag; //For use on Alchemist improved potions/Potion Pitcher. [Skotlex]
extern int potion_hp, potion_per_hp, potion_sp, potion_per_sp;
@@ -110,6 +113,30 @@ struct script_stack {
struct DBMap* var_function;// scope variables
};
+enum hQueueOpt {
+ HQO_NONE,
+ HQO_onLogOut,
+ HQO_OnDeath,
+ HQO_OnMapChange,
+ HQO_MAX,
+};
+
+/* [Ind/Hercules] */
+struct hQueue {
+ int id;
+ int *item;
+ int items;
+ /* events */
+ char onLogOut[EVENT_NAME_LENGTH];
+ char onDeath[EVENT_NAME_LENGTH];
+ char onMapChange[EVENT_NAME_LENGTH];
+};
+
+struct hQueueIterator {
+ int *item;
+ int items;
+ int pos;
+};
//
// Script state
@@ -129,10 +156,12 @@ struct script_state {
int instance_id;
//For backing up purposes
struct script_state *bk_st;
+ unsigned char hIterator;
int bk_npcid;
unsigned freeloop : 1;// used by buildin_freeloop
unsigned op2ref : 1;// used by op_2
unsigned npc_item_flag : 1;
+ unsigned int id;
};
struct script_reg {
@@ -162,20 +191,17 @@ int set_var(struct map_session_data *sd, char *name, void *val);
int run_script_timer(int tid, unsigned int tick, int id, intptr_t data);
void run_script_main(struct script_state *st);
-void script_stop_sleeptimers(int id);
+void script_stop_instances(int id);
struct linkdb_node* script_erase_sleepdb(struct linkdb_node *n);
void script_free_code(struct script_code* code);
void script_free_vars(struct DBMap *storage);
-struct script_state* script_alloc_state(struct script_code* script, int pos, int rid, int oid);
+struct script_state* script_alloc_state(struct script_code* rootscript, int pos, int rid, int oid);
void script_free_state(struct script_state* st);
struct DBMap* script_get_label_db(void);
struct DBMap* script_get_userfunc_db(void);
void script_run_autobonus(const char *autobonus,int id, int pos);
-bool script_get_constant(const char* name, int* value);
-void script_set_constant(const char* name, int value, bool isparameter);
-
void script_cleararray_pc(struct map_session_data* sd, const char* varname, void* value);
void script_setarray_pc(struct map_session_data* sd, const char* varname, uint8 idx, void* value, int* refcache);
@@ -187,6 +213,24 @@ int script_reload(void);
// @commands (script based)
void setd_sub(struct script_state *st, struct map_session_data *sd, const char *varname, int elem, void *value, struct DBMap **ref);
+struct script_function {
+ bool (*func)(struct script_state *st);
+ char *name;
+ char *arg;
+};
+
+// String buffer structures.
+// str_data stores string information
+struct str_data_struct {
+ enum c_op type;
+ int str;
+ int backpatch;
+ int label;
+ bool (*func)(struct script_state *st);
+ int val;
+ int next;
+};
+
///////////////////////////////////////////////////////////////////////////////
//## TODO possible enhancements: [FlavioJS]
// - 'callfunc' supporting labels in the current npc "::LabelName"
@@ -210,17 +254,17 @@ void setd_sub(struct script_state *st, struct map_session_data *sd, const char *
/// Returns the index of the last data in the stack
#define script_lastdata(st) ( (st)->end - (st)->start - 1 )
/// Pushes an int into the stack
-#define script_pushint(st,val) push_val((st)->stack, C_INT, (val))
+#define script_pushint(st,val) script->push_val((st)->stack, C_INT, (val),NULL)
/// Pushes a string into the stack (script engine frees it automatically)
-#define script_pushstr(st,val) push_str((st)->stack, C_STR, (val))
+#define script_pushstr(st,val) script->push_str((st)->stack, C_STR, (val))
/// Pushes a copy of a string into the stack
-#define script_pushstrcopy(st,val) push_str((st)->stack, C_STR, aStrdup(val))
+#define script_pushstrcopy(st,val) script->push_str((st)->stack, C_STR, aStrdup(val))
/// Pushes a constant string into the stack (must never change or be freed)
-#define script_pushconststr(st,val) push_str((st)->stack, C_CONSTSTR, (val))
+#define script_pushconststr(st,val) script->push_str((st)->stack, C_CONSTSTR, (val))
/// Pushes a nil into the stack
-#define script_pushnil(st) push_val((st)->stack, C_NOP, 0)
+#define script_pushnil(st) script->push_val((st)->stack, C_NOP, 0,NULL)
/// Pushes a copy of the data in the target index
-#define script_pushcopy(st,i) push_copy((st)->stack, (st)->start + (i))
+#define script_pushcopy(st,i) script->push_copy((st)->stack, (st)->start + (i))
#define script_isstring(st,i) data_isstring(script_getdata(st,i))
#define script_isint(st,i) data_isint(script_getdata(st,i))
@@ -235,9 +279,9 @@ void setd_sub(struct script_state *st, struct map_session_data *sd, const char *
/// Returns the script_data at the target index relative to the top of the stack
#define script_getdatatop(st,i) ( &((st)->stack->stack_data[(st)->stack->sp + (i)]) )
/// Pushes a copy of the data in the target index relative to the top of the stack
-#define script_pushcopytop(st,i) push_copy((st)->stack, (st)->stack->sp + (i))
+#define script_pushcopytop(st,i) script->push_copy((st)->stack, (st)->stack->sp + (i))
/// Removes the range of values [start,end[ relative to the top of the stack
-#define script_removetop(st,start,end) ( pop_stack((st), ((st)->stack->sp + (start)), (st)->stack->sp + (end)) )
+#define script_removetop(st,start,end) ( script->pop_stack((st), ((st)->stack->sp + (start)), (st)->stack->sp + (end)) )
//
// struct script_data* data;
@@ -255,12 +299,12 @@ void setd_sub(struct script_state *st, struct map_session_data *sd, const char *
#define data_isfunclabel(data) ( (data)->type == C_USERFUNC_POS )
/// Returns if this is a reference to a constant
-#define reference_toconstant(data) ( str_data[reference_getid(data)].type == C_INT )
+#define reference_toconstant(data) ( script->str_data[reference_getid(data)].type == C_INT )
/// Returns if this a reference to a param
-#define reference_toparam(data) ( str_data[reference_getid(data)].type == C_PARAM )
+#define reference_toparam(data) ( script->str_data[reference_getid(data)].type == C_PARAM )
/// Returns if this a reference to a variable
//##TODO confirm it's C_NAME [FlavioJS]
-#define reference_tovariable(data) ( str_data[reference_getid(data)].type == C_NAME )
+#define reference_tovariable(data) ( script->str_data[reference_getid(data)].type == C_NAME )
/// Returns the unique id of the reference (id and index)
#define reference_getuid(data) ( (data)->u.num )
/// Returns the id of the reference
@@ -268,13 +312,13 @@ void setd_sub(struct script_state *st, struct map_session_data *sd, const char *
/// Returns the array index of the reference
#define reference_getindex(data) ( (int32)(((uint32)(reference_getuid(data) & 0xff000000)) >> 24) )
/// Returns the name of the reference
-#define reference_getname(data) ( str_buf + str_data[reference_getid(data)].str )
+#define reference_getname(data) ( script->str_buf + script->str_data[reference_getid(data)].str )
/// Returns the linked list of uid-value pairs of the reference (can be NULL)
#define reference_getref(data) ( (data)->ref )
/// Returns the value of the constant
-#define reference_getconstant(data) ( str_data[reference_getid(data)].val )
+#define reference_getconstant(data) ( script->str_data[reference_getid(data)].val )
/// Returns the type of param
-#define reference_getparamtype(data) ( str_data[reference_getid(data)].val )
+#define reference_getparamtype(data) ( script->str_data[reference_getid(data)].val )
/// Composes the uid of a reference from the id and the index
#define reference_uid(id,idx) ( (int32)((((uint32)(id)) & 0x00ffffff) | (((uint32)(idx)) << 24)) )
@@ -286,16 +330,35 @@ void setd_sub(struct script_state *st, struct map_session_data *sd, const char *
#define BUILDIN(x) bool buildin_ ## x (struct script_state* st)
#define BUILDIN_A(x) buildin_ ## x
-struct script_function {
- bool (*func)(struct script_state *st);
- char *name;
- char *arg;
-};
/* script.c interface (incomplete) */
struct script_interface {
+ /* */
+ DBMap *st_db;
+ unsigned int active_scripts;
+ unsigned int next_id;
+ struct eri *st_ers;
+ struct eri *stack_ers;
+ /* */
+ struct hQueue *hq;
+ struct hQueueIterator *hqi;
+ int hqs, hqis;
+ int hqe[HQO_MAX];
/* */
char **buildin;
unsigned int buildin_count;
+ /* */
+ struct str_data_struct *str_data;
+ int str_data_size; // size of the data
+ int str_num; // next id to be assigned
+ // str_buf holds the strings themselves
+ char *str_buf;
+ int str_size; // size of the buffer
+ int str_pos; // next position to be assigned
+ /* */
+ char *word_buf;
+ int word_size;
+ /* */
+ unsigned short current_item_id;
/* */
void (*init) (void);
void (*final) (void);
@@ -304,6 +367,22 @@ struct script_interface {
bool (*addScript) (char *name, char *args, bool (*func)(struct script_state *st));
int (*conv_num) (struct script_state *st,struct script_data *data);
const char* (*conv_str) (struct script_state *st,struct script_data *data);
+ TBL_PC *(*rid2sd) (struct script_state *st);
+ void (*detach_rid) (struct script_state* st);
+ struct script_data* (*push_val)(struct script_stack* stack, enum c_op type, int val, struct DBMap** ref);
+ void (*get_val) (struct script_state* st, struct script_data* data);
+ void* (*get_val2) (struct script_state* st, int uid, struct DBMap** ref);
+ struct script_data* (*push_str) (struct script_stack* stack, enum c_op type, char* str);
+ struct script_data* (*push_copy) (struct script_stack* stack, int pos);
+ void (*pop_stack) (struct script_state* st, int start, int end);
+ void (*set_constant) (const char* name, int value, bool isparameter);
+ void (*set_constant2) (const char *name, int value, bool isparameter);
+ bool (*get_constant) (const char* name, int* value);
+ /* */
+ struct hQueue *(*queue) (int idx);
+ bool (*queue_add) (int idx, int var);
+ bool (*queue_del) (int idx);
+ bool (*queue_remove) (int idx, int var);
} script_s;
struct script_interface *script;
diff --git a/src/map/searchstore.c b/src/map/searchstore.c
index 7e1ee3e84..d346a0de6 100644
--- a/src/map/searchstore.c
+++ b/src/map/searchstore.c
@@ -135,14 +135,14 @@ void searchstore_query(struct map_session_data* sd, unsigned char type, unsigned
// validate lists
for( i = 0; i < item_count; i++ ) {
- if( !itemdb_exists(itemlist[i]) ) {
+ if( !itemdb->exists(itemlist[i]) ) {
ShowWarning("searchstore_query: Client resolved item %hu is not known.\n", itemlist[i]);
clif->search_store_info_failed(sd, SSI_FAILED_NOTHING_SEARCH_ITEM);
return;
}
}
for( i = 0; i < card_count; i++ ) {
- if( !itemdb_exists(cardlist[i]) ) {
+ if( !itemdb->exists(cardlist[i]) ) {
ShowWarning("searchstore_query: Client resolved card %hu is not known.\n", cardlist[i]);
clif->search_store_info_failed(sd, SSI_FAILED_NOTHING_SEARCH_ITEM);
return;
@@ -273,7 +273,7 @@ void searchstore_click(struct map_session_data* sd, int account_id, int store_id
return;
}
- if( ( pl_sd = map_id2sd(account_id) ) == NULL ) {// no longer online
+ if( ( pl_sd = iMap->id2sd(account_id) ) == NULL ) {// no longer online
clif->search_store_info_failed(sd, SSI_FAILED_SSILIST_CLICK_TO_OPEN_STORE);
return;
}
diff --git a/src/map/skill.c b/src/map/skill.c
index 06bfca5f8..509de6f4a 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -189,57 +189,66 @@ void skill_chk(int16* skill_id) {
}
#define skill_get(var,id) { skill->chk(&id); if(!id) return 0; return var; }
-#define skill_get2(var,id,lv) { skill->chk(&id); if(!id) return 0; if( lv > MAX_SKILL_LEVEL ) { int lv2 = lv; lv = skill_db[id].max; return (var) + (lv2-lv); } return var; }
+#define skill_get2(var,id,lv) { \
+ skill->chk(&id); \
+ if(!id) return 0; \
+ if( lv >= MAX_SKILL_LEVEL && var > 1 ) { \
+ int lv2 = lv; lv = skill_db[id].max; \
+ return (var) + (lv2-lv);\
+ } \
+ return var;\
+}
+#define skill_glv(lv) min(lv,MAX_SKILL_LEVEL-1)
// Skill DB
int skill_get_hit( uint16 skill_id ) { skill_get (skill_db[skill_id].hit, skill_id); }
int skill_get_inf( uint16 skill_id ) { skill_get (skill_db[skill_id].inf, skill_id); }
-int skill_get_ele( uint16 skill_id , uint16 skill_lv ) { skill_get2 (skill_db[skill_id].element[skill_lv-1], skill_id, skill_lv); }
+int skill_get_ele( uint16 skill_id , uint16 skill_lv ) { skill_get (skill_db[skill_id].element[skill_glv(skill_lv-1)], skill_id); }
int skill_get_nk( uint16 skill_id ) { skill_get (skill_db[skill_id].nk, skill_id); }
int skill_get_max( uint16 skill_id ) { skill_get (skill_db[skill_id].max, skill_id); }
-int skill_get_range( uint16 skill_id , uint16 skill_lv ) { skill_get2 (skill_db[skill_id].range[skill_lv-1], skill_id, skill_lv); }
-int skill_get_splash( uint16 skill_id , uint16 skill_lv ) { skill_get2 ( (skill_db[skill_id].splash[skill_lv-1]>=0?skill_db[skill_id].splash[skill_lv-1]:AREA_SIZE), skill_id, skill_lv); }
-int skill_get_hp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].hp[skill_lv-1], skill_id, skill_lv); }
-int skill_get_sp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].sp[skill_lv-1], skill_id, skill_lv); }
-int skill_get_hp_rate(uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill_db[skill_id].hp_rate[skill_lv-1], skill_id, skill_lv); }
-int skill_get_sp_rate(uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill_db[skill_id].sp_rate[skill_lv-1], skill_id, skill_lv); }
+int skill_get_range( uint16 skill_id , uint16 skill_lv ) { skill_get2 (skill_db[skill_id].range[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_splash( uint16 skill_id , uint16 skill_lv ) { skill_get2 ( (skill_db[skill_id].splash[skill_glv(skill_lv-1)]>=0?skill_db[skill_id].splash[skill_glv(skill_lv-1)]:AREA_SIZE), skill_id, skill_lv); }
+int skill_get_hp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].hp[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_sp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].sp[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_hp_rate(uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill_db[skill_id].hp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_sp_rate(uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill_db[skill_id].sp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); }
int skill_get_state(uint16 skill_id) { skill_get (skill_db[skill_id].state, skill_id); }
-int skill_get_spiritball(uint16 skill_id, uint16 skill_lv) { skill_get2 (skill_db[skill_id].spiritball[skill_lv-1], skill_id, skill_lv); }
+int skill_get_spiritball(uint16 skill_id, uint16 skill_lv) { skill_get2 (skill_db[skill_id].spiritball[skill_glv(skill_lv-1)], skill_id, skill_lv); }
int skill_get_itemid(uint16 skill_id, int idx) { skill_get (skill_db[skill_id].itemid[idx], skill_id); }
int skill_get_itemqty(uint16 skill_id, int idx) { skill_get (skill_db[skill_id].amount[idx], skill_id); }
-int skill_get_zeny( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].zeny[skill_lv-1], skill_id, skill_lv); }
-int skill_get_num( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].num[skill_lv-1], skill_id, skill_lv); }
-int skill_get_cast( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].cast[skill_lv-1], skill_id, skill_lv); }
-int skill_get_delay( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].delay[skill_lv-1], skill_id, skill_lv); }
-int skill_get_walkdelay( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].walkdelay[skill_lv-1], skill_id, skill_lv); }
-int skill_get_time( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].upkeep_time[skill_lv-1], skill_id, skill_lv); }
-int skill_get_time2( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].upkeep_time2[skill_lv-1], skill_id, skill_lv); }
+int skill_get_zeny( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].zeny[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_num( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].num[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_cast( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].cast[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_delay( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].delay[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_walkdelay( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].walkdelay[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_time( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].upkeep_time[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_time2( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].upkeep_time2[skill_glv(skill_lv-1)], skill_id, skill_lv); }
int skill_get_castdef( uint16 skill_id ) { skill_get (skill_db[skill_id].cast_def_rate, skill_id); }
int skill_get_weapontype( uint16 skill_id ) { skill_get (skill_db[skill_id].weapon, skill_id); }
int skill_get_ammotype( uint16 skill_id ) { skill_get (skill_db[skill_id].ammo, skill_id); }
-int skill_get_ammo_qty( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill_db[skill_id].ammo_qty[skill_lv-1], skill_id, skill_lv); }
+int skill_get_ammo_qty( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill_db[skill_id].ammo_qty[skill_glv(skill_lv-1)], skill_id, skill_lv); }
int skill_get_inf2( uint16 skill_id ) { skill_get (skill_db[skill_id].inf2, skill_id); }
int skill_get_castcancel( uint16 skill_id ) { skill_get (skill_db[skill_id].castcancel, skill_id); }
-int skill_get_maxcount( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].maxcount[skill_lv-1], skill_id, skill_lv); }
-int skill_get_blewcount( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].blewcount[skill_lv-1], skill_id, skill_lv); }
-int skill_get_mhp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].mhp[skill_lv-1], skill_id, skill_lv); }
-int skill_get_castnodex( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].castnodex[skill_lv-1], skill_id, skill_lv); }
-int skill_get_delaynodex( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill_db[skill_id].delaynodex[skill_lv-1], skill_id, skill_lv); }
+int skill_get_maxcount( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].maxcount[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_blewcount( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].blewcount[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_mhp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].mhp[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_castnodex( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].castnodex[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_delaynodex( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill_db[skill_id].delaynodex[skill_glv(skill_lv-1)], skill_id, skill_lv); }
int skill_get_type( uint16 skill_id ) { skill_get (skill_db[skill_id].skill_type, skill_id); }
int skill_get_unit_id ( uint16 skill_id, int flag ){ skill_get (skill_db[skill_id].unit_id[flag], skill_id); }
int skill_get_unit_interval( uint16 skill_id ) { skill_get (skill_db[skill_id].unit_interval, skill_id); }
-int skill_get_unit_range( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill_db[skill_id].unit_range[skill_lv-1], skill_id, skill_lv); }
+int skill_get_unit_range( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill_db[skill_id].unit_range[skill_glv(skill_lv-1)], skill_id, skill_lv); }
int skill_get_unit_target( uint16 skill_id ) { skill_get (skill_db[skill_id].unit_target&BCT_ALL, skill_id); }
int skill_get_unit_bl_target( uint16 skill_id ) { skill_get (skill_db[skill_id].unit_target&BL_ALL, skill_id); }
int skill_get_unit_flag( uint16 skill_id ) { skill_get (skill_db[skill_id].unit_flag, skill_id); }
-int skill_get_unit_layout_type( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill_db[skill_id].unit_layout_type[skill_lv-1], skill_id, skill_lv); }
-int skill_get_cooldown( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill_db[skill_id].cooldown[skill_lv-1], skill_id, skill_lv); }
+int skill_get_unit_layout_type( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill_db[skill_id].unit_layout_type[skill_glv(skill_lv-1)], skill_id, skill_lv); }
+int skill_get_cooldown( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill_db[skill_id].cooldown[skill_glv(skill_lv-1)], skill_id, skill_lv); }
#ifdef RENEWAL_CAST
-int skill_get_fixed_cast( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill_db[skill_id].fixed_cast[skill_lv-1], skill_id, skill_lv); }
+int skill_get_fixed_cast( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill_db[skill_id].fixed_cast[skill_glv(skill_lv-1)], skill_id, skill_lv); }
#endif
int skill_tree_get_max(uint16 skill_id, int b_class)
{
int i;
- b_class = pc_class2idx(b_class);
+ b_class = pc->class2idx(b_class);
ARR_FIND( 0, MAX_SKILL_TREE, i, skill_tree[b_class][i].id == 0 || skill_tree[b_class][i].id == skill_id );
if( i < MAX_SKILL_TREE && skill_tree[b_class][i].id == skill_id )
@@ -313,7 +322,7 @@ int skill_get_range2 (struct block_list *bl, uint16 skill_id, uint16 skill_lv) {
case RA_AIMEDBOLT:
case RA_WUGBITE:
if( bl->type == BL_PC )
- range += pc_checkskill((TBL_PC*)bl, AC_VULTURE);
+ range += pc->checkskill((TBL_PC*)bl, AC_VULTURE);
else
range += 10; //Assume level 10?
break;
@@ -324,20 +333,19 @@ int skill_get_range2 (struct block_list *bl, uint16 skill_id, uint16 skill_lv) {
case GS_SPREADATTACK:
case GS_GROUNDDRIFT:
if (bl->type == BL_PC)
- range += pc_checkskill((TBL_PC*)bl, GS_SNAKEEYE);
+ range += pc->checkskill((TBL_PC*)bl, GS_SNAKEEYE);
else
range += 10; //Assume level 10?
break;
case NJ_KIRIKAGE:
if (bl->type == BL_PC)
- range = skill->get_range(NJ_SHADOWJUMP,pc_checkskill((TBL_PC*)bl,NJ_SHADOWJUMP));
+ range = skill->get_range(NJ_SHADOWJUMP,pc->checkskill((TBL_PC*)bl,NJ_SHADOWJUMP));
break;
/**
* Warlock
**/
case WL_WHITEIMPRISON:
case WL_SOULEXPANSION:
- case WL_FROSTMISTY:
case WL_MARSHOFABYSS:
case WL_SIENNAEXECRATE:
case WL_DRAINLIFE:
@@ -346,9 +354,10 @@ int skill_get_range2 (struct block_list *bl, uint16 skill_id, uint16 skill_lv) {
case WL_COMET:
case WL_CHAINLIGHTNING:
case WL_TETRAVORTEX:
+ case WL_EARTHSTRAIN:
case WL_RELEASE:
if( bl->type == BL_PC )
- range += pc_checkskill((TBL_PC*)bl, WL_RADIUS);
+ range += pc->checkskill((TBL_PC*)bl, WL_RADIUS);
break;
/**
* Ranger Bonus
@@ -361,7 +370,7 @@ int skill_get_range2 (struct block_list *bl, uint16 skill_id, uint16 skill_lv) {
case RA_FIRINGTRAP:
case RA_ICEBOUNDTRAP:
if( bl->type == BL_PC )
- range += (1 + pc_checkskill((TBL_PC*)bl, RA_RESEARCHTRAP))/2;
+ range += (1 + pc->checkskill((TBL_PC*)bl, RA_RESEARCHTRAP))/2;
}
if( !range && bl->type != BL_PC )
@@ -376,14 +385,14 @@ int skill_calc_heal(struct block_list *src, struct block_list *target, uint16 sk
struct status_change* sc;
switch( skill_id ) {
- case BA_APPLEIDUN:
+ case BA_APPLEIDUN:
#ifdef RENEWAL
- hp = 100+5*skill_lv+5*(status_get_vit(src)/10); // HP recovery
+ hp = 100+5*skill_lv+5*(status_get_vit(src)/10); // HP recovery
#else
- hp = 30+5*skill_lv+5*(status_get_vit(src)/10); // HP recovery
+ hp = 30+5*skill_lv+5*(status_get_vit(src)/10); // HP recovery
#endif
- if( sd )
- hp += 5*pc_checkskill(sd,BA_MUSICALLESSON);
+ if( sd )
+ hp += 5*pc->checkskill(sd,BA_MUSICALLESSON);
break;
case PR_SANCTUARY:
hp = (skill_lv>6)?777:skill_lv*100;
@@ -397,13 +406,13 @@ int skill_calc_heal(struct block_list *src, struct block_list *target, uint16 sk
#ifdef RENEWAL
/**
* Renewal Heal Formula
- * Formula: ( [(Base Level + INT) / 5] × 30 ) × (Heal Level / 10) × (Modifiers) + MATK
+ * Formula: ( [(Base Level + INT) / 5] ? 30 ) ? (Heal Level / 10) ? (Modifiers) + MATK
**/
hp = (status_get_lv(src) + status_get_int(src)) / 5 * 30 * skill_lv / 10;
#else
- hp = ( status_get_lv(src) + status_get_int(src) ) / 8 * (4 + ( skill_id == AB_HIGHNESSHEAL ? ( sd ? pc_checkskill(sd,AL_HEAL) : 10 ) : skill_lv ) * 8);
+ hp = ( status_get_lv(src) + status_get_int(src) ) / 8 * (4 + ( skill_id == AB_HIGHNESSHEAL ? ( sd ? pc->checkskill(sd,AL_HEAL) : 10 ) : skill_lv ) * 8);
#endif
- if( sd && ((skill = pc_checkskill(sd, HP_MEDITATIO)) > 0) )
+ if( sd && ((skill = pc->checkskill(sd, HP_MEDITATIO)) > 0) )
hp += hp * skill * 2 / 100;
else if( src->type == BL_HOM && (skill = homun->checkskill(((TBL_HOM*)src), HLIF_BRAIN)) > 0 )
hp += hp * skill * 2 / 100;
@@ -413,10 +422,10 @@ int skill_calc_heal(struct block_list *src, struct block_list *target, uint16 sk
if( ( (target && target->type == BL_MER) || !heal ) && skill_id != NPC_EVILLAND )
hp >>= 1;
- if( sd && (skill = pc_skillheal_bonus(sd, skill_id)) )
+ if( sd && (skill = pc->skillheal_bonus(sd, skill_id)) )
hp += hp*skill/100;
- if( tsd && (skill = pc_skillheal2_bonus(tsd, skill_id)) )
+ if( tsd && (skill = pc->skillheal2_bonus(tsd, skill_id)) )
hp += hp*skill/100;
sc = status_get_sc(target);
@@ -425,10 +434,12 @@ int skill_calc_heal(struct block_list *src, struct block_list *target, uint16 sk
hp -= hp * sc->data[SC_CRITICALWOUND]->val2/100;
if( sc->data[SC_DEATHHURT] && heal )
hp -= hp * 20/100;
- if( sc->data[SC_INCHEALRATE] && skill_id != NPC_EVILLAND && skill_id != BA_APPLEIDUN )
- hp += hp * sc->data[SC_INCHEALRATE]->val1/100; // Only affects Heal, Sanctuary and PotionPitcher.(like bHealPower) [Inkfish]
+ if( sc->data[SC_HEALPLUS] && skill_id != NPC_EVILLAND && skill_id != BA_APPLEIDUN )
+ hp += hp * sc->data[SC_HEALPLUS]->val1/100; // Only affects Heal, Sanctuary and PotionPitcher.(like bHealPower) [Inkfish]
if( sc->data[SC_WATER_INSIGNIA] && sc->data[SC_WATER_INSIGNIA]->val1 == 2)
hp += hp / 10;
+ if( sc->data[SC_OFFERTORIUM] && (skill_id == AB_HIGHNESSHEAL || skill_id == AB_CHEAL || skill_id == PR_SANCTUARY || skill_id == AL_HEAL) )
+ hp += hp * sc->data[SC_OFFERTORIUM]->val2 / 100;
}
#ifdef RENEWAL
@@ -438,32 +449,7 @@ int skill_calc_heal(struct block_list *src, struct block_list *target, uint16 sk
case BA_APPLEIDUN: case PR_SANCTUARY:
case NPC_EVILLAND: break;
default:
- {
- struct status_data *status = status_get_status_data(src);
- int min, max;
-
- min = max = status_base_matk(status, status_get_lv(src));
- if( status->rhw.matk > 0 ){
- int wMatk, variance;
- wMatk = status->rhw.matk;
- variance = wMatk * status->rhw.wlv / 10;
- min += wMatk - variance;
- max += wMatk + variance;
- }
-
- if( sc && sc->data[SC_RECOGNIZEDSPELL] )
- min = max;
-
- if( sd && sd->right_weapon.overrefine > 0 ){
- min++;
- max += sd->right_weapon.overrefine - 1;
- }
-
- if(max > min)
- hp += min+rnd()%(max-min);
- else
- hp += min;
- }
+ hp += status_get_matk(src, 3);
}
#endif
return hp;
@@ -523,7 +509,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd)
// allowing a skill to be cast. This is to prevent no-delay ACT files from spamming skills such as
// AC_DOUBLE which do not have a skill delay and are not regarded in terms of attack motion.
if( !sd->state.autocast && sd->skillitem != skill_id && sd->canskill_tick &&
- DIFF_TICK(gettick(), sd->canskill_tick) < (sd->battle_status.amotion * (battle_config.skill_amotion_leniency) / 100) )
+ DIFF_TICK(iTimer->gettick(), sd->canskill_tick) < (sd->battle_status.amotion * (battle_config.skill_amotion_leniency) / 100) )
{// attempted to cast a skill before the attack motion has finished
return 1;
}
@@ -548,7 +534,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd)
case RETURN_TO_ELDICASTES:
case ALL_GUARDIAN_RECALL:
if(map[m].flag.nowarp) {
- clif->skill_teleportmessage(sd,0);
+ clif->skill_mapinfomessage(sd,0);
return 1;
}
return 0;
@@ -556,7 +542,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd)
case SC_FATALMENACE:
case SC_DIMENSIONDOOR:
if(map[m].flag.noteleport) {
- clif->skill_teleportmessage(sd,0);
+ clif->skill_mapinfomessage(sd,0);
return 1;
}
return 0; // gonna be checked in 'skill->castend_nodamage_id'
@@ -564,7 +550,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd)
case WE_CALLPARENT:
case WE_CALLBABY:
if (map[m].flag.nomemo) {
- clif->skill_teleportmessage(sd,1);
+ clif->skill_mapinfomessage(sd,1);
return 1;
}
break;
@@ -595,7 +581,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd)
break;
case GD_EMERGENCYCALL:
if (
- !(battle_config.emergency_call&((agit_flag || agit2_flag)?2:1)) ||
+ !(battle_config.emergency_call&((iMap->agit_flag || iMap->agit2_flag)?2:1)) ||
!(battle_config.emergency_call&(map[m].flag.gvg || map[m].flag.gvg_castle?8:4)) ||
(battle_config.emergency_call&16 && map[m].flag.nowarpto && !map[m].flag.gvg_castle)
) {
@@ -616,7 +602,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd)
* These skills cannot be used while in mado gear (credits to Xantara)
**/
if( pc_ismadogear(sd) ) {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_MADOGEAR_RIDE,0);
return 1;
}
break;
@@ -627,7 +613,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd)
case WM_LULLABY_DEEPSLEEP:
case WM_SATURDAY_NIGHT_FEVER:
if( !map_flag_vs(m) ) {
- clif->skill_teleportmessage(sd,2); // This skill uses this msg instead of skill fails.
+ clif->skill_mapinfomessage(sd,2); // This skill uses this msg instead of skill fails.
return 1;
}
break;
@@ -692,7 +678,7 @@ struct s_skill_unit_layout* skill_get_unit_layout (uint16 skill_id, uint16 skill
if (pos != -1) // simple single-definition layout
return &skill_unit_layout[pos];
- dir = (src->x == x && src->y == y) ? 6 : map_calc_dir(src,x,y); // 6 - default aegis direction
+ dir = (src->x == x && src->y == y) ? 6 : iMap->calc_dir(src,x,y); // 6 - default aegis direction
if (skill_id == MG_FIREWALL)
return &skill_unit_layout [firewall_unit_pos + dir];
@@ -805,44 +791,44 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
break; // If a normal attack is a skill, it's splash damage. [Inkfish]
if(sd) {
// Automatic trigger of Blitz Beat
- if (pc_isfalcon(sd) && sd->status.weapon == W_BOW && (temp=pc_checkskill(sd,HT_BLITZBEAT))>0 &&
- rnd()%1000 <= sstatus->luk*10/3+1 ) {
- rate=(sd->status.job_level+9)/10;
+ if (pc_isfalcon(sd) && sd->status.weapon == W_BOW && (temp=pc->checkskill(sd,HT_BLITZBEAT))>0 &&
+ rnd()%1000 <= sstatus->luk*3 ) {
+ rate = sd->status.job_level / 10 + 1;
skill->castend_damage_id(src,bl,HT_BLITZBEAT,(temp<rate)?temp:rate,tick,SD_LEVEL);
}
// Automatic trigger of Warg Strike [Jobbie]
- if( pc_iswug(sd) && (sd->status.weapon == W_BOW || sd->status.weapon == W_FIST) && (temp=pc_checkskill(sd,RA_WUGSTRIKE)) > 0 && rnd()%1000 <= sstatus->luk*10/3+1 )
+ if( pc_iswug(sd) && (temp=pc->checkskill(sd,RA_WUGSTRIKE)) > 0 && rnd()%1000 <= sstatus->luk*3 )
skill->castend_damage_id(src,bl,RA_WUGSTRIKE,temp,tick,0);
// Gank
if(dstmd && sd->status.weapon != W_BOW &&
- (temp=pc_checkskill(sd,RG_SNATCHER)) > 0 &&
- (temp*15 + 55) + pc_checkskill(sd,TF_STEAL)*10 > rnd()%1000) {
- if(pc_steal_item(sd,bl,pc_checkskill(sd,TF_STEAL)))
+ (temp=pc->checkskill(sd,RG_SNATCHER)) > 0 &&
+ (temp*15 + 55) + pc->checkskill(sd,TF_STEAL)*10 > rnd()%1000) {
+ if(pc->steal_item(sd,bl,pc->checkskill(sd,TF_STEAL)))
clif->skill_nodamage(src,bl,TF_STEAL,temp,1);
else
clif->skill_fail(sd,RG_SNATCHER,USESKILL_FAIL_LEVEL,0);
}
// Chance to trigger Taekwon kicks [Dralnu]
- if(sc && !sc->data[SC_COMBO]) {
- if(sc->data[SC_READYSTORM] &&
- sc_start(src,SC_COMBO, 15, TK_STORMKICK,
+ if(sc && !sc->data[SC_COMBOATTACK]) {
+ if(sc->data[SC_STORMKICK_READY] &&
+ sc_start(src,SC_COMBOATTACK, 15, TK_STORMKICK,
(2000 - 4*sstatus->agi - 2*sstatus->dex)))
; //Stance triggered
- else if(sc->data[SC_READYDOWN] &&
- sc_start(src,SC_COMBO, 15, TK_DOWNKICK,
+ else if(sc->data[SC_DOWNKICK_READY] &&
+ sc_start(src,SC_COMBOATTACK, 15, TK_DOWNKICK,
(2000 - 4*sstatus->agi - 2*sstatus->dex)))
; //Stance triggered
- else if(sc->data[SC_READYTURN] &&
- sc_start(src,SC_COMBO, 15, TK_TURNKICK,
+ else if(sc->data[SC_TURNKICK_READY] &&
+ sc_start(src,SC_COMBOATTACK, 15, TK_TURNKICK,
(2000 - 4*sstatus->agi - 2*sstatus->dex)))
; //Stance triggered
- else if (sc->data[SC_READYCOUNTER]) { //additional chance from SG_FRIEND [Komurka]
+ else if (sc->data[SC_COUNTERKICK_READY]) { //additional chance from SG_FRIEND [Komurka]
rate = 20;
if (sc->data[SC_SKILLRATE_UP] && sc->data[SC_SKILLRATE_UP]->val1 == TK_COUNTER) {
rate += rate*sc->data[SC_SKILLRATE_UP]->val2/100;
status_change_end(src, SC_SKILLRATE_UP, INVALID_TIMER);
}
- sc_start2(src, SC_COMBO, rate, TK_COUNTER, bl->id,
+ sc_start2(src, SC_COMBOATTACK, rate, TK_COUNTER, bl->id,
(2000 - 4*sstatus->agi - 2*sstatus->dex));
}
}
@@ -853,7 +839,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
if (sc) {
struct status_change_entry *sce;
// Enchant Poison gives a chance to poison attacked enemies
- if((sce=sc->data[SC_ENCPOISON])) //Don't use sc_start since chance comes in 1/10000 rate.
+ if((sce=sc->data[SC_ENCHANTPOISON])) //Don't use sc_start since chance comes in 1/10000 rate.
status_change_start(bl,SC_POISON,sce->val2, sce->val1,src->id,0,0,
skill->get_time2(AS_ENCHANTPOISON,sce->val1),0);
// Enchant Deadly Poison gives a chance to deadly poison attacked enemies
@@ -862,10 +848,10 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
skill->get_time2(ASC_EDP,sce->val1));
}
}
- break;
+ break;
case SM_BASH:
- if( sd && skill_lv > 5 && pc_checkskill(sd,SM_FATALBLOW)>0 ){
+ if( sd && skill_lv > 5 && pc->checkskill(sd,SM_FATALBLOW)>0 ){
//TODO: How much % per base level it actually is?
sc_start(bl,SC_STUN,(5*(skill_lv-5)+(int)sd->status.base_level/10),
skill_lv,skill->get_time2(SM_FATALBLOW,skill_lv));
@@ -878,7 +864,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
case AS_VENOMKNIFE:
if (sd) //Poison chance must be that of Envenom. [Skotlex]
- skill_lv = pc_checkskill(sd, TF_POISON);
+ skill_lv = pc->checkskill(sd, TF_POISON);
case TF_POISON:
case AS_SPLASHER:
if(!sc_start2(bl,SC_POISON,(4*skill_lv+10),skill_lv,src->id,skill->get_time2(skill_id,skill_lv))
@@ -981,7 +967,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
break;
case AM_ACIDTERROR:
- sc_start2(bl,SC_BLEEDING,(skill_lv*3),skill_lv,src->id,skill->get_time2(skill_id,skill_lv));
+ sc_start2(bl,SC_BLOODING,(skill_lv*3),skill_lv,src->id,skill->get_time2(skill_id,skill_lv));
if (skill->break_equip(bl, EQP_ARMOR, 100*skill->get_time(skill_id,skill_lv), BCT_ENEMY))
clif->emotion(bl,E_OMG);
break;
@@ -1025,7 +1011,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
case DC_UGLYDANCE:
rate = 5+5*skill_lv;
- if(sd && (temp=pc_checkskill(sd,DC_DANCINGLESSON)))
+ if(sd && (temp=pc->checkskill(sd,DC_DANCINGLESSON)))
rate += 5+temp;
status_zap(bl, 0, rate);
break;
@@ -1053,14 +1039,12 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
sc_start(bl,status_skill2sc(skill_id),70,skill_lv,skill->get_time2(skill_id,skill_lv));
break;
case NPC_BLEEDING:
- sc_start2(bl,SC_BLEEDING,(20*skill_lv),skill_lv,src->id,skill->get_time2(skill_id,skill_lv));
+ sc_start2(bl,SC_BLOODING,(20*skill_lv),skill_lv,src->id,skill->get_time2(skill_id,skill_lv));
break;
case NPC_MENTALBREAKER:
{ //Based on observations by Tharis, Mental Breaker should do SP damage
- //equal to Matk*skLevel.
- rate = sstatus->matk_min;
- if (rate < sstatus->matk_max)
- rate += rnd()%(sstatus->matk_max - sstatus->matk_min);
+ //equal to Matk*skLevel.
+ rate = status_get_matk(src, 2);
rate*=skill_lv;
status_zap(bl, 0, rate);
break;
@@ -1099,7 +1083,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
case LK_HEADCRUSH: //Headcrush has chance of causing Bleeding status, except on demon and undead element
if (!(battle->check_undead(tstatus->race, tstatus->def_ele) || tstatus->race == RC_DEMON))
- sc_start2(bl, SC_BLEEDING,50, skill_lv, src->id, skill->get_time2(skill_id,skill_lv));
+ sc_start2(bl, SC_BLOODING,50, skill_lv, src->id, skill->get_time2(skill_id,skill_lv));
break;
case LK_JOINTBEAT:
@@ -1119,8 +1103,8 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
sc_start(bl,SC_STUN,(5+skill_lv*5),skill_lv,skill->get_time2(skill_id,2));
break;
default:
- sc_start2(bl,SC_BLEEDING,(5+skill_lv*5),skill_lv,src->id,skill->get_time2(skill_id,3));
- }
+ sc_start2(bl,SC_BLOODING,(5+skill_lv*5),skill_lv,src->id,skill->get_time2(skill_id,3));
+ }
break;
case HW_NAPALMVULCAN:
@@ -1142,12 +1126,12 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
case TK_JUMPKICK:
if( dstsd && dstsd->class_ != MAPID_SOUL_LINKER && !tsc->data[SC_PRESERVE] )
{// debuff the following statuses
- status_change_end(bl, SC_SPIRIT, INVALID_TIMER);
+ status_change_end(bl, SC_SOULLINK, INVALID_TIMER);
status_change_end(bl, SC_ADRENALINE2, INVALID_TIMER);
status_change_end(bl, SC_KAITE, INVALID_TIMER);
status_change_end(bl, SC_KAAHI, INVALID_TIMER);
- status_change_end(bl, SC_ONEHAND, INVALID_TIMER);
- status_change_end(bl, SC_ASPDPOTION2, INVALID_TIMER);
+ status_change_end(bl, SC_ONEHANDQUICKEN, INVALID_TIMER);
+ status_change_end(bl, SC_ATTHASTE_POTION3, INVALID_TIMER);
}
break;
case TK_TURNKICK:
@@ -1160,7 +1144,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
status_change_start(bl,SC_COMA,10,skill_lv,0,src->id,0,0,0);
break;
case GS_PIERCINGSHOT:
- sc_start2(bl,SC_BLEEDING,(skill_lv*3),skill_lv,src->id,skill->get_time2(skill_id,skill_lv));
+ sc_start2(bl,SC_BLOODING,(skill_lv*3),skill_lv,src->id,skill->get_time2(skill_id,skill_lv));
break;
case NJ_HYOUSYOURAKU:
sc_start(bl,SC_FREEZE,(10+10*skill_lv),skill_lv,skill->get_time2(skill_id,skill_lv));
@@ -1185,7 +1169,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
sc_start(bl,SC_CRITICALWOUND,100,skill_lv,skill->get_time2(skill_id,skill_lv));
break;
case RK_HUNDREDSPEAR:
- if( !sd || pc_checkskill(sd,KN_SPEARBOOMERANG) == 0 )
+ if( !sd || pc->checkskill(sd,KN_SPEARBOOMERANG) == 0 )
break; // Spear Boomerang auto cast chance only works if you have mastered Spear Boomerang.
rate = 10 + 3 * skill_lv;
if( rnd()%100 < rate )
@@ -1195,42 +1179,45 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
sc_start(bl,SC_FEAR,3+2*skill_lv,skill_lv,skill->get_time(skill_id,skill_lv));
break;
case RK_DRAGONBREATH:
- sc_start4(bl,SC_BURNING,5+5*skill_lv,skill_lv,1000,src->id,0,skill->get_time(skill_id,skill_lv));
+ sc_start4(bl,SC_BURNING,5+5*skill_lv,skill_lv,0,src->id,0,skill->get_time(skill_id,skill_lv));
+ break;
+ case RK_DRAGONBREATH_WATER:
+ sc_start4(bl,SC_FROSTMISTY,5+5*skill_lv,skill_lv,0,src->id,0,skill->get_time(skill_id,skill_lv));
break;
case AB_ADORAMUS:
- if( tsc && !tsc->data[SC_DECREASEAGI] ) //Prevent duplicate agi-down effect.
+ if( tsc && !tsc->data[SC_DEC_AGI] ) //Prevent duplicate agi-down effect.
sc_start(bl, SC_ADORAMUS, 100, skill_lv, skill->get_time(skill_id, skill_lv));
break;
case WL_CRIMSONROCK:
sc_start(bl, SC_STUN, 40, skill_lv, skill->get_time(skill_id, skill_lv));
break;
case WL_COMET:
- sc_start4(bl,SC_BURNING,100,skill_lv,1000,src->id,0,skill->get_time(skill_id,skill_lv));
+ sc_start4(bl,SC_BURNING,100,skill_lv,0,src->id,0,skill->get_time2(skill_id,skill_lv));
break;
case WL_EARTHSTRAIN:
{
- int rate = 0, i;
- const int pos[5] = { EQP_WEAPON, EQP_HELM, EQP_SHIELD, EQP_ARMOR, EQP_ACC };
- rate = 6 * skill_lv + sstatus->dex / 10 + (sd? sd->status.job_level / 4 : 0) - tstatus->dex /5;// The tstatus->dex / 5 part is unofficial, but players gotta have some kind of way to have resistance. [Rytech]
- //rate -= rate * tstatus->dex / 200; // Disabled until official resistance is found.
-
- for( i = 0; i < skill_lv; i++ )
- skill->strip_equip(bl,pos[i],rate,skill_lv,skill->get_time2(skill_id,skill_lv));
+ // lv 1 & 2 = Strip Helm, lv 3 = Strip Armor, lv 4 = Strip Weapon and lv 5 = Strip Accessory. [malufett]
+ const int pos[5] = { EQP_HELM, EQP_HELM, EQP_ARMOR, EQP_WEAPON, EQP_ACC };
+ skill->strip_equip(bl, pos[skill_lv], 6 * skill_lv + status_get_lv(src) / 4 + status_get_dex(src) / 10,
+ skill_lv, skill->get_time2(skill_id,skill_lv));
}
break;
case WL_JACKFROST:
sc_start(bl,SC_FREEZE,100,skill_lv,skill->get_time(skill_id,skill_lv));
break;
+ case WL_FROSTMISTY:
+ sc_start(bl,SC_FROSTMISTY,25 + 5 * skill_lv,skill_lv,skill->get_time(skill_id,skill_lv));
+ break;
case RA_WUGBITE:
- sc_start(bl, SC_BITE, (sd ? pc_checkskill(sd,RA_TOOTHOFWUG)*2 : 0), skill_lv, (skill->get_time(skill_id,skill_lv) + (sd ? pc_checkskill(sd,RA_TOOTHOFWUG)*500 : 0)) );
+ sc_start(bl, SC_WUGBITE, (sd ? pc->checkskill(sd,RA_TOOTHOFWUG)*2 : 0), skill_lv, (skill->get_time(skill_id,skill_lv) + (sd ? pc->checkskill(sd,RA_TOOTHOFWUG)*500 : 0)) );
break;
case RA_SENSITIVEKEEN:
if( rnd()%100 < 8 * skill_lv )
- skill->castend_damage_id(src, bl, RA_WUGBITE, sd ? pc_checkskill(sd, RA_WUGBITE):skill_lv, tick, SD_ANIMATION);
+ skill->castend_damage_id(src, bl, RA_WUGBITE, sd ? pc->checkskill(sd, RA_WUGBITE):skill_lv, tick, SD_ANIMATION);
break;
case RA_FIRINGTRAP:
case RA_ICEBOUNDTRAP:
- sc_start(bl, (skill_id == RA_FIRINGTRAP) ? SC_BURNING:SC_FREEZING, 40 + 10 * skill_lv, skill_lv, skill->get_time2(skill_id, skill_lv));
+ sc_start4(bl, (skill_id == RA_FIRINGTRAP) ? SC_BURNING:SC_FROSTMISTY, 40 + 10 * skill_lv, skill_lv, 0, src->id, 0, skill->get_time2(skill_id, skill_lv));
break;
case NC_PILEBUNKER:
if( rnd()%100 < 5 + 15*skill_lv )
@@ -1243,32 +1230,39 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
}
break;
case NC_FLAMELAUNCHER:
- sc_start4(bl, SC_BURNING, 50 + 10 * skill_lv, skill_lv, 1000, src->id, 0, skill->get_time2(skill_id, skill_lv));
+ sc_start4(bl, SC_BURNING, 50 + 10 * skill_lv, skill_lv, 0, src->id, 0, skill->get_time2(skill_id, skill_lv));
break;
case NC_COLDSLOWER:
sc_start(bl, SC_FREEZE, 10 * skill_lv, skill_lv, skill->get_time(skill_id, skill_lv));
- sc_start(bl, SC_FREEZING, 20 + 10 * skill_lv, skill_lv, skill->get_time(skill_id, skill_lv));
+ sc_start(bl, SC_FROSTMISTY, 20 + 10 * skill_lv, skill_lv, skill->get_time(skill_id, skill_lv));
break;
case NC_POWERSWING:
sc_start(bl, SC_STUN, 5*skill_lv, skill_lv, skill->get_time(skill_id, skill_lv));
if( rnd()%100 < 5*skill_lv )
- skill->castend_damage_id(src, bl, NC_AXEBOOMERANG, pc_checkskill(sd, NC_AXEBOOMERANG), tick, 1);
+ skill->castend_damage_id(src, bl, NC_AXEBOOMERANG, pc->checkskill(sd, NC_AXEBOOMERANG), tick, 1);
+ break;
+ case NC_MAGMA_ERUPTION:
+ sc_start4(bl, SC_BURNING, 10 * skill_lv, skill_lv, 0, src->id, 0, skill->get_time2(skill_id, skill_lv));
+ sc_start(bl, SC_STUN, 10 * skill_lv, skill_lv, skill->get_time(skill_id, skill_lv));
break;
case GC_WEAPONCRUSH:
skill->castend_nodamage_id(src,bl,skill_id,skill_lv,tick,BCT_ENEMY);
break;
+ case GC_DARKCROW:
+ sc_start(bl, SC_DARKCROW, 10 * skill_lv, skill_lv, skill->get_time(skill_id, skill_lv));
+ break;
case LG_SHIELDPRESS:
sc_start(bl, SC_STUN, 30 + 8 * skill_lv, skill_lv, skill->get_time(skill_id,skill_lv));
break;
case LG_PINPOINTATTACK:
- rate = 30 + (((5 * (sd?pc_checkskill(sd,LG_PINPOINTATTACK):skill_lv)) + (sstatus->agi + status_get_lv(src))) / 10);
+ rate = 30 + (((5 * (sd?pc->checkskill(sd,LG_PINPOINTATTACK):skill_lv)) + (sstatus->agi + status_get_lv(src))) / 10);
switch( skill_lv ) {
case 1:
- sc_start2(bl,SC_BLEEDING,rate,skill_lv,src->id,skill->get_time(skill_id,skill_lv));
+ sc_start2(bl,SC_BLOODING,rate,skill_lv,src->id,skill->get_time(skill_id,skill_lv));
break;
case 2:
if( dstsd && dstsd->spiritball && rnd()%100 < rate )
- pc_delspiritball(dstsd, dstsd->spiritball, 0);
+ pc->delspiritball(dstsd, dstsd->spiritball, 0);
break;
default:
skill->break_equip(bl,(skill_lv == 3) ? EQP_SHIELD : (skill_lv == 4) ? EQP_ARMOR : EQP_WEAPON,rate * 100,BCT_ENEMY);
@@ -1326,25 +1320,25 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
status_change_end(bl, SC_APPLEIDUN, INVALID_TIMER);
status_change_end(bl, SC_HUMMING, INVALID_TIMER);
status_change_end(bl, SC_FORTUNE, INVALID_TIMER);
- status_change_end(bl, SC_SERVICE4U, INVALID_TIMER);
+ status_change_end(bl, SC_SERVICEFORYOU, INVALID_TIMER);
status_change_end(bl, SC_LONGING, INVALID_TIMER);
- status_change_end(bl, SC_SWINGDANCE, INVALID_TIMER);
- status_change_end(bl, SC_SYMPHONYOFLOVER, INVALID_TIMER);
- status_change_end(bl, SC_MOONLITSERENADE, INVALID_TIMER);
- status_change_end(bl, SC_RUSHWINDMILL, INVALID_TIMER);
+ status_change_end(bl, SC_SWING, INVALID_TIMER);
+ status_change_end(bl, SC_SYMPHONY_LOVE, INVALID_TIMER);
+ status_change_end(bl, SC_MOONLIT_SERENADE, INVALID_TIMER);
+ status_change_end(bl, SC_RUSH_WINDMILL, INVALID_TIMER);
status_change_end(bl, SC_ECHOSONG, INVALID_TIMER);
status_change_end(bl, SC_HARMONIZE, INVALID_TIMER);
- status_change_end(bl, SC_WINKCHARM, INVALID_TIMER);
- status_change_end(bl, SC_SONGOFMANA, INVALID_TIMER);
- status_change_end(bl, SC_DANCEWITHWUG, INVALID_TIMER);
- status_change_end(bl, SC_LERADSDEW, INVALID_TIMER);
+ status_change_end(bl, SC_DC_WINKCHARM, INVALID_TIMER);
+ status_change_end(bl, SC_SONG_OF_MANA, INVALID_TIMER);
+ status_change_end(bl, SC_DANCE_WITH_WUG, INVALID_TIMER);
+ status_change_end(bl, SC_LERADS_DEW, INVALID_TIMER);
status_change_end(bl, SC_MELODYOFSINK, INVALID_TIMER);
- status_change_end(bl, SC_BEYONDOFWARCRY, INVALID_TIMER);
- status_change_end(bl, SC_UNLIMITEDHUMMINGVOICE, INVALID_TIMER);
+ status_change_end(bl, SC_BEYOND_OF_WARCRY, INVALID_TIMER);
+ status_change_end(bl, SC_UNLIMITED_HUMMING_VOICE, INVALID_TIMER);
}
break;
case SO_EARTHGRAVE:
- sc_start2(bl, SC_BLEEDING, 5 * skill_lv, skill_lv, src->id, skill->get_time2(skill_id, skill_lv)); // Need official rate. [LimitLine]
+ sc_start2(bl, SC_BLOODING, 5 * skill_lv, skill_lv, src->id, skill->get_time2(skill_id, skill_lv)); // Need official rate. [LimitLine]
break;
case SO_DIAMONDDUST:
rate = 5 + 5 * skill_lv;
@@ -1360,14 +1354,14 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
switch( sd->itemid ) { // Starting SCs here instead of do it in skill->additional_effect to simplify the code.
case 13261:
sc_start(bl, SC_STUN, 100, skill_lv, skill->get_time2(GN_SLINGITEM, skill_lv));
- sc_start2(bl, SC_BLEEDING, 100, skill_lv, src->id, skill->get_time2(GN_SLINGITEM, skill_lv));
+ sc_start2(bl, SC_BLOODING, 100, skill_lv, src->id, skill->get_time2(GN_SLINGITEM, skill_lv));
break;
case 13262:
sc_start(bl, SC_MELON_BOMB, 100, skill_lv, skill->get_time(GN_SLINGITEM, skill_lv)); // Reduces ASPD and moviment speed
break;
case 13264:
sc_start(bl, SC_BANANA_BOMB, 100, skill_lv, skill->get_time(GN_SLINGITEM, skill_lv)); // Reduces LUK ??Needed confirm it, may be it's bugged in kRORE?
- sc_start(bl, SC_BANANA_BOMB_SITDOWN, 75, skill_lv, skill->get_time(GN_SLINGITEM_RANGEMELEEATK,skill_lv)); // Sitdown for 3 seconds.
+ sc_start(bl, SC_BANANA_BOMB_SITDOWN_POSTDELAY, 75, skill_lv, skill->get_time(GN_SLINGITEM_RANGEMELEEATK,skill_lv)); // Sitdown for 3 seconds.
break;
}
sd->itemid = -1;
@@ -1375,10 +1369,10 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
break;
case GN_HELLS_PLANT_ATK:
sc_start(bl, SC_STUN, 5 + 5 * skill_lv, skill_lv, skill->get_time2(skill_id, skill_lv));
- sc_start2(bl, SC_BLEEDING, 20 + 10 * skill_lv, skill_lv, src->id,skill->get_time2(skill_id, skill_lv));
+ sc_start2(bl, SC_BLOODING, 20 + 10 * skill_lv, skill_lv, src->id,skill->get_time2(skill_id, skill_lv));
break;
case EL_WIND_SLASH: // Non confirmed rate.
- sc_start2(bl, SC_BLEEDING, 25, skill_lv, src->id, skill->get_time(skill_id,skill_lv));
+ sc_start2(bl, SC_BLOODING, 25, skill_lv, src->id, skill->get_time(skill_id,skill_lv));
break;
case EL_STONE_HAMMER:
rate = 10 * skill_lv;
@@ -1391,26 +1385,26 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
case EL_TYPOON_MIS:
sc_start(bl,SC_SILENCE,10*skill_lv,skill_lv,skill->get_time(skill_id,skill_lv));
break;
- case KO_JYUMONJIKIRI: // needs more info
- sc_start(bl,SC_JYUMONJIKIRI,25,skill_lv,skill->get_time(skill_id,skill_lv));
+ case KO_JYUMONJIKIRI:
+ sc_start(bl,SC_KO_JYUMONJIKIRI,90,skill_lv,skill->get_time(skill_id,skill_lv));
break;
case KO_MAKIBISHI:
- sc_start(bl, SC_STUN, 100, skill_lv, skill->get_time2(skill_id,skill_lv));
+ sc_start(bl, SC_STUN, 10 * skill_lv, skill_lv, 1000 * (skill_lv / 2 + 2));
break;
case MH_LAVA_SLIDE:
- if (tsc && !tsc->data[SC_BURNING]) sc_start4(bl, SC_BURNING, 10 * skill_lv, skill_lv, 1000, src->id, 0, skill->get_time(skill_id, skill_lv));
+ if (tsc && !tsc->data[SC_BURNING]) sc_start4(bl, SC_BURNING, 10 * skill_lv, skill_lv, 0, src->id, 0, skill->get_time(skill_id, skill_lv));
break;
case MH_STAHL_HORN:
sc_start(bl, SC_STUN, (20 + 4 * (skill_lv-1)), skill_lv, skill->get_time(skill_id, skill_lv));
break;
case MH_NEEDLE_OF_PARALYZE:
- sc_start(bl, SC_PARALYSIS, 40 + (5*skill_lv), skill_lv, skill->get_time(skill_id, skill_lv));
+ sc_start(bl, SC_NEEDLE_OF_PARALYZE, 40 + (5*skill_lv), skill_lv, skill->get_time(skill_id, skill_lv));
break;
}
if (md && battle_config.summons_trigger_autospells && md->master_id && md->special_state.ai)
{ //Pass heritage to Master for status causing effects. [Skotlex]
- sd = map_id2sd(md->master_id);
+ sd = iMap->id2sd(md->master_id);
src = sd?&sd->bl:src;
}
@@ -1433,7 +1427,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
rate += 10;
if(sc->data[SC_OVERTHRUST])
rate += 10;
- if(sc->data[SC_MAXOVERTHRUST])
+ if(sc->data[SC_OVERTHRUSTMAX])
rate += 10;
}
if( rate )
@@ -1483,7 +1477,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
if (DIFF_TICK(ud->canact_tick, tick + rate) < 0){
ud->canact_tick = tick+rate;
if ( battle_config.display_status_timers )
- clif->status_change(src, SI_ACTIONDELAY, 1, rate, 0, 0, 0);
+ clif->status_change(src, SI_POSTDELAY, 1, rate, 0, 0, 0);
}
}
}
@@ -1580,7 +1574,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
if (DIFF_TICK(ud->canact_tick, tick + rate) < 0){
ud->canact_tick = tick+rate;
if ( battle_config.display_status_timers && sd )
- clif->status_change(src, SI_ACTIONDELAY, 1, rate, 0, 0, 0);
+ clif->status_change(src, SI_POSTDELAY, 1, rate, 0, 0, 0);
}
}
}
@@ -1600,7 +1594,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
sd->autobonus[i].atk_type&attack_type&BF_RANGEMASK &&
sd->autobonus[i].atk_type&attack_type&BF_SKILLMASK))
continue; // one or more trigger conditions were not fulfilled
- pc_exeautobonus(sd,&sd->autobonus[i]);
+ pc->exeautobonus(sd,&sd->autobonus[i]);
}
}
@@ -1713,7 +1707,7 @@ int skill_onskillusage(struct map_session_data *sd, struct block_list *bl, uint1
continue;
if( sd->autobonus3[i].atk_type != skill_id )
continue;
- pc_exeautobonus(sd,&sd->autobonus3[i]);
+ pc->exeautobonus(sd,&sd->autobonus3[i]);
}
}
@@ -1798,9 +1792,9 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list *
if(sd && skill_id && attack_type&BF_MAGIC && status_isdead(bl) &&
!(skill->get_inf(skill_id)&(INF_GROUND_SKILL|INF_SELF_SKILL)) &&
- (rate=pc_checkskill(sd,HW_SOULDRAIN))>0
+ (rate=pc->checkskill(sd,HW_SOULDRAIN))>0
){ //Soul Drain should only work on targetted spells [Skotlex]
- if (pc_issit(sd)) pc_setstand(sd); //Character stuck in attacking animation while 'sitting' fix. [Skotlex]
+ if (pc_issit(sd)) pc->setstand(sd); //Character stuck in attacking animation while 'sitting' fix. [Skotlex]
clif->skill_nodamage(src,bl,HW_SOULDRAIN,rate,1);
status_heal(src, 0, status_get_lv(bl)*(95+15*rate)/100, 2);
}
@@ -1819,10 +1813,10 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list *
if( skill_id == WZ_WATERBALL ) {//(bugreport:5303)
struct status_change *sc = NULL;
if( ( sc = status_get_sc(src) ) ) {
- if(sc->data[SC_SPIRIT] &&
- sc->data[SC_SPIRIT]->val2 == SL_WIZARD &&
- sc->data[SC_SPIRIT]->val3 == WZ_WATERBALL)
- sc->data[SC_SPIRIT]->val3 = 0; //Clear bounced spell check.
+ if(sc->data[SC_SOULLINK] &&
+ sc->data[SC_SOULLINK]->val2 == SL_WIZARD &&
+ sc->data[SC_SOULLINK]->val3 == WZ_WATERBALL)
+ sc->data[SC_SOULLINK]->val3 = 0; //Clear bounced spell check.
}
}
}
@@ -1916,7 +1910,7 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list *
if (DIFF_TICK(ud->canact_tick, tick + rate) < 0){
ud->canact_tick = tick+rate;
if ( battle_config.display_status_timers && dstsd )
- clif->status_change(bl, SI_ACTIONDELAY, 1, rate, 0, 0, 0);
+ clif->status_change(bl, SI_POSTDELAY, 1, rate, 0, 0, 0);
}
}
}
@@ -1934,7 +1928,7 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list *
dstsd->autobonus2[i].atk_type&attack_type&BF_RANGEMASK &&
dstsd->autobonus2[i].atk_type&attack_type&BF_SKILLMASK))
continue; // one or more trigger conditions were not fulfilled
- pc_exeautobonus(dstsd,&dstsd->autobonus2[i]);
+ pc->exeautobonus(dstsd,&dstsd->autobonus2[i]);
}
}
@@ -1948,8 +1942,8 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list *
--------------------------------------------------------------------------*/
int skill_break_equip (struct block_list *bl, unsigned short where, int rate, int flag) {
const int where_list[4] = {EQP_WEAPON, EQP_ARMOR, EQP_SHIELD, EQP_HELM};
- const enum sc_type scatk[4] = {SC_STRIPWEAPON, SC_STRIPARMOR, SC_STRIPSHIELD, SC_STRIPHELM};
- const enum sc_type scdef[4] = {SC_CP_WEAPON, SC_CP_ARMOR, SC_CP_SHIELD, SC_CP_HELM};
+ const enum sc_type scatk[4] = {SC_NOEQUIPWEAPON, SC_NOEQUIPARMOR, SC_NOEQUIPSHIELD, SC_NOEQUIPHELM};
+ const enum sc_type scdef[4] = {SC_PROTECTWEAPON, SC_PROTECTARMOR, SC_PROTECTSHIELD, SC_PROTECTHELM};
struct status_change *sc = status_get_sc(bl);
int i,j;
TBL_PC *sd;
@@ -2027,7 +2021,7 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in
}
if (flag) {
sd->status.inventory[j].attribute = 1;
- pc_unequipitem(sd, j, 3);
+ pc->unequipitem(sd, j, 3);
}
}
clif->equiplist(sd);
@@ -2039,8 +2033,8 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in
int skill_strip_equip(struct block_list *bl, unsigned short where, int rate, int lv, int time) {
struct status_change *sc;
const int pos[5] = {EQP_WEAPON, EQP_SHIELD, EQP_ARMOR, EQP_HELM, EQP_ACC};
- const enum sc_type sc_atk[5] = {SC_STRIPWEAPON, SC_STRIPSHIELD, SC_STRIPARMOR, SC_STRIPHELM, SC__STRIPACCESSORY};
- const enum sc_type sc_def[5] = {SC_CP_WEAPON, SC_CP_SHIELD, SC_CP_ARMOR, SC_CP_HELM, 0};
+ const enum sc_type sc_atk[5] = {SC_NOEQUIPWEAPON, SC_NOEQUIPSHIELD, SC_NOEQUIPARMOR, SC_NOEQUIPHELM, SC__STRIPACCESSARY};
+ const enum sc_type sc_def[5] = {SC_PROTECTWEAPON, SC_PROTECTSHIELD, SC_PROTECTARMOR, SC_PROTECTHELM, 0};
int i;
if (rnd()%100 >= rate)
@@ -2107,7 +2101,7 @@ int skill_blown(struct block_list* src, struct block_list* target, int count, in
}
if (dir == -1) // <optimized>: do the computation here instead of outside
- dir = map_calc_dir(target, src->x, src->y); // direction from src to target, reversed
+ dir = iMap->calc_dir(target, src->x, src->y); // direction from src to target, reversed
if (dir >= 0 && dir < 8)
{ // take the reversed 'direction' and reverse it
@@ -2173,7 +2167,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
struct status_data *sstatus, *tstatus;
struct status_change *sc;
struct map_session_data *sd, *tsd;
- int type,damage,rdamage=0;
+ int type,damage;
int8 rmdamage=0;//magic reflected
bool additional_effects = true;
@@ -2244,15 +2238,15 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
flag |= 2;
//Spirit of Wizard blocks Kaite's reflection
- if( type == 2 && sc && sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_WIZARD )
+ if( type == 2 && sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_WIZARD )
{ //Consume one Fragment per hit of the casted skill? [Skotlex]
- type = tsd?pc_search_inventory (tsd, 7321):0;
+ type = tsd?pc->search_inventory (tsd, 7321):0;
if (type >= 0) {
- if ( tsd ) pc_delitem(tsd, type, 1, 0, 1, LOG_TYPE_CONSUME);
+ if ( tsd ) pc->delitem(tsd, type, 1, 0, 1, LOG_TYPE_CONSUME);
dmg.damage = dmg.damage2 = 0;
dmg.dmg_lv = ATK_MISS;
- sc->data[SC_SPIRIT]->val3 = skill_id;
- sc->data[SC_SPIRIT]->val4 = dsrc->id;
+ sc->data[SC_SOULLINK]->val3 = skill_id;
+ sc->data[SC_SOULLINK]->val4 = dsrc->id;
}
} else if( type != 2 ) /* Kaite bypasses */
additional_effects = false;
@@ -2302,19 +2296,15 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
if( (skill_id == AL_INCAGI || skill_id == AL_BLESSING ||
skill_id == CASH_BLESSING || skill_id == CASH_INCAGI ||
- skill_id == MER_INCAGI || skill_id == MER_BLESSING) && tsd->sc.data[SC_CHANGEUNDEAD] )
+ skill_id == MER_INCAGI || skill_id == MER_BLESSING) && tsd->sc.data[SC_PROPERTYUNDEAD] )
damage = 1;
- if( damage > 0 && (( dmg.flag&BF_WEAPON && src != bl && ( src == dsrc || ( dsrc->type == BL_SKILL && ( skill_id == SG_SUN_WARM || skill_id == SG_MOON_WARM || skill_id == SG_STAR_WARM ) ) ))
- || (sc && sc->data[SC_REFLECTDAMAGE])) )
- rdamage = battle->calc_return_damage(bl,src, &damage, dmg.flag, skill_id);
-
if( damage && sc && sc->data[SC_GENSOU] && dmg.flag&BF_MAGIC ){
struct block_list *nbl;
nbl = battle->get_enemy_area(bl,bl->x,bl->y,2,BL_CHAR,bl->id);
if( nbl ){ // Only one target is chosen.
- damage = damage / 2; // Deflect half of the damage to a target nearby
- clif->skill_damage(bl, nbl, tick, status_get_amotion(src), 0, status_fix_damage(bl,nbl,damage,0), dmg.div_, OB_OBOROGENSOU_TRANSITION_ATK, -1, 6);
+ int temp = (int)(damage / (float)(10 / skill_lv));
+ clif->skill_damage(bl, nbl, tick, status_get_amotion(src), 0, status_fix_damage(bl,nbl,temp,0), 1, OB_OBOROGENSOU_TRANSITION_ATK, -1, 6);
}
}
@@ -2339,84 +2329,88 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
if(sd) {
int flag = 0; //Used to signal if this skill can be combo'ed later on.
struct status_change_entry *sce;
- if ((sce = sd->sc.data[SC_COMBO])) {//End combo state after skill is invoked. [Skotlex]
+ if ((sce = sd->sc.data[SC_COMBOATTACK])) {//End combo state after skill is invoked. [Skotlex]
switch (skill_id) {
case TK_TURNKICK:
case TK_STORMKICK:
case TK_DOWNKICK:
case TK_COUNTER:
- if (pc_famerank(sd->status.char_id,MAPID_TAEKWON)) {//Extend combo time.
+ if (pc->famerank(sd->status.char_id,MAPID_TAEKWON)) {//Extend combo time.
sce->val1 = skill_id; //Update combo-skill
sce->val3 = skill_id;
if( sce->timer != INVALID_TIMER )
- delete_timer(sce->timer, status_change_timer);
- sce->timer = add_timer(tick+sce->val4, status_change_timer, src->id, SC_COMBO);
+ iTimer->delete_timer(sce->timer, status_change_timer);
+ sce->timer = iTimer->add_timer(tick+sce->val4, status_change_timer, src->id, SC_COMBOATTACK);
break;
}
unit_cancel_combo(src); // Cancel combo wait
break;
default:
if( src == dsrc ) // Ground skills are exceptions. [Inkfish]
- status_change_end(src, SC_COMBO, INVALID_TIMER);
+ status_change_end(src, SC_COMBOATTACK, INVALID_TIMER);
}
}
switch(skill_id) {
case MO_TRIPLEATTACK:
- if (pc_checkskill(sd, MO_CHAINCOMBO) > 0 || pc_checkskill(sd, SR_DRAGONCOMBO) > 0)
+ if (pc->checkskill(sd, MO_CHAINCOMBO) > 0 || pc->checkskill(sd, SR_DRAGONCOMBO) > 0)
flag=1;
break;
case MO_CHAINCOMBO:
- if(pc_checkskill(sd, MO_COMBOFINISH) > 0 && sd->spiritball > 0)
+ if(pc->checkskill(sd, MO_COMBOFINISH) > 0 && sd->spiritball > 0)
flag=1;
break;
case MO_COMBOFINISH:
if (sd->status.party_id>0) //bonus from SG_FRIEND [Komurka]
- party_skill_check(sd, sd->status.party_id, MO_COMBOFINISH, skill_lv);
- if (pc_checkskill(sd, CH_TIGERFIST) > 0 && sd->spiritball > 0)
+ party->skill_check(sd, sd->status.party_id, MO_COMBOFINISH, skill_lv);
+ if (pc->checkskill(sd, CH_TIGERFIST) > 0 && sd->spiritball > 0)
flag=1;
case CH_TIGERFIST:
- if (!flag && pc_checkskill(sd, CH_CHAINCRUSH) > 0 && sd->spiritball > 1)
+ if (!flag && pc->checkskill(sd, CH_CHAINCRUSH) > 0 && sd->spiritball > 1)
flag=1;
case CH_CHAINCRUSH:
- if (!flag && pc_checkskill(sd, MO_EXTREMITYFIST) > 0 && sd->spiritball > 0 && sd->sc.data[SC_EXPLOSIONSPIRITS])
+ if (!flag && pc->checkskill(sd, MO_EXTREMITYFIST) > 0 && sd->spiritball > 0 && sd->sc.data[SC_EXPLOSIONSPIRITS])
flag=1;
break;
case AC_DOUBLE:
- if( (tstatus->race == RC_BRUTE || tstatus->race == RC_INSECT) && pc_checkskill(sd, HT_POWER))
+ if( (tstatus->race == RC_BRUTE || tstatus->race == RC_INSECT) && pc->checkskill(sd, HT_POWER))
{
//TODO: This code was taken from Triple Blows, is this even how it should be? [Skotlex]
- sc_start2(src,SC_COMBO,100,HT_POWER,bl->id,2000);
+ sc_start2(src,SC_COMBOATTACK,100,HT_POWER,bl->id,2000);
clif->combo_delay(src,2000);
}
break;
case TK_COUNTER:
{ //bonus from SG_FRIEND [Komurka]
int level;
- if(sd->status.party_id>0 && (level = pc_checkskill(sd,SG_FRIEND)))
- party_skill_check(sd, sd->status.party_id, TK_COUNTER,level);
+ if(sd->status.party_id>0 && (level = pc->checkskill(sd,SG_FRIEND)))
+ party->skill_check(sd, sd->status.party_id, TK_COUNTER,level);
}
break;
case SL_STIN:
case SL_STUN:
- if (skill_lv >= 7 && !sd->sc.data[SC_SMA])
- sc_start(src,SC_SMA,100,skill_lv,skill->get_time(SL_SMA, skill_lv));
+ if (skill_lv >= 7 && !sd->sc.data[SC_SMA_READY])
+ sc_start(src,SC_SMA_READY,100,skill_lv,skill->get_time(SL_SMA, skill_lv));
break;
case GS_FULLBUSTER:
//Can't attack nor use items until skill's delay expires. [Skotlex]
sd->ud.attackabletime = sd->canuseitem_tick = sd->ud.canact_tick;
break;
+ case TK_DODGE:
+ if( pc->checkskill(sd, TK_JUMPKICK) > 0 )
+ flag = 1;
+ break;
case SR_DRAGONCOMBO:
- if( pc_checkskill(sd, SR_FALLENEMPIRE) > 0 )
+ if( pc->checkskill(sd, SR_FALLENEMPIRE) > 0 )
flag = 1;
break;
case SR_FALLENEMPIRE:
- if( pc_checkskill(sd, SR_TIGERCANNON) > 0 || pc_checkskill(sd, SR_GATEOFHELL) > 0 )
+ if( pc->checkskill(sd, SR_TIGERCANNON) > 0 || pc->checkskill(sd, SR_GATEOFHELL) > 0 )
flag = 1;
break;
} //Switch End
if (flag) { //Possible to chain
if ( (flag = DIFF_TICK(sd->ud.canact_tick, tick)) < 50 ) flag = 50;/* less is a waste. */
- sc_start2(src,SC_COMBO,100,skill_id,bl->id,flag);
+ sc_start2(src,SC_COMBOATTACK,100,skill_id,bl->id,flag);
clif->combo_delay(src, flag);
}
}
@@ -2450,9 +2444,11 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
case SR_EARTHSHAKER:
dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,1,skill_id,-2,6);
break;
+ case KO_MUCHANAGE:
+ if( dmg.dmg_lv == ATK_FLEE )
+ break;
case WL_SOULEXPANSION:
case WL_COMET:
- case KO_MUCHANAGE:
case NJ_HUUMA:
dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,dmg.div_,skill_id,skill_lv,8);
break;
@@ -2479,6 +2475,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
case EL_HURRICANE_ATK:
case KO_BAKURETSU:
case GN_CRAZYWEED_ATK:
+ case NC_MAGMA_ERUPTION:
dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,dmg.div_,skill_id,-1,5);
break;
case GN_SLINGITEM_RANGEMELEEATK:
@@ -2494,6 +2491,12 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
case WM_REVERBERATION_MAGIC:
dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,dmg.div_,WM_REVERBERATION,-2,6);
break;
+ case WL_TETRAVORTEX_FIRE:
+ case WL_TETRAVORTEX_WATER:
+ case WL_TETRAVORTEX_WIND:
+ case WL_TETRAVORTEX_GROUND:
+ dmg.dmotion = clif->skill_damage(src,bl,tick,dmg.amotion,dmg.dmotion,damage,dmg.div_, WL_TETRAVORTEX,-1,5);
+ break;
case HT_CLAYMORETRAP:
case HT_BLASTMINE:
case HT_FLASHER:
@@ -2509,7 +2512,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
break;
case WZ_SIGHTBLASTER:
dmg.dmotion = clif->skill_damage(src,bl,tick, dmg.amotion, dmg.dmotion, damage, dmg.div_, skill_id, flag&SD_LEVEL?-1:skill_lv, 5);
- break;
+ break;
case AB_DUPLELIGHT_MELEE:
case AB_DUPLELIGHT_MAGIC:
dmg.amotion = 300;/* makes the damage value not overlap with previous damage (when displayed by the client) */
@@ -2525,10 +2528,10 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
break;
}
- map_freeblock_lock();
+ iMap->freeblock_lock();
if(damage > 0 && dmg.flag&BF_SKILL && tsd
- && pc_checkskill(tsd,RG_PLAGIARISM)
+ && pc->checkskill(tsd,RG_PLAGIARISM)
&& (!sc || !sc->data[SC_PRESERVE])
&& damage < tsd->battle_status.hp)
{ //Updated to not be able to copy skills if the blow will kill you. [Skotlex]
@@ -2570,7 +2573,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
if( sc && sc->data[SC__REPRODUCE] && (lv = sc->data[SC__REPRODUCE]->val1) ) {
//Level dependent and limitation.
lv = min(lv,skill->get_max(copy_skill));
- idx = skill->get_index(tsd->reproduceskill_id);
+
if( tsd->reproduceskill_id ) {
idx = skill->get_index(tsd->reproduceskill_id);
if(tsd->status.skill[idx].flag == SKILL_FLAG_PLAGIARIZED ) {
@@ -2601,16 +2604,16 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
}
}
- if ((type = pc_checkskill(tsd,RG_PLAGIARISM)) < lv)
+ if ((type = pc->checkskill(tsd,RG_PLAGIARISM)) < lv)
lv = type;
tsd->cloneskill_id = copy_skill;
pc_setglobalreg(tsd, "CLONE_SKILL", copy_skill);
pc_setglobalreg(tsd, "CLONE_SKILL_LV", lv);
- tsd->status.skill[idx].id = copy_skill;
- tsd->status.skill[idx].lv = lv;
- tsd->status.skill[idx].flag = SKILL_FLAG_PLAGIARIZED;
+ tsd->status.skill[cidx].id = copy_skill;
+ tsd->status.skill[cidx].lv = lv;
+ tsd->status.skill[cidx].flag = SKILL_FLAG_PLAGIARIZED;
clif->addskill(tsd,copy_skill);
}
}
@@ -2634,8 +2637,8 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
skill->counter_additional_effect(src,bl,skill_id,skill_lv,dmg.flag,tick);
}
// Hell Inferno burning status only starts if Fire part hits.
- if( skill_id == WL_HELLINFERNO && dmg.damage > 0 )
- sc_start4(bl,SC_BURNING,55+5*skill_lv,skill_lv,1000,src->id,0,skill->get_time(skill_id,skill_lv));
+ if( skill_id == WL_HELLINFERNO && dmg.damage > 0 && !(flag&ELE_DARK) )
+ sc_start4(bl,SC_BURNING,55+5*skill_lv,skill_lv,0,src->id,0,skill->get_time(skill_id,skill_lv));
// Apply knock back chance in SC_TRIANGLESHOT skill.
else if( skill_id == SC_TRIANGLESHOT && rnd()%100 > (1 + skill_lv) )
dmg.blewcount = 0;
@@ -2659,7 +2662,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
dir = rand()%8;
break;
case WL_CRIMSONROCK:
- dir = map_calc_dir(bl,skill_area_temp[4],skill_area_temp[5]);
+ dir = iMap->calc_dir(bl,skill_area_temp[4],skill_area_temp[5]);
break;
}
@@ -2670,7 +2673,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
short dir_x, dir_y;
dir_x = dirx[(dir+4)%8];
dir_y = diry[(dir+4)%8];
- if( map_getcell(bl->m, bl->x+dir_x, bl->y+dir_y, CELL_CHKNOPASS) != 0 )
+ if( iMap->getcell(bl->m, bl->x+dir_x, bl->y+dir_y, CELL_CHKNOPASS) != 0 )
skill->addtimerskill(src, tick + status_get_amotion(src), bl->id, 0, 0, LG_OVERBRAND_PLUSATK, skill_lv, BF_WEAPON, flag );
} else
skill->addtimerskill(src, tick + status_get_amotion(src), bl->id, 0, 0, LG_OVERBRAND_PLUSATK, skill_lv, BF_WEAPON, flag );
@@ -2680,7 +2683,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
short dir_x, dir_y;
dir_x = dirx[(dir+4)%8];
dir_y = diry[(dir+4)%8];
- if( map_getcell(bl->m, bl->x+dir_x, bl->y+dir_y, CELL_CHKNOPASS) != 0 )
+ if( iMap->getcell(bl->m, bl->x+dir_x, bl->y+dir_y, CELL_CHKNOPASS) != 0 )
skill->addtimerskill(src, tick + 300 * ((flag&2) ? 1 : 2), bl->id, 0, 0, skill_id, skill_lv, BF_WEAPON, flag|4);
}
break;
@@ -2706,7 +2709,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
if( sc && sc->data[SC_DEVOTION] && skill_id != PA_PRESSURE ) {
struct status_change_entry *sce = sc->data[SC_DEVOTION];
- struct block_list *d_bl = map_id2bl(sce->val1);
+ struct block_list *d_bl = iMap->id2bl(sce->val1);
if( d_bl && (
(d_bl->type == BL_MER && ((TBL_MER*)d_bl)->master && ((TBL_MER*)d_bl)->master->bl.id == bl->id) ||
@@ -2714,12 +2717,12 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
) && check_distance_bl(bl, d_bl, sce->val3) )
{
if(!rmdamage){
- clif->damage(d_bl,d_bl, gettick(), 0, 0, damage, 0, 0, 0);
+ clif->damage(d_bl,d_bl, iTimer->gettick(), 0, 0, damage, 0, 0, 0);
status_fix_damage(NULL,d_bl, damage, 0);
} else{ //Reflected magics are done directly on the target not on paladin
//This check is only for magical skill.
//For BF_WEAPON skills types track var rdamage and function battle_calc_return_damage
- clif->damage(bl,bl, gettick(), 0, 0, damage, 0, 0, 0);
+ clif->damage(bl,bl, iTimer->gettick(), 0, 0, damage, 0, 0, 0);
status_fix_damage(bl,bl, damage, 0);
}
}
@@ -2744,7 +2747,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
dmg.flag |= BF_WEAPON;
if( sd && src != bl && damage > 0 && ( dmg.flag&BF_WEAPON ||
- (dmg.flag&BF_MISC && (skill_id == RA_CLUSTERBOMB || skill_id == RA_FIRINGTRAP || skill_id == RA_ICEBOUNDTRAP || skill_id == RK_DRAGONBREATH)) ) )
+ (dmg.flag&BF_MISC && (skill_id == RA_CLUSTERBOMB || skill_id == RA_FIRINGTRAP || skill_id == RA_ICEBOUNDTRAP || skill_id == RK_DRAGONBREATH || skill_id == RK_DRAGONBREATH_WATER)) ) )
{
if (battle_config.left_cardfix_to_right)
battle->drain(sd, bl, dmg.damage, dmg.damage, tstatus->race, tstatus->mode&MD_BOSS);
@@ -2752,30 +2755,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
battle->drain(sd, bl, dmg.damage, dmg.damage2, tstatus->race, tstatus->mode&MD_BOSS);
}
- if( rdamage > 0 ) {
- if( sc && sc->data[SC_REFLECTDAMAGE] ) {
- if( src != bl ) {// Don't reflect your own damage (Grand Cross)
- bool change = false;
- if( sd && !sd->state.autocast )
- change = true;
- if( change )
- sd->state.autocast = 1;
- map_foreachinshootrange(battle->damage_area,bl,skill->get_splash(LG_REFLECTDAMAGE,1),BL_CHAR,tick,bl,dmg.amotion,sstatus->dmotion,rdamage,tstatus->race);
- if( change )
- sd->state.autocast = 0;
- }
- } else {
- if( dmg.amotion )
- battle->delay_damage(tick, dmg.amotion,bl,src,0,CR_REFLECTSHIELD,0,rdamage,ATK_DEF,0,additional_effects);
- else
- status_fix_damage(bl,src,rdamage,0);
- clif->damage(src,src,tick, dmg.amotion,0,rdamage,1,4,0); // in aegis damage reflected is shown in single hit.
- //Use Reflect Shield to signal this kind of skill trigger. [Skotlex]
- if( tsd && src != bl )
- battle->drain(tsd, src, rdamage, rdamage, sstatus->race, is_boss(src));
- skill->additional_effect(bl, src, CR_REFLECTSHIELD, 1, BF_WEAPON|BF_SHORT|BF_NORMAL,ATK_DEF,tick);
- }
- }
+
if( damage > 0 ) {
/**
* Post-damage effects
@@ -2794,7 +2774,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
}
break;
case WM_METALICSOUND:
- status_zap(bl, 0, damage*100/(100*(110-pc_checkskill(sd,WM_LESSON)*10)));
+ status_zap(bl, 0, damage*100/(100*(110-pc->checkskill(sd,WM_LESSON)*10)));
break;
case SR_TIGERCANNON:
status_zap(bl, 0, damage/10); // 10% of damage dealt
@@ -2809,14 +2789,14 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
skill_id == MG_COLDBOLT || skill_id == MG_FIREBOLT || skill_id == MG_LIGHTNINGBOLT
) &&
(sc = status_get_sc(src)) &&
- sc->data[SC_DOUBLECAST] &&
- rnd() % 100 < sc->data[SC_DOUBLECAST]->val2)
+ sc->data[SC_DOUBLECASTING] &&
+ rnd() % 100 < sc->data[SC_DOUBLECASTING]->val2)
{
// skill->addtimerskill(src, tick + dmg.div_*dmg.amotion, bl->id, 0, 0, skill_id, skill_lv, BF_MAGIC, flag|2);
skill->addtimerskill(src, tick + dmg.amotion, bl->id, 0, 0, skill_id, skill_lv, BF_MAGIC, flag|2);
}
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return damage;
}
@@ -2928,7 +2908,7 @@ int skill_check_unit_range (struct block_list *bl, int x, int y, uint16 skill_id
}
range += layout_type;
- return map_foreachinarea(skill->check_unit_range_sub,bl->m,x-range,y-range,x+range,y+range,BL_SKILL,skill_id);
+ return iMap->foreachinarea(skill->check_unit_range_sub,bl->m,x-range,y-range,x+range,y+range,BL_SKILL,skill_id);
}
int skill_check_unit_range2_sub (struct block_list *bl, va_list ap) {
@@ -2975,7 +2955,7 @@ int skill_check_unit_range2 (struct block_list *bl, int x, int y, uint16 skill_i
else
type = BL_PC;
- return map_foreachinarea(skill->check_unit_range2_sub, bl->m,
+ return iMap->foreachinarea(skill->check_unit_range2_sub, bl->m,
x - range, y - range, x + range, y + range,
type, skill_id);
}
@@ -3089,10 +3069,10 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv,
{
index[i] = -1;
if( itemid[i] < 1 ) continue; // No item
- index[i] = pc_search_inventory(sd, itemid[i]);
+ index[i] = pc->search_inventory(sd, itemid[i]);
if( index[i] < 0 || sd->status.inventory[index[i]].amount < amount[i] )
{
- clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0);
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_NEED_ITEM, amount[i]|(itemid[i] << 16));
return 0;
}
}
@@ -3100,7 +3080,7 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv,
// Consume items
for( i = 0; i < ARRAYLENGTH(itemid); i++ )
{
- if( index[i] >= 0 ) pc_delitem(sd, index[i], amount[i], 0, 1, LOG_TYPE_CONSUME);
+ if( index[i] >= 0 ) pc->delitem(sd, index[i], amount[i], 0, 1, LOG_TYPE_CONSUME);
}
if( type&2 )
@@ -3123,7 +3103,7 @@ int skill_area_sub_count (struct block_list *src, struct block_list *target, uin
*
*------------------------------------------*/
int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) {
- struct block_list *src = map_id2bl(id),*target;
+ struct block_list *src = iMap->id2bl(id),*target;
struct unit_data *ud = unit_bl2ud(src);
struct skill_timerskill *skl;
int range;
@@ -3138,7 +3118,7 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) {
if(src->prev == NULL)
break; // Source not on Map
if(skl->target_id) {
- target = map_id2bl(skl->target_id);
+ target = iMap->id2bl(skl->target_id);
if( ( skl->skill_id == RG_INTIMIDATE || skl->skill_id == SC_FATALMENACE ) && (!target || target->prev == NULL || !check_distance_bl(src,target,AREA_SIZE)) )
target = src; //Required since it has to warp.
if(target == NULL)
@@ -3156,7 +3136,7 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) {
case RG_INTIMIDATE:
if (unit_warp(src,-1,-1,-1,CLR_TELEPORT) == 0) {
short x,y;
- map_search_freecell(src, 0, &x, &y, 1, 1, 0);
+ iMap->search_freecell(src, 0, &x, &y, 1, 1, 0);
if (target != src && !status_isdead(target))
unit_warp(target, -1, x, y, CLR_TELEPORT);
}
@@ -3164,16 +3144,16 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) {
case BA_FROSTJOKER:
case DC_SCREAM:
range= skill->get_splash(skl->skill_id, skl->skill_lv);
- map_foreachinarea(skill->frostjoke_scream,skl->map,skl->x-range,skl->y-range,
+ iMap->foreachinarea(skill->frostjoke_scream,skl->map,skl->x-range,skl->y-range,
skl->x+range,skl->y+range,BL_CHAR,src,skl->skill_id,skl->skill_lv,tick);
break;
case NPC_EARTHQUAKE:
if( skl->type > 1 )
skill->addtimerskill(src,tick+250,src->id,0,0,skl->skill_id,skl->skill_lv,skl->type-1,skl->flag);
- skill_area_temp[0] = map_foreachinrange(skill->area_sub, src, skill->get_splash(skl->skill_id, skl->skill_lv), BL_CHAR, src, skl->skill_id, skl->skill_lv, tick, BCT_ENEMY, skill->area_sub_count);
+ skill_area_temp[0] = iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skl->skill_id, skl->skill_lv), BL_CHAR, src, skl->skill_id, skl->skill_lv, tick, BCT_ENEMY, skill->area_sub_count);
skill_area_temp[1] = src->id;
skill_area_temp[2] = 0;
- map_foreachinrange(skill->area_sub, src, skill->get_splash(skl->skill_id, skl->skill_lv), splash_target(src), src, skl->skill_id, skl->skill_lv, tick, skl->flag, skill->castend_damage_id);
+ iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skl->skill_id, skl->skill_lv), splash_target(src), src, skl->skill_id, skl->skill_lv, tick, skl->flag, skill->castend_damage_id);
break;
case WZ_WATERBALL:
skill->toggle_magicpower(src, skl->skill_id); // only the first hit will be amplify
@@ -3184,10 +3164,10 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) {
} else {
struct status_change *sc = status_get_sc(src);
if(sc) {
- if(sc->data[SC_SPIRIT] &&
- sc->data[SC_SPIRIT]->val2 == SL_WIZARD &&
- sc->data[SC_SPIRIT]->val3 == skl->skill_id)
- sc->data[SC_SPIRIT]->val3 = 0; //Clear bounced spell check.
+ if(sc->data[SC_SOULLINK] &&
+ sc->data[SC_SOULLINK]->val2 == SL_WIZARD &&
+ sc->data[SC_SOULLINK]->val3 == skl->skill_id)
+ sc->data[SC_SOULLINK]->val3 = 0; //Clear bounced spell check.
}
}
break;
@@ -3196,48 +3176,33 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) {
**/
case WL_CHAINLIGHTNING_ATK: {
struct block_list *nbl = NULL; // Next Target of Chain
- skill->attack(BF_MAGIC,src,src,target,skl->skill_id,skl->skill_lv,tick,skl->flag); // Hit a Lightning on the current Target
+ skill->attack(BF_MAGIC, src, src, target, skl->skill_id, skl->skill_lv, tick, (9-skl->type)); // Hit a Lightning on the current Target
skill->toggle_magicpower(src, skl->skill_id); // only the first hit will be amplify
- if( skl->type > 1 ) { // Remaining Chains Hit
- nbl = battle->get_enemy_area(src,target->x,target->y,2,BL_CHAR|BL_SKILL,target->id); // Search for a new Target around current one...
- if( nbl == NULL && skl->x > 1 ) {
- nbl = target;
- skl->x--;
- } else
- skl->x = 3;
+
+ if( skl->type < (4 + skl->skill_lv - 1) && skl->x < 3 )
+ { // Remaining Chains Hit
+ nbl = battle->get_enemy_area(src, target->x, target->y, (skl->type>2)?2:3, // After 2 bounces, it will bounce to other targets in 7x7 range.
+ BL_CHAR|BL_SKILL, target->id); // Search for a new Target around current one...
+ if( nbl == NULL)
+ skl->x++;
+ else
+ skl->x = 0;
+
+ skill->addtimerskill(src, tick + 651, (nbl?nbl:target)->id, skl->x, 0, WL_CHAINLIGHTNING_ATK, skl->skill_lv, skl->type + 1, skl->flag);
}
-
- if( nbl )
- skill->addtimerskill(src,tick+status_get_adelay(src),nbl->id,skl->x,0,WL_CHAINLIGHTNING_ATK,skl->skill_lv,skl->type-1,skl->flag);
}
break;
case WL_TETRAVORTEX_FIRE:
case WL_TETRAVORTEX_WATER:
case WL_TETRAVORTEX_WIND:
case WL_TETRAVORTEX_GROUND:
- skill->attack(BF_MAGIC,src,src,target,skl->skill_id,skl->skill_lv,tick,skl->flag|SD_ANIMATION);
+ clif->skill_nodamage(src, target, skl->skill_id, skl->skill_lv, 1);
+ skill_attack(BF_MAGIC, src, src, target, skl->skill_id, skl->skill_lv, tick, skl->flag);
skill->toggle_magicpower(src, skl->skill_id); // only the first hit will be amplify
- if( skl->type >= 3 ) { // Final Hit
- if( !status_isdead(target) ) { // Final Status Effect
- int effects[4] = { SC_BURNING, SC_FREEZING, SC_BLEEDING, SC_STUN },
- applyeffects[4] = { 0, 0, 0, 0 },
- i, j = 0, k = 0;
- for( i = 1; i <= 8; i = i + i ) {
- if( skl->x&i )
- {
- applyeffects[j] = effects[k];
- j++;
- }
- k++;
- }
- if( j ) {
- i = applyeffects[rnd()%j];
- status_change_start(target, i, 10000, skl->skill_lv,
- (i == SC_BURNING ? 1000 : (i == SC_BLEEDING ? src->id : 0)),
- (i == SC_BURNING ? src->id : 0),
- 0, skill->get_time(WL_TETRAVORTEX,skl->skill_lv), 0);
- }
- }
+ if( skl->type == 4 ){
+ const enum sc_type scs[] = { SC_BURNING, SC_BLOODING, SC_FROSTMISTY, SC_STUN }; // status inflicts are depend on what summoned element is used.
+ int rate = skl->y, index = skl->x-1;
+ sc_start2(target, scs[index], rate, skl->skill_lv, src->id, skill->get_time(WL_TETRAVORTEX,index));
}
break;
case WM_REVERBERATION_MELEE:
@@ -3249,7 +3214,7 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) {
unit_warp(src, -1, skl->x, skl->y, 3);
else { // Target's Part
short x = skl->x, y = skl->y;
- map_search_freecell(NULL, target->m, &x, &y, 2, 2, 1);
+ iMap->search_freecell(NULL, target->m, &x, &y, 2, 2, 1);
unit_warp(target,-1,x,y,3);
}
break;
@@ -3270,9 +3235,22 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) {
skill->attack(BF_WEAPON, src, src, target, skl->skill_id, skl->skill_lv, tick, skl->flag|SD_LEVEL);
break;
case GN_SPORE_EXPLOSION:
- map_foreachinrange(skill->area_sub, target, skill->get_splash(skl->skill_id, skl->skill_lv), BL_CHAR,
+ iMap->foreachinrange(skill->area_sub, target, skill->get_splash(skl->skill_id, skl->skill_lv), BL_CHAR,
src, skl->skill_id, skl->skill_lv, 0, skl->flag|1|BCT_ENEMY, skill->castend_damage_id);
break;
+ case SR_FLASHCOMBO_ATK_STEP1:
+ case SR_FLASHCOMBO_ATK_STEP2:
+ case SR_FLASHCOMBO_ATK_STEP3:
+ case SR_FLASHCOMBO_ATK_STEP4:
+ if( src->type == BL_PC ) {
+ struct map_session_data *sd = NULL;
+ const enum e_skill combos[] = {SR_DRAGONCOMBO, SR_FALLENEMPIRE, SR_TIGERCANNON, SR_SKYNETBLOW};
+ if( (sd = ((TBL_PC*)src)) ){
+ uint16 cid = combos[skl->skill_id-SR_FLASHCOMBO_ATK_STEP1];
+ skill->castend_damage_id(src, target, cid, pc->checkskill(sd, cid), tick, 0);
+ }
+ }
+ break;
case CH_PALMSTRIKE:
{
struct status_change* tsc = status_get_sc(target);
@@ -3304,7 +3282,7 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) {
break;
case GN_CRAZYWEED_ATK: {
int dummy = 1, i = skill->get_unit_range(skl->skill_id,skl->skill_lv);
- map_foreachinarea(skill->cell_overlap, src->m, skl->x-i, skl->y-i, skl->x+i, skl->y+i, BL_SKILL, skl->skill_id, &dummy, src);
+ iMap->foreachinarea(skill->cell_overlap, src->m, skl->x-i, skl->y-i, skl->x+i, skl->y+i, BL_SKILL, skl->skill_id, &dummy, src);
}
case WL_EARTHSTRAIN:
skill->unitsetting(src,skl->skill_id,skl->skill_lv,skl->x,skl->y,(skl->type<<16)|skl->flag);
@@ -3335,7 +3313,7 @@ int skill_addtimerskill (struct block_list *src, unsigned int tick, int target,
if( i == MAX_SKILLTIMERSKILL ) return 1;
ud->skilltimerskill[i] = ers_alloc(skill_timer_ers, struct skill_timerskill);
- ud->skilltimerskill[i]->timer = add_timer(tick, skill->timerskill, src->id, i);
+ ud->skilltimerskill[i]->timer = iTimer->add_timer(tick, skill->timerskill, src->id, i);
ud->skilltimerskill[i]->src_id = src->id;
ud->skilltimerskill[i]->target_id = target;
ud->skilltimerskill[i]->skill_id = skill_id;
@@ -3361,7 +3339,7 @@ int skill_cleartimerskill (struct block_list *src)
for(i=0;i<MAX_SKILLTIMERSKILL;i++) {
if(ud->skilltimerskill[i]) {
- delete_timer(ud->skilltimerskill[i]->timer, skill->timerskill);
+ iTimer->delete_timer(ud->skilltimerskill[i]->timer, skill->timerskill);
ers_free(skill_timer_ers, ud->skilltimerskill[i]);
ud->skilltimerskill[i]=NULL;
}
@@ -3374,8 +3352,8 @@ int skill_activate_reverbetion( struct block_list *bl, va_list ap) {
if( bl->type != BL_SKILL )
return 0;
if( su->alive && (sg = su->group) && sg->skill_id == WM_REVERBERATION ) {
- map_foreachinrange(skill->trap_splash, bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, bl, gettick());
- su->limit=DIFF_TICK(gettick(),sg->tick);
+ iMap->foreachinrange(skill->trap_splash, bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, bl, iTimer->gettick());
+ su->limit=DIFF_TICK(iTimer->gettick(),sg->tick);
sg->unit_id = UNT_USED_TRAPS;
}
return 0;
@@ -3433,7 +3411,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
tstatus = status_get_status_data(bl);
- map_freeblock_lock();
+ iMap->freeblock_lock();
switch(skill_id) {
case MER_CRASH:
@@ -3516,7 +3494,9 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case GS_FULLBUSTER:
case NJ_SYURIKEN:
case NJ_KUNAI:
+#ifndef RENEWAL
case ASC_BREAKER:
+#endif
case HFLI_MOON: //[orn]
case HFLI_SBR44: //[orn]
case NPC_BLEEDING:
@@ -3524,6 +3504,8 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case NPC_HELLPOWER:
case RK_SONICWAVE:
case RK_HUNDREDSPEAR:
+ case RK_STORMBLAST:
+ case RK_CRUSHSTRIKE:
case AB_DUPLELIGHT_MELEE:
case RA_AIMEDBOLT:
case NC_AXEBOOMERANG:
@@ -3546,7 +3528,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case GN_SLINGITEM_RANGEMELEEATK:
case KO_JYUMONJIKIRI:
case KO_SETSUDAN:
- case KO_KAIHOU:
+ case GC_DARKCROW:
skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag);
break;
@@ -3558,7 +3540,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case NC_VULCANARM:
case NC_COLDSLOWER:
case NC_ARMSCANNON:
- if (sd) pc_overheat(sd,1);
+ if (sd) pc->overheat(sd,1);
case RK_WINDCUTTER:
skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag|SD_ANIMATION);
break;
@@ -3579,9 +3561,9 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
break;
case MO_COMBOFINISH:
- if (!(flag&1) && sc && sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_MONK)
+ if (!(flag&1) && sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_MONK)
{ //Becomes a splash attack when Soul Linked.
- map_foreachinrange(skill->area_sub, bl,
+ iMap->foreachinrange(skill->area_sub, bl,
skill->get_splash(skill_id, skill_lv),splash_target(src),
src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1,
skill->castend_damage_id);
@@ -3592,7 +3574,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case TK_STORMKICK: // Taekwon kicks [Dralnu]
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
skill_area_temp[1] = 0;
- map_foreachinrange(skill->attack_area, src,
+ iMap->foreachinrange(skill->attack_area, src,
skill->get_splash(skill_id, skill_lv), splash_target(src),
BF_WEAPON, src, src, skill_id, skill_lv, tick, flag, BCT_ENEMY);
break;
@@ -3600,7 +3582,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case KN_CHARGEATK: {
bool path = path_search_long(NULL, src->m, src->x, src->y, bl->x, bl->y,CELL_CHKWALL);
unsigned int dist = distance_bl(src, bl);
- uint8 dir = map_calc_dir(bl, src->x, src->y);
+ uint8 dir = iMap->calc_dir(bl, src->x, src->y);
// teleport to target (if not on WoE grounds)
if( !map_flag_gvg(src->m) && !map[src->m].flag.battleground && unit_movepos(src, bl->x, bl->y, 0, 1) )
@@ -3619,7 +3601,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
break;
case NC_FLAMELAUNCHER:
- if (sd) pc_overheat(sd,1);
+ if (sd) pc->overheat(sd,1);
case SN_SHARPSHOOTING:
case MA_SHARPSHOOTING:
case NJ_KAMAITACHI:
@@ -3627,7 +3609,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
//It won't shoot through walls since on castend there has to be a direct
//line of sight between caster and target.
skill_area_temp[1] = bl->id;
- map_foreachinpath (skill->attack_area,src->m,src->x,src->y,bl->x,bl->y,
+ iMap->foreachinpath (skill->attack_area,src->m,src->x,src->y,bl->x,bl->y,
skill->get_splash(skill_id, skill_lv),skill->get_maxcount(skill_id,skill_lv), splash_target(src),
skill->get_type(skill_id),src,src,skill_id,skill_lv,tick,flag,BCT_ENEMY);
break;
@@ -3638,7 +3620,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case NPC_ICEBREATH:
case NPC_THUNDERBREATH:
skill_area_temp[1] = bl->id;
- map_foreachinpath(skill->attack_area,src->m,src->x,src->y,bl->x,bl->y,
+ iMap->foreachinpath(skill->attack_area,src->m,src->x,src->y,bl->x,bl->y,
skill->get_splash(skill_id, skill_lv),skill->get_maxcount(skill_id,skill_lv), splash_target(src),
skill->get_type(skill_id),src,src,skill_id,skill_lv,tick,flag,BCT_ENEMY);
break;
@@ -3650,8 +3632,8 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case RG_BACKSTAP:
{
- uint8 dir = map_calc_dir(src, bl->x, bl->y), t_dir = unit_getdir(bl);
- if ((!check_distance_bl(src, bl, 0) && !map_check_dir(dir, t_dir)) || bl->type == BL_SKILL) {
+ uint8 dir = iMap->calc_dir(src, bl->x, bl->y), t_dir = unit_getdir(bl);
+ if ((!check_distance_bl(src, bl, 0) && !iMap->check_dir(dir, t_dir)) || bl->type == BL_SKILL) {
status_change_end(src, SC_HIDING, INVALID_TIMER);
skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, flag);
dir = dir < 4 ? dir+4 : dir-4; // change direction [Celest]
@@ -3678,9 +3660,6 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
break;
case NJ_ISSEN:
- status_change_end(src, SC_NEN, INVALID_TIMER);
- status_change_end(src, SC_HIDING, INVALID_TIMER);
- // fall through
case MO_EXTREMITYFIST:
{
short x, y, i = 2; // Move 2 cells for Issen(from target)
@@ -3699,7 +3678,9 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
#ifdef RENEWAL
sc_start(src,SC_EXTREMITYFIST2,100,skill_lv,skill->get_time(skill_id,skill_lv));
#endif
- }else
+ }else{
+ status_change_end(src, SC_NJ_NEN, INVALID_TIMER);
+ status_change_end(src, SC_HIDING, INVALID_TIMER);
status_set_hp(src,
#ifdef RENEWAL
max(status_get_max_hp(src)/100, 1)
@@ -3707,8 +3688,8 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
1
#endif
, 0);
-
- dir = map_calc_dir(src,bl->x,bl->y);
+ }
+ dir = iMap->calc_dir(src,bl->x,bl->y);
if( dir > 0 && dir < 4) x = -i;
else if( dir > 4 ) x = i;
else x = 0;
@@ -3784,7 +3765,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
int sflag = skill_area_temp[0] & 0xFFF, heal;
if( flag&SD_LEVEL )
sflag |= SD_LEVEL; // -1 will be used in packets instead of the skill level
- if( skill_area_temp[1] != bl->id && !(skill->get_inf2(skill_id)&INF2_NPC_SKILL) )
+ if( (skill_area_temp[1] != bl->id && !(skill->get_inf2(skill_id)&INF2_NPC_SKILL)) || flag&SD_ANIMATION )
sflag |= SD_ANIMATION; // original target gets no animation (as well as all NPC skills)
heal = skill->attack(skill->get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, sflag);
@@ -3799,6 +3780,8 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case GN_CARTCANNON:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
break;
+ case SR_TIGERCANNON:
+ flag |= SD_ANIMATION;
case LG_MOONSLASHER:
clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
break;
@@ -3821,10 +3804,10 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
//SD_LEVEL -> Forced splash damage for Auto Blitz-Beat -> count targets
//special case: Venom Splasher uses a different range for searching than for splashing
if( flag&SD_LEVEL || skill->get_nk(skill_id)&NK_SPLASHSPLIT )
- skill_area_temp[0] = map_foreachinrange(skill->area_sub, bl, (skill_id == AS_SPLASHER)?1:skill->get_splash(skill_id, skill_lv), BL_CHAR, src, skill_id, skill_lv, tick, BCT_ENEMY, skill->area_sub_count);
+ skill_area_temp[0] = iMap->foreachinrange(skill->area_sub, bl, (skill_id == AS_SPLASHER)?1:skill->get_splash(skill_id, skill_lv), BL_CHAR, src, skill_id, skill_lv, tick, BCT_ENEMY, skill->area_sub_count);
// recursive invocation of skill->castend_damage_id() with flag|1
- map_foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), ( skill_id == WM_REVERBERATION_MELEE || skill_id == WM_REVERBERATION_MAGIC )?BL_CHAR:splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id);
+ iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), ( skill_id == WM_REVERBERATION_MELEE || skill_id == WM_REVERBERATION_MAGIC )?BL_CHAR:splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id);
}
break;
@@ -3852,13 +3835,13 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
for(i=0;i<c;i++){
if (!skill->blown(src,bl,1,(unit_getdir(src)+4)%8,0x1))
break; //Can't knockback
- skill_area_temp[0] = map_foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, src, skill_id, skill_lv, tick, flag|BCT_ENEMY, skill->area_sub_count);
+ skill_area_temp[0] = iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, src, skill_id, skill_lv, tick, flag|BCT_ENEMY, skill->area_sub_count);
if( skill_area_temp[0] > 1 ) break; // collision
}
clif->blown(bl); //Update target pos.
if (i!=c) { //Splash
skill_area_temp[1] = bl->id;
- map_foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id);
+ iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id);
}
//Weirdo dual-hit property, two attacks for 500%
skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,0);
@@ -3874,14 +3857,14 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
skill->blown(src,bl,skill_area_temp[2],-1,0);
} else {
int x=bl->x,y=bl->y,i,dir;
- dir = map_calc_dir(bl,src->x,src->y);
+ dir = iMap->calc_dir(bl,src->x,src->y);
skill_area_temp[1] = bl->id;
skill_area_temp[2] = skill->get_blewcount(skill_id,skill_lv);
// all the enemies between the caster and the target are hit, as well as the target
if (skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,0))
skill->blown(src,bl,skill_area_temp[2],-1,0);
for (i=0;i<4;i++) {
- map_foreachincell(skill->area_sub,bl->m,x,y,BL_CHAR,
+ iMap->foreachincell(skill->area_sub,bl->m,x,y,BL_CHAR,
src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
x += dirx[dir];
y += diry[dir];
@@ -3894,7 +3877,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
{
skill_area_temp[1] = bl->id; //NOTE: This is used in skill->castend_nodamage_id to avoid affecting the target.
if (skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag))
- map_foreachinrange(skill->area_sub,bl,
+ iMap->foreachinrange(skill->area_sub,bl,
skill->get_splash(skill_id, skill_lv),BL_CHAR,
src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,
skill->castend_nodamage_id);
@@ -3936,6 +3919,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case AB_DUPLELIGHT_MAGIC:
case WM_METALICSOUND:
case MH_ERASER_CUTTER:
+ case KO_KAIHOU:
skill->attack(BF_MAGIC,src,src,bl,skill_id,skill_lv,tick,flag);
break;
@@ -3977,11 +3961,11 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
for( y = src->y - range; y <= src->y + range; ++y )
for( x = src->x - range; x <= src->x + range; ++x )
{
- if( !map_find_skill_unit_oncell(src,x,y,SA_LANDPROTECTOR,NULL,1) )
+ if( !iMap->find_skill_unit_oncell(src,x,y,SA_LANDPROTECTOR,NULL,1) )
{
- if( src->type != BL_PC || map_getcell(src->m,x,y,CELL_CHKWATER) ) // non-players bypass the water requirement
+ if( src->type != BL_PC || iMap->getcell(src->m,x,y,CELL_CHKWATER) ) // non-players bypass the water requirement
count++; // natural water cell
- else if( (unit = map_find_skill_unit_oncell(src,x,y,SA_DELUGE,NULL,1)) != NULL || (unit = map_find_skill_unit_oncell(src,x,y,NJ_SUITON,NULL,1)) != NULL )
+ else if( (unit = iMap->find_skill_unit_oncell(src,x,y,SA_DELUGE,NULL,1)) != NULL || (unit = iMap->find_skill_unit_oncell(src,x,y,NJ_SUITON,NULL,1)) != NULL )
{
count++; // skill-induced water cell
skill->delunit(unit); // consume cell
@@ -4002,7 +3986,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
break;
case SL_SMA:
- status_change_end(src, SC_SMA, INVALID_TIMER);
+ status_change_end(src, SC_SMA_READY, INVALID_TIMER);
case SL_STIN:
case SL_STUN:
if (sd && !battle_config.allow_es_magic_pc && bl->type != BL_MOB) {
@@ -4024,11 +4008,15 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case NJ_ZENYNAGE:
case GN_THORNS_TRAP:
case GN_HELLS_PLANT_ATK:
+#ifdef RENEWAL
+ case ASC_BREAKER:
+#endif
skill->attack(BF_MISC,src,src,bl,skill_id,skill_lv,tick,flag);
break;
/**
* Rune Knight
**/
+ case RK_DRAGONBREATH_WATER:
case RK_DRAGONBREATH: {
struct status_change *tsc = NULL;
if( (tsc = status_get_sc(bl)) && (tsc->data[SC_HIDING] )) {
@@ -4087,7 +4075,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
if( !map_flag_gvg(src->m) && !map[src->m].flag.battleground )
{ //You don't move on GVG grounds.
short x, y;
- map_search_freecell(bl, 0, &x, &y, 1, 1, 0);
+ iMap->search_freecell(bl, 0, &x, &y, 1, 1, 0);
if (unit_movepos(src, x, y, 0, 0))
clif->slide(src,src->x,src->y);
}
@@ -4095,7 +4083,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag);
break;
case RK_PHANTOMTHRUST:
- unit_setdir(src,map_calc_dir(src, bl->x, bl->y));
+ unit_setdir(src,iMap->calc_dir(src, bl->x, bl->y));
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
skill->blown(src,bl,distance_bl(src,bl)-1,unit_getdir(src),0);
@@ -4103,20 +4091,10 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag);
break;
- case RK_STORMBLAST:
- case RK_CRUSHSTRIKE:
- if( sd ) {
- if( pc_checkskill(sd,RK_RUNEMASTERY) >= ( skill_id == RK_CRUSHSTRIKE ? 7 : 3 ) )
- skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag);
- else
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- } else //non-sd support
- skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag);
- break;
case GC_DARKILLUSION:
{
short x, y;
- short dir = map_calc_dir(src,bl->x,bl->y);
+ short dir = iMap->calc_dir(src,bl->x,bl->y);
if( dir > 0 && dir < 4) x = 2;
else if( dir > 4 ) x = -2;
@@ -4136,9 +4114,8 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
}
break;
-
case GC_WEAPONCRUSH:
- if( sc && sc->data[SC_COMBO] && sc->data[SC_COMBO]->val1 == GC_WEAPONBLOCKING )
+ if( sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == GC_WEAPONBLOCKING )
skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag);
else if( sd )
clif->skill_fail(sd,skill_id,USESKILL_FAIL_GC_WEAPONBLOCKING,0);
@@ -4164,7 +4141,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
break;
case WL_CHAINLIGHTNING:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- skill->addtimerskill(src,tick + 150,bl->id,3,0,WL_CHAINLIGHTNING_ATK,skill_lv,4+skill_lv,flag);
+ skill->addtimerskill(src,tick+status_get_amotion(src),bl->id,0,0,WL_CHAINLIGHTNING_ATK,skill_lv,0,flag);
break;
case WL_DRAINLIFE:
{
@@ -4173,7 +4150,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
heal = heal * (5 + 5 * skill_lv) / 100;
- if( bl->type == BL_SKILL )
+ if( bl->type == BL_SKILL || status_get_hp(src) == status_get_max_hp(src)) // Don't absorb when caster was in full HP
heal = 0; // Don't absorb heal from Ice Walls or other skill units.
if( heal && rnd()%100 < rate )
@@ -4185,61 +4162,43 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
break;
case WL_TETRAVORTEX:
- if( sd ) {
- int spheres[5] = { 0, 0, 0, 0, 0 },
- positions[5] = {-1,-1,-1,-1,-1 },
- i, j = 0, k, subskill = 0;
-
- for( i = SC_SPHERE_1; i <= SC_SPHERE_5; i++ )
- if( sc && sc->data[i] )
- {
- spheres[j] = i;
- positions[j] = sc->data[i]->val2;
- j++; //
- }
-
- if( j < 4 )
- { // Need 4 spheres minimum
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- break;
- }
-
- // Sphere Sort, this time from new to old
- for( i = 0; i <= j - 2; i++ )
- for( k = i + 1; k <= j - 1; k++ )
- if( positions[i] < positions[k] )
- {
- swap(positions[i],positions[k]);
- swap(spheres[i],spheres[k]);
+ if( sc ){
+ int i = SC_SUMMON5, x = 0;
+ int types[][2] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}};
+ for(; i >= SC_SUMMON1; i--){
+ if( sc->data[i] ){
+ int skillid = WL_TETRAVORTEX_FIRE + (sc->data[i]->val1 - WLS_FIRE) + (sc->data[i]->val1 == WLS_WIND) - (sc->data[i]->val1 == WLS_WATER), sc_index = 0, rate = 0;
+ if( x < 4 ){
+ types[x][0] = (sc->data[i]->val1 - WLS_FIRE) + 1;
+ types[x][1] = 25; // 25% each for equal sharing
+ if( x == 3 ){
+ x = 0;
+ sc_index = types[rand()%4][0];
+ for(; x < 4; x++)
+ if(types[x][0] == sc_index)
+ rate += types[x][1];
+ }
+ skill->addtimerskill(src, tick + (SC_SUMMON5-i) * 206, bl->id, sc_index, rate, skillid, skill_lv, x, flag);
}
-
- k = 0;
- for( i = 0; i < 4; i++ )
- {
- switch( sc->data[spheres[i]]->val1 )
- {
- case WLS_FIRE: subskill = WL_TETRAVORTEX_FIRE; k |= 1; break;
- case WLS_WIND: subskill = WL_TETRAVORTEX_WIND; k |= 4; break;
- case WLS_WATER: subskill = WL_TETRAVORTEX_WATER; k |= 2; break;
- case WLS_STONE: subskill = WL_TETRAVORTEX_GROUND; k |= 8; break;
+ status_change_end(src, (sc_type)i, INVALID_TIMER);
+ x++;
}
- skill->addtimerskill(src, tick + i * 200, bl->id, k, 0, subskill, skill_lv, i, flag);
- clif->skill_nodamage(src, bl, subskill, skill_lv, 1);
- status_change_end(src, spheres[i], INVALID_TIMER);
}
}
break;
case WL_RELEASE:
if( sd ) {
- int i;
+ int i, cooldown;
+ clif->skill_nodamage(src, bl, skill_id, skill_lv, 1);
+ skill->toggle_magicpower(src, skill_id);
// Priority is to release SpellBook
if( sc && sc->data[SC_READING_SB] ) { // SpellBook
uint16 skill_id, skill_lv, point, s = 0;
- int spell[SC_MAXSPELLBOOK-SC_SPELLBOOK1 + 1];
+ int spell[SC_SPELLBOOK7-SC_SPELLBOOK1 + 1];
- for(i = SC_MAXSPELLBOOK; i >= SC_SPELLBOOK1; i--) // List all available spell to be released
- if( sc->data[i] ) spell[s++] = i;
+ for(i = SC_SPELLBOOK7; i >= SC_SPELLBOOK1; i--) // List all available spell to be released
+ if( sc->data[i] ) spell[s++] = i;
if ( s == 0 )
break;
@@ -4252,13 +4211,12 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
status_change_end(src, (sc_type)i, INVALID_TIMER);
}else //something went wrong :(
break;
-
+
if( sc->data[SC_READING_SB]->val2 > point )
sc->data[SC_READING_SB]->val2 -= point;
else // Last spell to be released
status_change_end(src, SC_READING_SB, INVALID_TIMER);
- if( bl->type != BL_SKILL ) /* skill types will crash the client */
- clif->skill_nodamage(src, bl, skill_id, skill_lv, 1);
+
if( !skill->check_condition_castbegin(sd, skill_id, skill_lv) )
break;
@@ -4275,47 +4233,32 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
}
sd->ud.canact_tick = tick + skill->delay_fix(src, skill_id, skill_lv);
- clif->status_change(src, SI_ACTIONDELAY, 1, skill->delay_fix(src, skill_id, skill_lv), 0, 0, 0);
- } else { // Summon Balls
- int j = 0, k, skele;
- int spheres[5] = { 0, 0, 0, 0, 0 },
- positions[5] = {-1,-1,-1,-1,-1 };
-
- for( i = SC_SPHERE_1; i <= SC_SPHERE_5; i++ )
- if( sc && sc->data[i] ) {
- spheres[j] = i;
- positions[j] = sc->data[i]->val2;
- sc->data[i]->val2--; // Prepares for next position
- j++;
- }
+ clif->status_change(src, SI_POSTDELAY, 1, skill->delay_fix(src, skill_id, skill_lv), 0, 0, 0);
- if( j == 0 ) { // No Spheres
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_SUMMON_NONE,0);
- break;
+ cooldown = skill_get_cooldown(skill_id, skill_lv);
+ for (i = 0; i < ARRAYLENGTH(sd->skillcooldown) && sd->skillcooldown[i].id; i++) {
+ if (sd->skillcooldown[i].id == skill_id){
+ cooldown += sd->skillcooldown[i].val;
+ break;
+ }
}
-
- // Sphere Sort
- for( i = 0; i <= j - 2; i++ )
- for( k = i + 1; k <= j - 1; k++ )
- if( positions[i] > positions[k] ) {
- swap(positions[i],positions[k]);
- swap(spheres[i],spheres[k]);
- }
-
- if( skill_lv == 1 ) j = 1; // Limit only to one ball
- for( i = 0; i < j; i++ ) {
- skele = WL_RELEASE - 5 + sc->data[spheres[i]]->val1 - WLS_FIRE; // Convert Ball Element into Skill ATK for balls
- // WL_SUMMON_ATK_FIRE, WL_SUMMON_ATK_WIND, WL_SUMMON_ATK_WATER, WL_SUMMON_ATK_GROUND
- skill->addtimerskill(src,tick+status_get_adelay(src)*i,bl->id,0,0,skele,sc->data[spheres[i]]->val3,BF_MAGIC,flag|SD_LEVEL);
- status_change_end(src, spheres[i], INVALID_TIMER); // Eliminate ball
+ if(cooldown)
+ skill->blockpc_start(sd, skill_id, cooldown, false);
+ }else if( sc ){ // Summon Balls
+ int i = SC_SUMMON5;
+ for(; i >= SC_SUMMON1; i--){
+ if( sc->data[i] ){
+ int skillid = WL_SUMMON_ATK_FIRE + (sc->data[i]->val1 - WLS_FIRE);
+ skill->addtimerskill(src, tick + status_get_adelay(src) * (SC_SUMMON5 - i), bl->id, 0, 0, skillid, skill_lv, BF_MAGIC, flag);
+ status_change_end(src, (sc_type)i, INVALID_TIMER);
+ if(skill_lv == 1)
+ break;
+ }
}
- clif->skill_nodamage(src,bl,skill_id,0,1);
}
}
break;
case WL_FROSTMISTY:
- // Causes Freezing status through walls.
- sc_start(bl,status_skill2sc(skill_id),20+12*skill_lv+(sd ? sd->status.job_level : 50)/5,skill_lv,skill->get_time(skill_id,skill_lv));
// Doesn't deal damage through non-shootable walls.
if( path_search(NULL,src->m,src->x,src->y,bl->x,bl->y,1,CELL_CHKWALL) )
skill->attack(BF_MAGIC,src,src,bl,skill_id,skill_lv,tick,flag|SD_ANIMATION);
@@ -4328,7 +4271,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
if( sd && pc_isridingwug(sd) ){
short x[8]={0,-1,-1,-1,0,1,1,1};
short y[8]={1,1,0,-1,-1,-1,0,1};
- uint8 dir = map_calc_dir(bl, src->x, src->y);
+ uint8 dir = iMap->calc_dir(bl, src->x, src->y);
if( unit_movepos(src, bl->x+x[dir], bl->y+y[dir], 1, 1) )
{
@@ -4368,7 +4311,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
item_tmp.nameid = sg->item_id?sg->item_id:ITEMID_TRAP;
item_tmp.identify = 1;
if( item_tmp.nameid )
- map_addflooritem(&item_tmp,1,bl->m,bl->x,bl->y,0,0,0,0);
+ iMap->addflooritem(&item_tmp,1,bl->m,bl->x,bl->y,0,0,0,0);
}
skill->delunit(su);
}
@@ -4385,9 +4328,9 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
}
else
{
- map_foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id);
+ iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id);
clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
- if( sd ) pc_overheat(sd,1);
+ if( sd ) pc->overheat(sd,1);
}
break;
@@ -4400,11 +4343,11 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
else
{
short x, y;
- map_search_freecell(src, 0, &x, &y, -1, -1, 0);
+ iMap->search_freecell(src, 0, &x, &y, -1, -1, 0);
// Destination area
skill_area_temp[4] = x;
skill_area_temp[5] = y;
- map_foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id);
+ iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id);
skill->addtimerskill(src,tick + 800,src->id,x,y,skill_id,skill_lv,0,flag); // To teleport Self
clif->skill_damage(src,src,tick,status_get_amotion(src),0,-30000,1,skill_id,skill_lv,6);
}
@@ -4444,19 +4387,19 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
break;
case SR_HOWLINGOFLION:
- status_change_end(bl, SC_SWINGDANCE, INVALID_TIMER);
- status_change_end(bl, SC_SYMPHONYOFLOVER, INVALID_TIMER);
- status_change_end(bl, SC_MOONLITSERENADE, INVALID_TIMER);
- status_change_end(bl, SC_RUSHWINDMILL, INVALID_TIMER);
+ status_change_end(bl, SC_SWING, INVALID_TIMER);
+ status_change_end(bl, SC_SYMPHONY_LOVE, INVALID_TIMER);
+ status_change_end(bl, SC_MOONLIT_SERENADE, INVALID_TIMER);
+ status_change_end(bl, SC_RUSH_WINDMILL, INVALID_TIMER);
status_change_end(bl, SC_ECHOSONG, INVALID_TIMER);
status_change_end(bl, SC_HARMONIZE, INVALID_TIMER);
status_change_end(bl, SC_SIRCLEOFNATURE, INVALID_TIMER);
- status_change_end(bl, SC_SATURDAYNIGHTFEVER, INVALID_TIMER);
- status_change_end(bl, SC_DANCEWITHWUG, INVALID_TIMER);
- status_change_end(bl, SC_LERADSDEW, INVALID_TIMER);
+ status_change_end(bl, SC_SATURDAY_NIGHT_FEVER, INVALID_TIMER);
+ status_change_end(bl, SC_DANCE_WITH_WUG, INVALID_TIMER);
+ status_change_end(bl, SC_LERADS_DEW, INVALID_TIMER);
status_change_end(bl, SC_MELODYOFSINK, INVALID_TIMER);
- status_change_end(bl, SC_BEYONDOFWARCRY, INVALID_TIMER);
- status_change_end(bl, SC_UNLIMITEDHUMMINGVOICE, INVALID_TIMER);
+ status_change_end(bl, SC_BEYOND_OF_WARCRY, INVALID_TIMER);
+ status_change_end(bl, SC_UNLIMITED_HUMMING_VOICE, INVALID_TIMER);
skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, flag|SD_ANIMATION);
break;
@@ -4466,7 +4409,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
status_change_end(bl, SC_HIDING, INVALID_TIMER);
status_change_end(bl, SC_CLOAKINGEXCEED, INVALID_TIMER);
} else{
- map_foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id);
+ iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id);
clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
}
break;
@@ -4487,7 +4430,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
skill->attack(skill->get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag);
else {
clif->skill_nodamage(src, bl, skill_id, 0, 1);
- skill->addtimerskill(src, gettick() + skill->get_time(skill_id, skill_lv) - 1000, bl->id, 0, 0, skill_id, skill_lv, 0, 0);
+ skill->addtimerskill(src, iTimer->gettick() + skill->get_time(skill_id, skill_lv) - 1000, bl->id, 0, 0, skill_id, skill_lv, 0, 0);
}
break;
@@ -4503,7 +4446,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
clif->skill_nodamage(src,battle->get_master(src),skill_id,skill_lv,1);
clif->skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
if( rnd()%100 < 30 )
- map_foreachinrange(skill->area_sub,bl,i,BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
+ iMap->foreachinrange(skill->area_sub,bl,i,BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
else
skill->attack(skill->get_type(skill_id),src,src,bl,skill_id,skill_lv,tick,flag);
}
@@ -4526,7 +4469,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
clif->skill_nodamage(src,battle->get_master(src),skill_id,skill_lv,1);
clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
if( rnd()%100 < 30 )
- map_foreachinrange(skill->area_sub,bl,i,BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
+ iMap->foreachinrange(skill->area_sub,bl,i,BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
else
skill->attack(skill->get_type(skill_id),src,src,bl,skill_id,skill_lv,tick,flag);
}
@@ -4564,7 +4507,6 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
}
break;
-
//recursive homon skill
case MH_MAGMA_FLOW:
case MH_XENO_SLASHER:
@@ -4572,7 +4514,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
if(flag & 1)
skill->attack(skill->get_type(skill_id), src, src, bl, skill_id, skill_lv, tick, flag);
else {
- map_foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag | BCT_ENEMY | SD_SPLASH | 1, skill->castend_damage_id);
+ iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag | BCT_ENEMY | SD_SPLASH | 1, skill->castend_damage_id);
}
break;
@@ -4580,8 +4522,8 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case MH_NEEDLE_OF_PARALYZE:
skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, flag);
break;
- case MH_TINDER_BREAKER:
- if (unit_movepos(src, bl->x, bl->y, 1, 1)) {
+ case MH_TINDER_BREAKER:
+ if (unit_movepos(src, bl->x, bl->y, 1, 1)) {
#if PACKETVER >= 20111005
clif->snap(src, bl->x, bl->y);
#else
@@ -4589,7 +4531,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
#endif
}
clif->skill_nodamage(src,bl,skill_id,skill_lv,
- sc_start4(bl,SC_CLOSECONFINE2,100,skill_lv,src->id,0,0,skill->get_time(skill_id,skill_lv)));
+ sc_start4(bl,SC_RG_CCONFINE_S,100,skill_lv,src->id,0,0,skill->get_time(skill_id,skill_lv)));
skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, flag);
break;
@@ -4600,7 +4542,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, SD_LEVEL|flag);
} else {
skill_area_temp[1] = bl->id;
- map_foreachinrange(skill->area_sub, bl,
+ iMap->foreachinrange(skill->area_sub, bl,
sd->bonus.splash_range, BL_CHAR,
src, skill_id, skill_lv, tick, flag | BCT_ENEMY | 1,
skill->castend_damage_id);
@@ -4614,18 +4556,18 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
clif->skill_damage(src, bl, tick, status_get_amotion(src), tstatus->dmotion,
0, abs(skill->get_num(skill_id, skill_lv)),
skill_id, skill_lv, skill->get_hit(skill_id));
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 1;
}
if( sc && sc->data[SC_CURSEDCIRCLE_ATKER] ) //Should only remove after the skill has been casted.
status_change_end(src,SC_CURSEDCIRCLE_ATKER,INVALID_TIMER);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
if( sd && !(flag&1) )
{// ensure that the skill last-cast tick is recorded
- sd->canskill_tick = gettick();
+ sd->canskill_tick = iTimer->gettick();
if( sd->state.arrow_atk )
{// consume arrow on last invocation to this skill.
@@ -4642,6 +4584,333 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
/*==========================================
*
*------------------------------------------*/
+int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data)
+{
+ struct block_list *target, *src;
+ struct map_session_data *sd;
+ struct mob_data *md;
+ struct unit_data *ud;
+ struct status_change *sc = NULL;
+ int inf,inf2,flag = 0;
+
+ src = iMap->id2bl(id);
+ if( src == NULL )
+ {
+ ShowDebug("skill_castend_id: src == NULL (tid=%d, id=%d)\n", tid, id);
+ return 0;// not found
+ }
+
+ ud = unit_bl2ud(src);
+ if( ud == NULL )
+ {
+ ShowDebug("skill_castend_id: ud == NULL (tid=%d, id=%d)\n", tid, id);
+ return 0;// ???
+ }
+
+ sd = BL_CAST(BL_PC, src);
+ md = BL_CAST(BL_MOB, src);
+
+ if( src->prev == NULL ) {
+ ud->skilltimer = INVALID_TIMER;
+ return 0;
+ }
+
+ if(ud->skill_id != SA_CASTCANCEL && ud->skill_id != SO_SPELLFIST) {// otherwise handled in unit_skillcastcancel()
+ if( ud->skilltimer != tid ) {
+ ShowError("skill_castend_id: Timer mismatch %d!=%d!\n", ud->skilltimer, tid);
+ ud->skilltimer = INVALID_TIMER;
+ return 0;
+ }
+
+ if( sd && ud->skilltimer != INVALID_TIMER && (pc->checkskill(sd,SA_FREECAST) > 0 || ud->skill_id == LG_EXEEDBREAK) )
+ {// restore original walk speed
+ ud->skilltimer = INVALID_TIMER;
+ status_calc_bl(&sd->bl, SCB_SPEED);
+ }
+
+ ud->skilltimer = INVALID_TIMER;
+ }
+
+ if (ud->skilltarget == id)
+ target = src;
+ else
+ target = iMap->id2bl(ud->skilltarget);
+
+ // Use a do so that you can break out of it when the skill fails.
+ do {
+ if(!target || target->prev==NULL) break;
+
+ if(src->m != target->m || status_isdead(src)) break;
+
+ switch (ud->skill_id) {
+ //These should become skill_castend_pos
+ case WE_CALLPARTNER:
+ if(sd) clif->callpartner(sd);
+ case WE_CALLPARENT:
+ case WE_CALLBABY:
+ case AM_RESURRECTHOMUN:
+ case PF_SPIDERWEB:
+ //Find a random spot to place the skill. [Skotlex]
+ inf2 = skill->get_splash(ud->skill_id, ud->skill_lv);
+ ud->skillx = target->x + inf2;
+ ud->skilly = target->y + inf2;
+ if (inf2 && !iMap->random_dir(target, &ud->skillx, &ud->skilly)) {
+ ud->skillx = target->x;
+ ud->skilly = target->y;
+ }
+ ud->skilltimer=tid;
+ return skill->castend_pos(tid,tick,id,data);
+ case GN_WALLOFTHORN:
+ ud->skillx = target->x;
+ ud->skilly = target->y;
+ ud->skilltimer = tid;
+ return skill->castend_pos(tid,tick,id,data);
+ }
+
+ if(ud->skill_id == RG_BACKSTAP) {
+ uint8 dir = iMap->calc_dir(src,target->x,target->y),t_dir = unit_getdir(target);
+ if(check_distance_bl(src, target, 0) || iMap->check_dir(dir,t_dir)) {
+ break;
+ }
+ }
+
+ if( ud->skill_id == PR_TURNUNDEAD ) {
+ struct status_data *tstatus = status_get_status_data(target);
+ if( !battle->check_undead(tstatus->race, tstatus->def_ele) )
+ break;
+ }
+
+ if( ud->skill_id == RA_WUGSTRIKE ){
+ if( !path_search(NULL,src->m,src->x,src->y,target->x,target->y,1,CELL_CHKNOREACH))
+ break;
+ }
+
+ if( ud->skill_id == PR_LEXDIVINA || ud->skill_id == MER_LEXDIVINA )
+ {
+ sc = status_get_sc(target);
+ if( battle->check_target(src,target, BCT_ENEMY) <= 0 && (!sc || !sc->data[SC_SILENCE]) )
+ { //If it's not an enemy, and not silenced, you can't use the skill on them. [Skotlex]
+ clif->skill_nodamage (src, target, ud->skill_id, ud->skill_lv, 0);
+ break;
+ }
+ }
+ else
+ { // Check target validity.
+ inf = skill->get_inf(ud->skill_id);
+ inf2 = skill->get_inf2(ud->skill_id);
+
+ if(inf&INF_ATTACK_SKILL ||
+ (inf&INF_SELF_SKILL && inf2&INF2_NO_TARGET_SELF) //Combo skills
+ ) // Casted through combo.
+ inf = BCT_ENEMY; //Offensive skill.
+ else if(inf2&INF2_NO_ENEMY)
+ inf = BCT_NOENEMY;
+ else
+ inf = 0;
+
+ if(inf2 & (INF2_PARTY_ONLY|INF2_GUILD_ONLY) && src != target)
+ {
+ inf |=
+ (inf2&INF2_PARTY_ONLY?BCT_PARTY:0)|
+ (inf2&INF2_GUILD_ONLY?BCT_GUILD:0);
+ //Remove neutral targets (but allow enemy if skill is designed to be so)
+ inf &= ~BCT_NEUTRAL;
+ }
+
+ if( sd && (inf2&INF2_CHORUS_SKILL) && skill->check_pc_partner(sd, ud->skill_id, &ud->skill_lv, 1, 0) < 1 ) {
+ clif->skill_fail(sd, ud->skill_id, USESKILL_FAIL_NEED_HELPER, 0);
+ break;
+ }
+
+ if( ud->skill_id >= SL_SKE && ud->skill_id <= SL_SKA && target->type == BL_MOB )
+ {
+ if( ((TBL_MOB*)target)->class_ == MOBID_EMPERIUM )
+ break;
+ }
+ else if (inf && battle->check_target(src, target, inf) <= 0){
+ if (sd) clif->skill_fail(sd,ud->skill_id,USESKILL_FAIL_LEVEL,0);
+ break;
+ }
+
+ if(inf&BCT_ENEMY && (sc = status_get_sc(target)) &&
+ sc->data[SC_FOGWALL] &&
+ rnd() % 100 < 75) { //Fogwall makes all offensive-type targetted skills fail at 75%
+ if (sd) clif->skill_fail(sd, ud->skill_id, USESKILL_FAIL_LEVEL, 0);
+ break;
+ }
+ }
+
+ //Avoid doing double checks for instant-cast skills.
+ if (tid != INVALID_TIMER && !status_check_skilluse(src, target, ud->skill_id, 1))
+ break;
+
+ if(md) {
+ md->last_thinktime=tick +MIN_MOBTHINKTIME;
+ if(md->skill_idx >= 0 && md->db->skill[md->skill_idx].emotion >= 0)
+ clif->emotion(src, md->db->skill[md->skill_idx].emotion);
+ }
+
+ if(src != target && battle_config.skill_add_range &&
+ !check_distance_bl(src, target, skill->get_range2(src,ud->skill_id,ud->skill_lv)+battle_config.skill_add_range))
+ {
+ if (sd) {
+ clif->skill_fail(sd,ud->skill_id,USESKILL_FAIL_LEVEL,0);
+ if(battle_config.skill_out_range_consume) //Consume items anyway. [Skotlex]
+ skill->consume_requirement(sd,ud->skill_id,ud->skill_lv,3);
+ }
+ break;
+ }
+
+ if( sd )
+ {
+ if( !skill->check_condition_castend(sd, ud->skill_id, ud->skill_lv) )
+ break;
+ else
+ skill->consume_requirement(sd,ud->skill_id,ud->skill_lv,1);
+ }
+#ifdef OFFICIAL_WALKPATH
+ if( !path_search_long(NULL, src->m, src->x, src->y, target->x, target->y, CELL_CHKWALL) )
+ break;
+#endif
+ if( (src->type == BL_MER || src->type == BL_HOM) && !skill->check_condition_mercenary(src, ud->skill_id, ud->skill_lv, 1) )
+ break;
+
+ if (ud->state.running && ud->skill_id == TK_JUMPKICK) {
+ ud->state.running = 0;
+ status_change_end(src, SC_RUN, INVALID_TIMER);
+ flag = 1;
+ }
+
+ if (ud->walktimer != INVALID_TIMER && ud->skill_id != TK_RUN && ud->skill_id != RA_WUGDASH)
+ unit_stop_walking(src,1);
+
+ if( !sd || sd->skillitem != ud->skill_id || skill->get_delay(ud->skill_id,ud->skill_lv) )
+ ud->canact_tick = tick + skill->delay_fix(src, ud->skill_id, ud->skill_lv); //Tests show wings don't overwrite the delay but skill scrolls do. [Inkfish]
+ if (sd) { //Cooldown application
+ int i, cooldown = skill->get_cooldown(ud->skill_id, ud->skill_lv);
+ for (i = 0; i < ARRAYLENGTH(sd->skillcooldown) && sd->skillcooldown[i].id; i++) { // Increases/Decreases cooldown of a skill by item/card bonuses.
+ if (sd->skillcooldown[i].id == ud->skill_id){
+ cooldown += sd->skillcooldown[i].val;
+ break;
+ }
+ }
+ if(cooldown)
+ skill->blockpc_start(sd, ud->skill_id, cooldown, false);
+ }
+ if( battle_config.display_status_timers && sd )
+ clif->status_change(src, SI_POSTDELAY, 1, skill->delay_fix(src, ud->skill_id, ud->skill_lv), 0, 0, 0);
+ if( sd )
+ {
+ switch( ud->skill_id )
+ {
+ case GS_DESPERADO:
+ sd->canequip_tick = tick + skill->get_time(ud->skill_id, ud->skill_lv);
+ break;
+ case CR_GRANDCROSS:
+ case NPC_GRANDDARKNESS:
+ if( (sc = status_get_sc(src)) && sc->data[SC_NOEQUIPSHIELD] )
+ {
+ const struct TimerData *timer = iTimer->get_timer(sc->data[SC_NOEQUIPSHIELD]->timer);
+ if( timer && timer->func == status_change_timer && DIFF_TICK(timer->tick,iTimer->gettick()+skill->get_time(ud->skill_id, ud->skill_lv)) > 0 )
+ break;
+ }
+ sc_start2(src, SC_NOEQUIPSHIELD, 100, 0, 1, skill->get_time(ud->skill_id, ud->skill_lv));
+ break;
+ }
+ }
+ if (skill->get_state(ud->skill_id) != ST_MOVE_ENABLE)
+ unit_set_walkdelay(src, tick, battle_config.default_walk_delay+skill->get_walkdelay(ud->skill_id, ud->skill_lv), 1);
+
+ if(battle_config.skill_log && battle_config.skill_log&src->type)
+ ShowInfo("Type %d, ID %d skill castend id [id =%d, lv=%d, target ID %d]\n",
+ src->type, src->id, ud->skill_id, ud->skill_lv, target->id);
+
+ iMap->freeblock_lock();
+
+ // SC_MAGICPOWER needs to switch states before any damage is actually dealt
+ skill->toggle_magicpower(src, ud->skill_id);
+ if( ud->skill_id != RA_CAMOUFLAGE ) // only normal attack and auto cast skills benefit from its bonuses
+ status_change_end(src,SC_CAMOUFLAGE, INVALID_TIMER);
+
+ if (skill->get_casttype(ud->skill_id) == CAST_NODAMAGE)
+ skill->castend_nodamage_id(src,target,ud->skill_id,ud->skill_lv,tick,flag);
+ else
+ skill->castend_damage_id(src,target,ud->skill_id,ud->skill_lv,tick,flag);
+
+ sc = status_get_sc(src);
+ if(sc && sc->count) {
+ if(sc->data[SC_SOULLINK] &&
+ sc->data[SC_SOULLINK]->val2 == SL_WIZARD &&
+ sc->data[SC_SOULLINK]->val3 == ud->skill_id &&
+ ud->skill_id != WZ_WATERBALL)
+ sc->data[SC_SOULLINK]->val3 = 0; //Clear bounced spell check.
+
+ if( sc->data[SC_DANCING] && skill->get_inf2(ud->skill_id)&INF2_SONG_DANCE && sd )
+ skill->blockpc_start(sd,BD_ADAPTATION,3000, false);
+ }
+
+ if( sd && ud->skill_id != SA_ABRACADABRA && ud->skill_id != WM_RANDOMIZESPELL ) // they just set the data so leave it as it is.[Inkfish]
+ sd->skillitem = sd->skillitemlv = 0;
+
+ if (ud->skilltimer == INVALID_TIMER) {
+ if(md) md->skill_idx = -1;
+ else ud->skill_id = 0; //mobs can't clear this one as it is used for skill condition 'afterskill'
+ ud->skill_lv = ud->skilltarget = 0;
+ }
+ iMap->freeblock_unlock();
+ return 1;
+ } while(0);
+
+ //Skill failed.
+ if (ud->skill_id == MO_EXTREMITYFIST && sd && !(sc && sc->data[SC_FOGWALL]))
+ { //When Asura fails... (except when it fails from Fog of Wall)
+ //Consume SP/spheres
+ skill->consume_requirement(sd,ud->skill_id, ud->skill_lv,1);
+ status_set_sp(src, 0, 0);
+ sc = &sd->sc;
+ if (sc->count)
+ { //End states
+ status_change_end(src, SC_EXPLOSIONSPIRITS, INVALID_TIMER);
+ status_change_end(src, SC_BLADESTOP, INVALID_TIMER);
+#ifdef RENEWAL
+ sc_start(src, SC_EXTREMITYFIST2, 100, ud->skill_lv, skill->get_time(ud->skill_id, ud->skill_lv));
+#endif
+ }
+ if (target && target->m == src->m)
+ { //Move character to target anyway.
+ int dir, x, y;
+ dir = iMap->calc_dir(src,target->x,target->y);
+ if( dir > 0 && dir < 4) x = -2;
+ else if( dir > 4 ) x = 2;
+ else x = 0;
+ if( dir > 2 && dir < 6 ) y = -2;
+ else if( dir == 7 || dir < 2 ) y = 2;
+ else y = 0;
+ if (unit_movepos(src, src->x+x, src->y+y, 1, 1))
+ { //Display movement + animation.
+ clif->slide(src,src->x,src->y);
+ clif->skill_damage(src,target,tick,sd->battle_status.amotion,0,0,1,ud->skill_id, ud->skill_lv, 5);
+ }
+ clif->skill_fail(sd,ud->skill_id,USESKILL_FAIL_LEVEL,0);
+ }
+ }
+
+ ud->skill_id = ud->skill_lv = ud->skilltarget = 0;
+ if( !sd || sd->skillitem != ud->skill_id || skill->get_delay(ud->skill_id,ud->skill_lv) )
+ ud->canact_tick = tick;
+ //You can't place a skill failed packet here because it would be
+ //sent in ALL cases, even cases where skill_check_condition fails
+ //which would lead to double 'skill failed' messages u.u [Skotlex]
+ if(sd)
+ sd->skillitem = sd->skillitemlv = 0;
+ else if(md)
+ md->skill_idx = -1;
+ return 0;
+}
+
+/*==========================================
+ *
+ *------------------------------------------*/
int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, unsigned int tick, int flag)
{
struct map_session_data *sd, *dstsd;
@@ -4733,6 +5002,23 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
return ret;
}
break;
+ case RK_MILLENNIUMSHIELD:
+ case RK_CRUSHSTRIKE:
+ case RK_REFRESH:
+ case RK_GIANTGROWTH:
+ case RK_STONEHARDSKIN:
+ case RK_VITALITYACTIVATION:
+ case RK_STORMBLAST:
+ case RK_FIGHTINGSPIRIT:
+ case RK_ABUNDANCE:
+ if( sd && !pc->checkskill(sd, RK_RUNEMASTERY) ){
+ if( status_change_start(&sd->bl, (sc_type)(rnd()%SC_CONFUSION), 1000, 1, 0, 0, 0, skill->get_time2(skill_id,skill_lv),8) ){
+ skill->consume_requirement(sd,skill_id,skill_lv,2);
+ iMap->freeblock_unlock();
+ return 0;
+ }
+ }
+ break;
default:
//Skill is actually ground placed.
if (src == bl && skill->get_unit_id(skill_id,0))
@@ -4749,7 +5035,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
battle->attr_fix(NULL, NULL, 100, i, tstatus->def_ele, tstatus->ele_lv) <= 0)
return 1; //Skills that cause an status should be blocked if the target element blocks its element.
- map_freeblock_lock();
+ iMap->freeblock_lock();
switch(skill_id) {
case HLIF_HEAL: //[orn]
case AL_HEAL:
@@ -4785,7 +5071,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
dstsd = sd;
}
}
- else if (tsc->data[SC_BERSERK] || tsc->data[SC_SATURDAYNIGHTFEVER] || tsc->data[SC__BLOODYLUST])
+ else if (tsc->data[SC_BERSERK] || tsc->data[SC_SATURDAY_NIGHT_FEVER] || tsc->data[SC__BLOODYLUST])
heal = 0; //Needed so that it actually displays 0 when healing.
}
clif->skill_nodamage (src, bl, skill_id, heal, 1);
@@ -4797,7 +5083,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
heal_get_jobexp = heal_get_jobexp * battle_config.heal_exp / 100;
if (heal_get_jobexp <= 0)
heal_get_jobexp = 1;
- pc_gainexp (sd, bl, 0, heal_get_jobexp, false);
+ pc->gainexp (sd, bl, 0, heal_get_jobexp, false);
}
}
break;
@@ -4819,8 +5105,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
}
skill_area_temp[0] = 5 - skill_area_temp[0]; // The actual penalty...
if (skill_area_temp[0] > 0 && !map[src->m].flag.noexppenalty) { //Apply penalty
- sd->status.base_exp -= min(sd->status.base_exp, pc_nextbaseexp(sd) * skill_area_temp[0] * 2/1000); //0.2% penalty per each.
- sd->status.job_exp -= min(sd->status.job_exp, pc_nextjobexp(sd) * skill_area_temp[0] * 2/1000);
+ sd->status.base_exp -= min(sd->status.base_exp, pc->nextbaseexp(sd) * skill_area_temp[0] * 2/1000); //0.2% penalty per each.
+ sd->status.job_exp -= min(sd->status.job_exp, pc->nextjobexp(sd) * skill_area_temp[0] * 2/1000);
clif->updatestatus(sd,SP_BASEEXP);
clif->updatestatus(sd,SP_JOBEXP);
}
@@ -4864,16 +5150,16 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
{
int exp = 0,jexp = 0;
int lv = dstsd->status.base_level - sd->status.base_level, jlv = dstsd->status.job_level - sd->status.job_level;
- if(lv > 0 && pc_nextbaseexp(dstsd)) {
+ if(lv > 0 && pc->nextbaseexp(dstsd)) {
exp = (int)((double)dstsd->status.base_exp * (double)lv * (double)battle_config.resurrection_exp / 1000000.);
if (exp < 1) exp = 1;
}
- if(jlv > 0 && pc_nextjobexp(dstsd)) {
+ if(jlv > 0 && pc->nextjobexp(dstsd)) {
jexp = (int)((double)dstsd->status.job_exp * (double)lv * (double)battle_config.resurrection_exp / 1000000.);
if (jexp < 1) jexp = 1;
}
if(exp > 0 || jexp > 0)
- pc_gainexp (sd, bl, exp, jexp, false);
+ pc->gainexp (sd, bl, exp, jexp, false);
}
}
}
@@ -4889,7 +5175,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if (flag&1)
sc_start(bl,type, 23+skill_lv*4 +status_get_lv(src) -status_get_lv(bl), skill_lv,skill->get_time(skill_id,skill_lv));
else {
- map_foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_CHAR,
+ iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_CHAR,
src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id);
clif->skill_nodamage(src, bl, skill_id, skill_lv, 1);
}
@@ -4945,7 +5231,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if (!target_id)
break;
if (skill->get_casttype(abra_skill_id) == CAST_GROUND) {
- bl = map_id2bl(target_id);
+ bl = iMap->id2bl(target_id);
if (!bl) bl = src;
unit_skilluse_pos(src, bl->x, bl->y, abra_skill_id, abra_skill_lv);
} else
@@ -4985,7 +5271,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
break;
case SA_LEVELUP:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- if (sd && pc_nextbaseexp(sd)) pc_gainexp(sd, NULL, pc_nextbaseexp(sd) * 10 / 100, 0, false);
+ if (sd && pc->nextbaseexp(sd)) pc->gainexp(sd, NULL, pc->nextbaseexp(sd) * 10 / 100, 0, false);
break;
case SA_INSTANTDEATH:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
@@ -5010,7 +5296,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
mob_class_change(dstmd,class_);
if( tsc && dstmd->status.mode&MD_BOSS )
{
- const enum sc_type scs[] = { SC_QUAGMIRE, SC_PROVOKE, SC_ROKISWEIL, SC_GRAVITATION, SC_SUITON, SC_STRIPWEAPON, SC_STRIPSHIELD, SC_STRIPARMOR, SC_STRIPHELM, SC_BLADESTOP };
+ const enum sc_type scs[] = { SC_QUAGMIRE, SC_PROVOKE, SC_ROKISWEIL, SC_GRAVITATION, SC_NJ_SUITON, SC_NOEQUIPWEAPON, SC_NOEQUIPSHIELD, SC_NOEQUIPARMOR, SC_NOEQUIPHELM, SC_BLADESTOP };
for (i = SC_COMMON_MIN; i <= SC_COMMON_MAX; i++)
if (tsc->data[i]) status_change_end(bl, (sc_type)i, INVALID_TIMER);
for (i = 0; i < ARRAYLENGTH(scs); i++)
@@ -5033,7 +5319,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
break;
case SA_FORTUNE:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- if(sd) pc_getzeny(sd,status_get_lv(bl)*100,LOG_TYPE_STEAL,NULL);
+ if(sd) pc->getzeny(sd,status_get_lv(bl)*100,LOG_TYPE_STEAL,NULL);
break;
case SA_TAMINGMONSTER:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
@@ -5048,7 +5334,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if(sd && dstsd){ //Check they are not another crusader [Skotlex]
if ((dstsd->class_&MAPID_UPPERMASK) == MAPID_CRUSADER) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 1;
}
}
@@ -5063,31 +5349,31 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if( sd && dstsd && (dstsd->class_&MAPID_UPPERMASK) == MAPID_BARDDANCER && dstsd->status.sex == sd->status.sex )
{// Cannot cast on another bard/dancer-type class of the same gender as caster
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 1;
}
if( sc && tsc )
{
- if( !sc->data[SC_MARIONETTE] && !tsc->data[SC_MARIONETTE2] )
+ if( !sc->data[SC_MARIONETTE_MASTER] && !tsc->data[SC_MARIONETTE] )
{
- sc_start(src,SC_MARIONETTE,100,bl->id,skill->get_time(skill_id,skill_lv));
- sc_start(bl,SC_MARIONETTE2,100,src->id,skill->get_time(skill_id,skill_lv));
+ sc_start(src,SC_MARIONETTE_MASTER,100,bl->id,skill->get_time(skill_id,skill_lv));
+ sc_start(bl,SC_MARIONETTE,100,src->id,skill->get_time(skill_id,skill_lv));
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
}
else
- if( sc->data[SC_MARIONETTE ] && sc->data[SC_MARIONETTE ]->val1 == bl->id &&
- tsc->data[SC_MARIONETTE2] && tsc->data[SC_MARIONETTE2]->val1 == src->id )
+ if( sc->data[SC_MARIONETTE_MASTER ] && sc->data[SC_MARIONETTE_MASTER ]->val1 == bl->id &&
+ tsc->data[SC_MARIONETTE] && tsc->data[SC_MARIONETTE]->val1 == src->id )
{
- status_change_end(src, SC_MARIONETTE, INVALID_TIMER);
- status_change_end(bl, SC_MARIONETTE2, INVALID_TIMER);
+ status_change_end(src, SC_MARIONETTE_MASTER, INVALID_TIMER);
+ status_change_end(bl, SC_MARIONETTE, INVALID_TIMER);
}
else
{
if( sd )
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 1;
}
}
@@ -5106,13 +5392,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if(dstsd->status.weapon == W_FIST ||
(dstsd->sc.count && !dstsd->sc.data[type] &&
( //Allow re-enchanting to lenghten time. [Skotlex]
- dstsd->sc.data[SC_FIREWEAPON] ||
- dstsd->sc.data[SC_WATERWEAPON] ||
- dstsd->sc.data[SC_WINDWEAPON] ||
- dstsd->sc.data[SC_EARTHWEAPON] ||
- dstsd->sc.data[SC_SHADOWWEAPON] ||
- dstsd->sc.data[SC_GHOSTWEAPON] ||
- dstsd->sc.data[SC_ENCPOISON]
+ dstsd->sc.data[SC_PROPERTYFIRE] ||
+ dstsd->sc.data[SC_PROPERTYWATER] ||
+ dstsd->sc.data[SC_PROPERTYWIND] ||
+ dstsd->sc.data[SC_PROPERTYGROUND] ||
+ dstsd->sc.data[SC_PROPERTYDARK] ||
+ dstsd->sc.data[SC_PROPERTYTELEKINESIS] ||
+ dstsd->sc.data[SC_ENCHANTPOISON]
))
) {
if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
@@ -5146,18 +5432,18 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case TK_SEVENWIND:
switch(skill->get_ele(skill_id,skill_lv)) {
- case ELE_EARTH : type = SC_EARTHWEAPON; break;
- case ELE_WIND : type = SC_WINDWEAPON; break;
- case ELE_WATER : type = SC_WATERWEAPON; break;
- case ELE_FIRE : type = SC_FIREWEAPON; break;
- case ELE_GHOST : type = SC_GHOSTWEAPON; break;
- case ELE_DARK : type = SC_SHADOWWEAPON; break;
+ case ELE_EARTH : type = SC_PROPERTYGROUND; break;
+ case ELE_WIND : type = SC_PROPERTYWIND; break;
+ case ELE_WATER : type = SC_PROPERTYWATER; break;
+ case ELE_FIRE : type = SC_PROPERTYFIRE; break;
+ case ELE_GHOST : type = SC_PROPERTYTELEKINESIS; break;
+ case ELE_DARK : type = SC_PROPERTYDARK; break;
case ELE_HOLY : type = SC_ASPERSIO; break;
}
clif->skill_nodamage(src,bl,skill_id,skill_lv,
sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)));
- sc_start(bl,SC_SEVENWIND,100,skill_lv,skill->get_time(skill_id,skill_lv));
+ sc_start2(bl,SC_TK_SEVENWIND,100,skill_lv,skill->get_ele(skill_id,skill_lv),skill->get_time(skill_id,skill_lv));
break;
@@ -5170,7 +5456,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case SM_MAGNUM:
case MS_MAGNUM:
skill_area_temp[1] = 0;
- map_foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_SKILL|BL_CHAR,
+ iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_SKILL|BL_CHAR,
src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1, skill->castend_damage_id);
clif->skill_nodamage (src,src,skill_id,skill_lv,1);
// Initiate 10% of your damage becomes fire element.
@@ -5199,7 +5485,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case AL_BLESSING:
case MER_INCAGI:
case MER_BLESSING:
- if (dstsd != NULL && tsc->data[SC_CHANGEUNDEAD]) {
+ if (dstsd != NULL && tsc->data[SC_PROPERTYUNDEAD]) {
skill->attack(BF_MISC,src,src,bl,skill_id,skill_lv,tick,flag);
break;
}
@@ -5270,6 +5556,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case SR_GENTLETOUCH_ENERGYGAIN:
case GN_CARTBOOST:
case KO_MEIKYOUSISUI:
+ case ALL_FULL_THROTTLE:
+ case RA_UNLIMIT:
+ case WL_TELEKINESIS_INTENSE:
+ case AB_OFFERTORIUM:
+ case RK_GIANTGROWTH:
+ case RK_VITALITYACTIVATION:
+ case RK_ABUNDANCE:
+ case RK_CRUSHSTRIKE:
clif->skill_nodamage(src,bl,skill_id,skill_lv,
sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)));
break;
@@ -5277,7 +5571,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case SO_STRIKING:
if (sd) {
int bonus = 25 + 10 * skill_lv;
- bonus += (pc_checkskill(sd, SA_FLAMELAUNCHER)+pc_checkskill(sd, SA_FROSTWEAPON)+pc_checkskill(sd, SA_LIGHTNINGLOADER)+pc_checkskill(sd, SA_SEISMICWEAPON))*5;
+ bonus += (pc->checkskill(sd, SA_FLAMELAUNCHER)+pc->checkskill(sd, SA_FROSTWEAPON)+pc->checkskill(sd, SA_LIGHTNINGLOADER)+pc->checkskill(sd, SA_SEISMICWEAPON))*5;
clif->skill_nodamage( src, bl, skill_id, skill_lv,
battle->check_target(src,bl,BCT_PARTY) > 0 ?
sc_start2(bl, type, 100, skill_lv, bonus, skill->get_time(skill_id,skill_lv)) :
@@ -5317,7 +5611,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case NJ_BUNSINJYUTSU:
clif->skill_nodamage(src,bl,skill_id,skill_lv,
sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)));
- status_change_end(bl, SC_NEN, INVALID_TIMER);
+ status_change_end(bl, SC_NJ_NEN, INVALID_TIMER);
break;
/* Was modified to only affect targetted char. [Skotlex]
case HP_ASSUMPTIO:
@@ -5325,7 +5619,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv));
else
{
- map_foreachinrange(skill->area_sub, bl,
+ iMap->foreachinrange(skill->area_sub, bl,
skill->get_splash(skill_id, skill_lv), BL_PC,
src, skill_id, skill_lv, tick, flag|BCT_ALL|1,
skill->castend_nodamage_id);
@@ -5342,13 +5636,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case AS_ENCHANTPOISON: // Prevent spamming [Valaris]
if (sd && dstsd && dstsd->sc.count) {
- if (dstsd->sc.data[SC_FIREWEAPON] ||
- dstsd->sc.data[SC_WATERWEAPON] ||
- dstsd->sc.data[SC_WINDWEAPON] ||
- dstsd->sc.data[SC_EARTHWEAPON] ||
- dstsd->sc.data[SC_SHADOWWEAPON] ||
- dstsd->sc.data[SC_GHOSTWEAPON]
- // dstsd->sc.data[SC_ENCPOISON] //People say you should be able to recast to lengthen the timer. [Skotlex]
+ if (dstsd->sc.data[SC_PROPERTYFIRE] ||
+ dstsd->sc.data[SC_PROPERTYWATER] ||
+ dstsd->sc.data[SC_PROPERTYWIND] ||
+ dstsd->sc.data[SC_PROPERTYGROUND] ||
+ dstsd->sc.data[SC_PROPERTYDARK] ||
+ dstsd->sc.data[SC_PROPERTYTELEKINESIS]
+ // dstsd->sc.data[SC_ENCHANTPOISON] //People say you should be able to recast to lengthen the timer. [Skotlex]
) {
clif->skill_nodamage(src,bl,skill_id,skill_lv,0);
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
@@ -5394,7 +5688,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
{
clif->skill_nodamage(src,bl,skill_id,skill_lv,
sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)));
- map_foreachinrange( status_change_timer_sub, src,
+ iMap->foreachinrange( status_change_timer_sub, src,
skill->get_splash(skill_id, skill_lv), BL_CHAR,
src,NULL,type,tick);
}
@@ -5405,7 +5699,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case MER_PROVOKE:
if( (tstatus->mode&MD_BOSS) || battle->check_undead(tstatus->race,tstatus->def_ele) )
{
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 1;
}
//TODO: How much does base level affects? Dummy value of 1% per level difference used. [Skotlex]
@@ -5415,7 +5709,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
{
if( sd )
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
unit_skillcastcancel(bl, 2);
@@ -5457,7 +5751,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
{
if( sd )
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 1;
}
@@ -5472,7 +5766,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if( i == count )
{ // No free slots, skill Fail
clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 1;
}
}
@@ -5494,7 +5788,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if( sd->sc.data[SC_RAISINGDRAGON] )
limit += sd->sc.data[SC_RAISINGDRAGON]->val1;
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- pc_addspiritball(sd,skill->get_time(skill_id,skill_lv),limit);
+ pc->addspiritball(sd,skill->get_time(skill_id,skill_lv),limit);
}
break;
@@ -5505,13 +5799,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
limit += sd->sc.data[SC_RAISINGDRAGON]->val1;
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
for (i = 0; i < limit; i++)
- pc_addspiritball(sd,skill->get_time(skill_id,skill_lv),limit);
+ pc->addspiritball(sd,skill->get_time(skill_id,skill_lv),limit);
}
break;
case MO_KITRANSLATION:
if(dstsd && (dstsd->class_&MAPID_BASEMASK)!=MAPID_GUNSLINGER) {
- pc_addspiritball(dstsd,skill->get_time(skill_id,skill_lv),5);
+ pc->addspiritball(dstsd,skill->get_time(skill_id,skill_lv),5);
}
break;
@@ -5528,7 +5822,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if (dstsd && dstsd->spiritball && (sd == dstsd || map_flag_vs(src->m)) && (dstsd->class_&MAPID_BASEMASK)!=MAPID_GUNSLINGER)
{ // split the if for readability, and included gunslingers in the check so that their coins cannot be removed [Reddozen]
i = dstsd->spiritball * 7;
- pc_delspiritball(dstsd,dstsd->spiritball,0);
+ pc->delspiritball(dstsd,dstsd->spiritball,0);
} else if (dstmd && !(tstatus->mode&MD_BOSS) && rnd() % 100 < 20)
{ // check if target is a monster and not a Boss, for the 20% chance to absorb 2 SP per monster's level [Reddozen]
i = 2 * dstmd->level;
@@ -5566,7 +5860,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case RG_RAID:
skill_area_temp[1] = 0;
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- map_foreachinrange(skill->area_sub, bl,
+ iMap->foreachinrange(skill->area_sub, bl,
skill->get_splash(skill_id, skill_lv), splash_target(src),
src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1,
skill->castend_damage_id);
@@ -5584,7 +5878,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case KO_HAPPOKUNAI:
skill_area_temp[1] = 0;
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- i = map_foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src),
+ i = iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src),
src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_damage_id);
if( !i && ( skill_id == NC_AXETORNADO || skill_id == SR_SKYNETBLOW || skill_id == KO_HAPPOKUNAI ) )
clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
@@ -5617,7 +5911,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
//Passive side of the attack.
status_change_end(src, SC_SIGHT, INVALID_TIMER);
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- map_foreachinrange(skill->area_sub,src,
+ iMap->foreachinrange(skill->area_sub,src,
skill->get_splash(skill_id, skill_lv),BL_CHAR|BL_SKILL,
src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1,
skill->castend_damage_id);
@@ -5628,7 +5922,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case WZ_FROSTNOVA:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
skill_area_temp[1] = 0;
- map_foreachinrange(skill->attack_area, src,
+ iMap->foreachinrange(skill->attack_area, src,
skill->get_splash(skill_id, skill_lv), splash_target(src),
BF_MAGIC, src, src, skill_id, skill_lv, tick, flag, BCT_ENEMY);
break;
@@ -5640,12 +5934,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
i = ((!md || md->special_state.ai == 2) && !map_flag_vs(src->m))?
BCT_ENEMY:BCT_ALL;
clif->skill_nodamage(src, src, skill_id, -1, 1);
- map_delblock(src); //Required to prevent chain-self-destructions hitting back.
- map_foreachinrange(skill->area_sub, bl,
+ iMap->delblock(src); //Required to prevent chain-self-destructions hitting back.
+ iMap->foreachinrange(skill->area_sub, bl,
skill->get_splash(skill_id, skill_lv), splash_target(src),
src, skill_id, skill_lv, tick, flag|i,
skill->castend_damage_id);
- map_addblock(src);
+ iMap->addblock(src);
status_damage(src, src, sstatus->max_hp,0,0,1);
break;
@@ -5656,6 +5950,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case CASH_BLESSING:
case CASH_INCAGI:
case CASH_ASSUMPTIO:
+ case WM_FRIGG_SONG:
if( sd == NULL || sd->status.party_id == 0 || (flag & 1) )
clif->skill_nodamage(bl, bl, skill_id, skill_lv, sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)));
else if( sd )
@@ -5704,7 +5999,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if( tsce )
{
clif->skill_nodamage(src,bl,skill_id,skill_lv,status_change_end(bl, type, INVALID_TIMER));
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)));
@@ -5715,7 +6010,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case SL_KAUPE:
if (sd) {
if (!dstsd || !(
- (sd->sc.data[SC_SPIRIT] && sd->sc.data[SC_SPIRIT]->val2 == SL_SOULLINKER) ||
+ (sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_SOULLINKER) ||
(dstsd->class_&MAPID_UPPERMASK) == MAPID_SOUL_LINKER ||
dstsd->status.char_id == sd->status.char_id ||
dstsd->status.char_id == sd->status.partner_id ||
@@ -5743,12 +6038,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if (tsce)
{
clif->skill_nodamage(src,bl,skill_id,-1,status_change_end(bl, type, INVALID_TIMER)); //Hide skill-scream animation.
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
} else if( tsc && tsc->option&OPTION_MADOGEAR ) {
//Mado Gear cannot hide
if( sd ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
clif->skill_nodamage(src,bl,skill_id,-1,sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)));
@@ -5757,7 +6052,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if (tsce)
{
clif->skill_nodamage(src,bl,skill_id,skill_lv,status_change_end(bl, type, INVALID_TIMER));
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start4(bl,type,100,skill_lv,unit_getdir(bl),0,0,0));
@@ -5775,7 +6070,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
clif->skill_nodamage(src,bl,skill_id,( skill_id == LG_FORCEOFVANGUARD ) ? skill_lv : -1,i);
else if( sd )
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
case RA_CAMOUFLAGE:
@@ -5831,7 +6126,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case TF_STEAL:
if(sd) {
- if(pc_steal_item(sd,bl,skill_lv))
+ if(pc->steal_item(sd,bl,skill_lv))
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
else
clif->skill_fail(sd,skill_id,USESKILL_FAIL,0);
@@ -5840,7 +6135,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case RG_STEALCOIN:
if(sd) {
- if(pc_steal_coin(sd,bl))
+ if(pc->steal_coin(sd,bl))
{
dstmd->state.provoke_flag = src->id;
mob_target(dstmd, src, skill->get_range2(src,skill_id,skill_lv));
@@ -5879,7 +6174,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
// Level 6-10 doesn't consume a red gem if it fails [celest]
if (skill_lv > 5)
{ // not to consume items
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
}
@@ -5939,7 +6234,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
break;
case MER_COMPRESS:
- status_change_end(bl, SC_BLEEDING, INVALID_TIMER);
+ status_change_end(bl, SC_BLOODING, INVALID_TIMER);
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
break;
case MER_MENTALCURE:
@@ -5997,23 +6292,31 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
break;
case MC_IDENTIFY:
- if(sd)
+ if(sd) {
clif->item_identify_list(sd);
+ if( sd->menuskill_id != MC_IDENTIFY ) {/* failed, dont consume anything, return */
+ iMap->freeblock_unlock();
+ return 1;
+ }
+ status_zap(src,0,skill_db[skill->get_index(skill_id)].sp[skill_lv]); // consume sp only if succeeded
+ }
break;
// Weapon Refining [Celest]
case WS_WEAPONREFINE:
- if(sd)
+ if(sd){
+ sd->state.prerefining = 1;
clif->item_refine_list(sd);
+ }
break;
case MC_VENDING:
if(sd)
{ //Prevent vending of GMs with unnecessary Level to trade/drop. [Skotlex]
- if ( !pc_can_give_items(sd) )
+ if ( !pc->can_give_items(sd) )
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
else {
- sd->state.prevend = 1;
+ sd->state.prevend = sd->state.workinprogress = 3;
clif->openvendingreq(sd,2+skill_lv);
}
}
@@ -6023,7 +6326,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if(sd)
{
if (map[bl->m].flag.noteleport && skill_lv <= 2) {
- clif->skill_teleportmessage(sd,0);
+ clif->skill_mapinfomessage(sd,0);
break;
}
if(!battle_config.duel_allow_teleport && sd->duel_group && skill_lv <= 2) { // duel restriction [LuzZza]
@@ -6035,9 +6338,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if( sd->state.autocast || ( (sd->skillitem == AL_TELEPORT || battle_config.skip_teleport_lv1_menu) && skill_lv == 1 ) || skill_lv == 3 )
{
if( skill_lv == 1 )
- pc_randomwarp(sd,CLR_TELEPORT);
+ pc->randomwarp(sd,CLR_TELEPORT);
else
- pc_setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
+ pc->setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
break;
}
@@ -6076,10 +6379,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
item_tmp.identify = 1;
tbl.id = 0;
clif->takeitem(&sd->bl,&tbl);
- eflag = pc_additem(sd,&item_tmp,1,LOG_TYPE_PRODUCE);
+ eflag = pc->additem(sd,&item_tmp,1,LOG_TYPE_PRODUCE);
if(eflag) {
clif->additem(sd,0,0,eflag);
- map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
}
break;
@@ -6146,7 +6449,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
}
//Special message when trying to use strip on FCP [Jobbie]
- if( sd && skill_id == ST_FULLSTRIP && tsc && tsc->data[SC_CP_WEAPON] && tsc->data[SC_CP_HELM] && tsc->data[SC_CP_ARMOR] && tsc->data[SC_CP_SHIELD])
+ if( sd && skill_id == ST_FULLSTRIP && tsc && tsc->data[SC_PROTECTWEAPON] && tsc->data[SC_PROTECTHELM] && tsc->data[SC_PROTECTARMOR] && tsc->data[SC_PROTECTSHIELD])
{
clif->gospel_info(sd, 0x28);
break;
@@ -6164,29 +6467,30 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case AM_BERSERKPITCHER:
case AM_POTIONPITCHER: {
- int i,hp = 0,sp = 0;
+ int i,sp = 0;
+ int64 hp = 0;
if( dstmd && dstmd->class_ == MOBID_EMPERIUM ) {
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 1;
}
if( sd ) {
- int x,bonus=100;
+ int x,bonus=100, potion = min(500+skill_lv,505);
x = skill_lv%11 - 1;
- i = pc_search_inventory(sd,skill_db[skill_id].itemid[x]);
+ i = pc->search_inventory(sd,skill_db[skill_id].itemid[x]);
if( i < 0 || skill_db[skill_id].itemid[x] <= 0 ) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 1;
}
if(sd->inventory_data[i] == NULL || sd->status.inventory[i].amount < skill_db[skill_id].amount[x]) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 1;
}
if( skill_id == AM_BERSERKPITCHER ) {
if( dstsd && dstsd->status.base_level < (unsigned int)sd->inventory_data[i]->elv ) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 1;
}
}
@@ -6195,36 +6499,39 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
potion_target = bl->id;
run_script(sd->inventory_data[i]->script,0,sd->bl.id,0);
potion_flag = potion_target = 0;
- if( sd->sc.data[SC_SPIRIT] && sd->sc.data[SC_SPIRIT]->val2 == SL_ALCHEMIST )
+ if( sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_ALCHEMIST )
bonus += sd->status.base_level;
if( potion_per_hp > 0 || potion_per_sp > 0 ) {
hp = tstatus->max_hp * potion_per_hp / 100;
- hp = hp * (100 + pc_checkskill(sd,AM_POTIONPITCHER)*10 + pc_checkskill(sd,AM_LEARNINGPOTION)*5)*bonus/10000;
+ hp = hp * (100 + pc->checkskill(sd,AM_POTIONPITCHER)*10 + pc->checkskill(sd,AM_LEARNINGPOTION)*5)*bonus/10000;
if( dstsd ) {
sp = dstsd->status.max_sp * potion_per_sp / 100;
- sp = sp * (100 + pc_checkskill(sd,AM_POTIONPITCHER)*10 + pc_checkskill(sd,AM_LEARNINGPOTION)*5)*bonus/10000;
+ sp = sp * (100 + pc->checkskill(sd,AM_POTIONPITCHER)*10 + pc->checkskill(sd,AM_LEARNINGPOTION)*5)*bonus/10000;
}
} else {
if( potion_hp > 0 ) {
- hp = potion_hp * (100 + pc_checkskill(sd,AM_POTIONPITCHER)*10 + pc_checkskill(sd,AM_LEARNINGPOTION)*5)*bonus/10000;
+ hp = potion_hp * (100 + pc->checkskill(sd,AM_POTIONPITCHER)*10 + pc->checkskill(sd,AM_LEARNINGPOTION)*5)*bonus/10000;
hp = hp * (100 + (tstatus->vit<<1)) / 100;
if( dstsd )
- hp = hp * (100 + pc_checkskill(dstsd,SM_RECOVERY)*10) / 100;
+ hp = hp * (100 + pc->checkskill(dstsd,SM_RECOVERY)*10) / 100;
}
if( potion_sp > 0 ) {
- sp = potion_sp * (100 + pc_checkskill(sd,AM_POTIONPITCHER)*10 + pc_checkskill(sd,AM_LEARNINGPOTION)*5)*bonus/10000;
+ sp = potion_sp * (100 + pc->checkskill(sd,AM_POTIONPITCHER)*10 + pc->checkskill(sd,AM_LEARNINGPOTION)*5)*bonus/10000;
sp = sp * (100 + (tstatus->int_<<1)) / 100;
if( dstsd )
- sp = sp * (100 + pc_checkskill(dstsd,MG_SRECOVERY)*10) / 100;
+ sp = sp * (100 + pc->checkskill(dstsd,MG_SRECOVERY)*10) / 100;
}
}
- if (sd->itemgrouphealrate[IG_POTION]>0) {
- hp += hp * sd->itemgrouphealrate[IG_POTION] / 100;
- sp += sp * sd->itemgrouphealrate[IG_POTION] / 100;
+ for(i = 0; i < ARRAYLENGTH(sd->itemhealrate) && sd->itemhealrate[i].nameid; i++) {
+ if (sd->itemhealrate[i].nameid == potion) {
+ hp += hp * sd->itemhealrate[i].rate / 100;
+ sp += sp * sd->itemhealrate[i].rate / 100;
+ break;
+ }
}
-
- if( (i = pc_skillheal_bonus(sd, skill_id)) ) {
+
+ if( (i = pc->skillheal_bonus(sd, skill_id)) ) {
hp += hp * i / 100;
sp += sp * i / 100;
}
@@ -6232,9 +6539,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
hp = (1 + rnd()%400) * (100 + skill_lv*10) / 100;
hp = hp * (100 + (tstatus->vit<<1)) / 100;
if( dstsd )
- hp = hp * (100 + pc_checkskill(dstsd,SM_RECOVERY)*10) / 100;
+ hp = hp * (100 + pc->checkskill(dstsd,SM_RECOVERY)*10) / 100;
}
- if( dstsd && (i = pc_skillheal2_bonus(dstsd, skill_id)) ) {
+ if( dstsd && (i = pc->skillheal2_bonus(dstsd, skill_id)) ) {
hp += hp * i / 100;
sp += sp * i / 100;
}
@@ -6254,14 +6561,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
}
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
if( hp > 0 || (skill_id == AM_POTIONPITCHER && sp <= 0) )
- clif->skill_nodamage(NULL,bl,AL_HEAL,hp,1);
+ clif->skill_nodamage(NULL,bl,AL_HEAL,(int)hp,1);
if( sp > 0 )
clif->skill_nodamage(NULL,bl,MG_SRECOVERY,sp,1);
#ifdef RENEWAL
if( tsc && tsc->data[SC_EXTREMITYFIST2] )
sp = 0;
#endif
- status_heal(bl,hp,sp,0);
+ status_heal(bl,(int)hp,sp,0);
}
break;
case AM_CP_WEAPON:
@@ -6271,9 +6578,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
{
unsigned int equip[] = {EQP_WEAPON, EQP_SHIELD, EQP_ARMOR, EQP_HEAD_TOP};
- if( sd && ( bl->type != BL_PC || ( dstsd && pc_checkequip(dstsd,equip[skill_id - AM_CP_WEAPON]) < 0 ) ) ){
+ if( sd && ( bl->type != BL_PC || ( dstsd && pc->checkequip(dstsd,equip[skill_id - AM_CP_WEAPON]) < 0 ) ) ){
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- map_freeblock_unlock(); // Don't consume item requirements
+ iMap->freeblock_unlock(); // Don't consume item requirements
return 0;
}
@@ -6299,7 +6606,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
break;
case AM_TWILIGHT3:
if (sd) {
- int ebottle = pc_search_inventory(sd,713);
+ int ebottle = pc->search_inventory(sd,713);
if( ebottle >= 0 )
ebottle = sd->status.inventory[ebottle].amount;
//check if you can produce all three, if not, then fail:
@@ -6322,9 +6629,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
{
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
if((dstsd && (dstsd->class_&MAPID_UPPERMASK) == MAPID_SOUL_LINKER)
- || (tsc && tsc->data[SC_SPIRIT] && tsc->data[SC_SPIRIT]->val2 == SL_ROGUE) //Rogue's spirit defends againt dispel.
- || rnd()%100 >= 50+10*skill_lv
- || ( tsc && tsc->option&OPTION_MADOGEAR ) )//Mado Gear is immune to dispell according to bug report 49 [Ind]
+ || (tsc && tsc->data[SC_SOULLINK] && tsc->data[SC_SOULLINK]->val2 == SL_ROGUE) //Rogue's spirit defends againt dispel.
+ || rnd()%100 >= 50+10*skill_lv )
{
if (sd)
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
@@ -6337,84 +6643,45 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
break;
}
-
- for(i=0;i<SC_MAX;i++)
+
+ for(i = 0; i < SC_MAX; i++)
{
- if (!tsc->data[i])
- continue;
- switch (i) {
- case SC_WEIGHT50: case SC_WEIGHT90: case SC_HALLUCINATION:
- case SC_STRIPWEAPON: case SC_STRIPSHIELD: case SC_STRIPARMOR:
- case SC_STRIPHELM: case SC_CP_WEAPON: case SC_CP_SHIELD:
- case SC_CP_ARMOR: case SC_CP_HELM: case SC_COMBO:
- case SC_STRFOOD: case SC_AGIFOOD: case SC_VITFOOD:
- case SC_INTFOOD: case SC_DEXFOOD: case SC_LUKFOOD:
- case SC_HITFOOD: case SC_FLEEFOOD: case SC_BATKFOOD:
- case SC_WATKFOOD: case SC_MATKFOOD: case SC_DANCING:
- case SC_EDP: case SC_AUTOBERSERK:
- case SC_CARTBOOST: case SC_MELTDOWN: case SC_SAFETYWALL:
- case SC_SMA: case SC_SPEEDUP0: case SC_NOCHAT:
- case SC_ANKLE: case SC_SPIDERWEB: case SC_JAILED:
- case SC_ITEMBOOST: case SC_EXPBOOST: case SC_LIFEINSURANCE:
- case SC_BOSSMAPINFO: case SC_PNEUMA: case SC_AUTOSPELL:
- case SC_INCHITRATE: case SC_INCATKRATE: case SC_NEN:
- case SC_READYSTORM: case SC_READYDOWN: case SC_READYTURN:
- case SC_READYCOUNTER: case SC_DODGE: case SC_WARM:
- case SC_SPEEDUP1: case SC_AUTOTRADE: case SC_CRITICALWOUND:
- case SC_JEXPBOOST: case SC_INVINCIBLE: case SC_INVINCIBLEOFF:
- case SC_HELLPOWER: case SC_MANU_ATK: case SC_MANU_DEF:
- case SC_SPL_ATK: case SC_SPL_DEF: case SC_MANU_MATK:
- case SC_SPL_MATK: case SC_RICHMANKIM: case SC_ETERNALCHAOS:
- case SC_DRUMBATTLE: case SC_NIBELUNGEN: case SC_ROKISWEIL:
- case SC_INTOABYSS: case SC_SIEGFRIED: case SC_FOOD_STR_CASH:
- case SC_FOOD_AGI_CASH: case SC_FOOD_VIT_CASH: case SC_FOOD_DEX_CASH:
- case SC_FOOD_INT_CASH: case SC_FOOD_LUK_CASH: case SC_SEVENWIND:
- case SC_MIRACLE: case SC_S_LIFEPOTION: case SC_L_LIFEPOTION:
- case SC_INCHEALRATE: case SC_ELECTRICSHOCKER: case SC__STRIPACCESSORY:
- //case SC_SAVAGE_STEAK: case SC_COCKTAIL_WARG_BLOOD: case SC_MINOR_BBQ:
- //case SC_SIROMA_ICE_TEA: case SC_DROCERA_HERB_STEAMED: case SC_PUTTI_TAILS_NOODLES:
- case SC_NEUTRALBARRIER_MASTER: case SC_NEUTRALBARRIER: case SC_STEALTHFIELD_MASTER:
- case SC_STEALTHFIELD: case SC_GIANTGROWTH: case SC_MILLENNIUMSHIELD:
- case SC_REFRESH: case SC_STONEHARDSKIN: case SC_VITALITYACTIVATION:
- case SC_FIGHTINGSPIRIT: case SC_ABUNDANCE: case SC__SHADOWFORM:
- case SC_LEADERSHIP: case SC_GLORYWOUNDS: case SC_SOULCOLD:
- case SC_HAWKEYES: case SC_GUILDAURA: case SC_PUSH_CART:
- case SC_RAISINGDRAGON: case SC_GT_ENERGYGAIN: case SC_GT_CHANGE:
- case SC_GT_REVITALIZE: case SC_REFLECTDAMAGE: case SC_INSPIRATION:
- case SC_EXEEDBREAK: case SC_FORCEOFVANGUARD: case SC_BANDING:
- case SC_DUPLELIGHT: case SC_EXPIATIO: case SC_LAUDAAGNUS:
- case SC_LAUDARAMUS: case SC_GATLINGFEVER: case SC_INCREASING:
- case SC_ADJUSTMENT: case SC_MADNESSCANCEL: case SC_ALL_RIDING:
- #ifdef RENEWAL
- case SC_EXTREMITYFIST2:
- #endif
- continue;
- /**
- * bugreport:4888 these songs may only be dispelled if you're not in their song area anymore
- **/
- case SC_WHISTLE:
- case SC_ASSNCROS:
- case SC_POEMBRAGI:
- case SC_APPLEIDUN:
- case SC_HUMMING:
- case SC_DONTFORGETME:
- case SC_FORTUNE:
- case SC_SERVICE4U:
- if( !tsc->data[i]->val4 ) //val4 = out-of-song-area
+ if ( !tsc->data[i] )
continue;
- break;
- case SC_ASSUMPTIO:
- if( bl->type == BL_MOB )
+ if( SC_COMMON_MAX < i ){
+ if ( status_get_sc_type(i)&SC_NO_DISPELL )
continue;
- break;
}
- if(i==SC_BERSERK || i==SC_SATURDAYNIGHTFEVER) tsc->data[i]->val2=0; //Mark a dispelled berserk to avoid setting hp to 100 by setting hp penalty to 0.
+ switch (i) {
+ /**
+ * bugreport:4888 these songs may only be dispelled if you're not in their song area anymore
+ **/
+ case SC_WHISTLE:
+ case SC_ASSNCROS:
+ case SC_POEMBRAGI:
+ case SC_APPLEIDUN:
+ case SC_HUMMING:
+ case SC_DONTFORGETME:
+ case SC_FORTUNE:
+ case SC_SERVICEFORYOU:
+ if( tsc->data[i]->val4 ) //val4 = out-of-song-area
+ continue;
+ break;
+ case SC_ASSUMPTIO:
+ if( bl->type == BL_MOB )
+ continue;
+ break;
+ case SC_BERSERK:
+ case SC_SATURDAY_NIGHT_FEVER:
+ tsc->data[i]->val2=0; //Mark a dispelled berserk to avoid setting hp to 100 by setting hp penalty to 0.
+ break;
+ }
status_change_end(bl, (sc_type)i, INVALID_TIMER);
}
break;
}
//Affect all targets on splash area.
- map_foreachinrange(skill->area_sub, bl, i, BL_CHAR,
+ iMap->foreachinrange(skill->area_sub, bl, i, BL_CHAR,
src, skill_id, skill_lv, tick, flag|1,
skill->castend_damage_id);
break;
@@ -6440,7 +6707,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
}
clif->skill_nodamage(src,bl,TK_HIGHJUMP,skill_lv,1);
- if(!map_count_oncell(src->m,x,y,BL_PC|BL_NPC|BL_MOB) && map_getcell(src->m,x,y,CELL_CHKREACH)) {
+ if(!iMap->count_oncell(src->m,x,y,BL_PC|BL_NPC|BL_MOB) && iMap->getcell(src->m,x,y,CELL_CHKREACH)) {
clif->slide(src,x,y);
unit_movepos(src, x, y, 1, 0);
}
@@ -6520,7 +6787,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
static const int spellarray[3] = { MG_COLDBOLT,MG_FIREBOLT,MG_LIGHTNINGBOLT };
if(skill_lv >= 10) {
spellid = MG_FROSTDIVER;
- // if (tsc && tsc->data[SC_SPIRIT] && tsc->data[SC_SPIRIT]->val2 == SA_SAGE)
+ // if (tsc && tsc->data[SC_SOULLINK] && tsc->data[SC_SOULLINK]->val2 == SA_SAGE)
// maxlv = 10;
// else
maxlv = skill_lv - 9;
@@ -6551,7 +6818,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case BS_GREED:
if(sd){
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- map_foreachinrange(skill->greed,bl,
+ iMap->foreachinrange(skill->greed,bl,
skill->get_splash(skill_id, skill_lv),BL_ITEM,bl);
}
break;
@@ -6648,9 +6915,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case NPC_SPEEDUP:
{
// or does it increase casting rate? just a guess xD
- int i = SC_ASPDPOTION0 + skill_lv - 1;
- if (i > SC_ASPDPOTION3)
- i = SC_ASPDPOTION3;
+ int i = SC_ATTHASTE_POTION1 + skill_lv - 1;
+ if (i > SC_ATTHASTE_INFINITY)
+ i = SC_ATTHASTE_INFINITY;
clif->skill_nodamage(src,bl,skill_id,skill_lv,
sc_start(bl,(sc_type)i,100,skill_lv,skill_lv * 60000));
}
@@ -6660,7 +6927,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
// not really needed... but adding here anyway ^^
if (md && md->master_id > 0) {
struct block_list *mbl, *tbl;
- if ((mbl = map_id2bl(md->master_id)) == NULL ||
+ if ((mbl = iMap->id2bl(md->master_id)) == NULL ||
(tbl = battle->get_targeted(mbl)) == NULL)
break;
md->state.provoke_flag = tbl->id;
@@ -6671,7 +6938,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case NPC_RUN:
{
const int mask[8][2] = {{0,-1},{1,-1},{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1}};
- uint8 dir = (bl == src)?unit_getdir(src):map_calc_dir(src,bl->x,bl->y); //If cast on self, run forward, else run away.
+ uint8 dir = (bl == src)?unit_getdir(src):iMap->calc_dir(src,bl->x,bl->y); //If cast on self, run forward, else run away.
unit_stop_attack(src);
//Run skillv tiles overriding the can-move check.
if (unit_walktoxy(src, src->x + skill_lv * mask[dir][0], src->y + skill_lv * mask[dir][1], 2) && md)
@@ -6722,7 +6989,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
break;
case NPC_AGIUP:
- sc_start(bl,SC_SPEEDUP1,100,skill_lv,skill->get_time(skill_id, skill_lv));
+ sc_start(bl,SC_MOVHASTE_INFINITY,100,skill_lv,skill->get_time(skill_id, skill_lv));
clif->skill_nodamage(src,bl,skill_id,skill_lv,
sc_start(bl,type,100,100,skill->get_time(skill_id, skill_lv)));
break;
@@ -6756,12 +7023,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
// parent-baby skills
case WE_BABY:
if(sd){
- struct map_session_data *f_sd = pc_get_father(sd);
- struct map_session_data *m_sd = pc_get_mother(sd);
+ struct map_session_data *f_sd = pc->get_father(sd);
+ struct map_session_data *m_sd = pc->get_mother(sd);
// if neither was found
if(!f_sd && !m_sd){
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
status_change_start(bl,SC_STUN,10000,skill_lv,0,0,0,skill->get_time2(skill_id,skill_lv),8);
@@ -6809,10 +7076,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
memset(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid = skill_db[su->group->skill_id].itemid[i];
item_tmp.identify = 1;
- if( item_tmp.nameid && (flag=pc_additem(sd,&item_tmp,skill_db[su->group->skill_id].amount[i],LOG_TYPE_OTHER)) )
+ if( item_tmp.nameid && (flag=pc->additem(sd,&item_tmp,skill_db[su->group->skill_id].amount[i],LOG_TYPE_OTHER)) )
{
clif->additem(sd,0,0,flag);
- map_addflooritem(&item_tmp,skill_db[su->group->skill_id].amount[i],sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ iMap->addflooritem(&item_tmp,skill_db[su->group->skill_id].amount[i],sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
}
}
@@ -6823,10 +7090,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
memset(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid = su->group->item_id?su->group->item_id:ITEMID_TRAP;
item_tmp.identify = 1;
- if( item_tmp.nameid && (flag=pc_additem(sd,&item_tmp,1,LOG_TYPE_OTHER)) )
+ if( item_tmp.nameid && (flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_OTHER)) )
{
clif->additem(sd,0,0,flag);
- map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
}
}
@@ -6881,7 +7148,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
#endif
) {
if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 1;
}
clif->skill_nodamage(src,bl,skill_id,skill_lv,
@@ -6894,14 +7161,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case PF_MINDBREAKER:
{
if(tstatus->mode&MD_BOSS || battle->check_undead(tstatus->race,tstatus->def_ele) ) {
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 1;
}
if (tsce)
{ //HelloKitty2 (?) explained that this silently fails when target is
//already inflicted. [Skotlex]
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 1;
}
@@ -6910,7 +7177,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
sc_start(bl,type,55+5*skill_lv,skill_lv,skill->get_time(skill_id,skill_lv))))
{
if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
@@ -6967,9 +7234,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
sp = sp * (100 + (tstatus->int_<<1))/100;
if (dstsd) {
if (hp)
- hp = hp * (100 + pc_checkskill(dstsd,SM_RECOVERY)*10 + pc_skillheal2_bonus(dstsd, skill_id))/100;
+ hp = hp * (100 + pc->checkskill(dstsd,SM_RECOVERY)*10 + pc->skillheal2_bonus(dstsd, skill_id))/100;
if (sp)
- sp = sp * (100 + pc_checkskill(dstsd,MG_SRECOVERY)*10 + pc_skillheal2_bonus(dstsd, skill_id))/100;
+ sp = sp * (100 + pc->checkskill(dstsd,MG_SRECOVERY)*10 + pc->skillheal2_bonus(dstsd, skill_id))/100;
}
if( tsc && tsc->count ) {
if (tsc->data[SC_CRITICALWOUND]) {
@@ -6999,14 +7266,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
int i, s = 0, skilltime = skill->get_time(skill_id,skill_lv);
for (i=0 ; i<4; i++) {
- if( bl->type != BL_PC || ( dstsd && pc_checkequip(dstsd,equip[i]) < 0 ) )
+ if( bl->type != BL_PC || ( dstsd && pc->checkequip(dstsd,equip[i]) < 0 ) )
continue;
- sc_start(bl,(sc_type)(SC_CP_WEAPON + i),100,skill_lv,skilltime);
+ sc_start(bl,(sc_type)(SC_PROTECTWEAPON + i),100,skill_lv,skilltime);
s++;
}
if( sd && !s ){
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- map_freeblock_unlock(); // Don't consume item requirements
+ iMap->freeblock_unlock(); // Don't consume item requirements
return 0;
}
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
@@ -7031,18 +7298,25 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case CG_TAROTCARD:
{
int eff, count = -1;
+ if( tsc && tsc->data[type] ){
+ iMap->freeblock_unlock();
+ return 0;
+ }
if( rnd() % 100 > skill_lv * 8 || (dstmd && ((dstmd->guardian_data && dstmd->class_ == MOBID_EMPERIUM) || mob_is_battleground(dstmd))) )
{
if( sd )
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
status_zap(src,0,skill_db[skill->get_index(skill_id)].sp[skill_lv]); // consume sp only if succeeded [Inkfish]
do {
eff = rnd() % 14;
- clif->specialeffect(bl, 523 + eff, AREA);
+ if( eff == 5 )
+ clif->specialeffect(src, 528, AREA);
+ else
+ clif->specialeffect(bl, 523 + eff, AREA);
switch (eff)
{
case 0: // heals SP to 0
@@ -7112,6 +7386,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
sc_start(bl,SC_INCHITRATE,100,-20,skill->get_time2(skill_id,skill_lv));
sc_start(bl,SC_INCFLEERATE,100,-20,skill->get_time2(skill_id,skill_lv));
sc_start(bl,SC_INCDEFRATE,100,-20,skill->get_time2(skill_id,skill_lv));
+ sc_start(bl,type,100,skill_lv,skill->get_time2(skill_id,skill_lv));
break;
default:
break;
@@ -7136,7 +7411,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case SL_STAR:
case SL_SUPERNOVICE:
case SL_WIZARD:
- //NOTE: here, 'type' has the value of the associated MAPID, not of the SC_SPIRIT constant.
+ //NOTE: here, 'type' has the value of the associated MAPID, not of the SC_SOULLINK constant.
if (sd && !(dstsd && (dstsd->class_&MAPID_UPPERMASK) == type)) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
break;
@@ -7146,11 +7421,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
dstsd->die_counter = 0;
pc_setglobalreg(dstsd,"PC_DIE_COUNTER", 0);
clif->specialeffect(bl, 0x152, AREA);
- //SC_SPIRIT invokes status_calc_pc for us.
+ //SC_SOULLINK invokes status_calc_pc for us.
}
clif->skill_nodamage(src,bl,skill_id,skill_lv,
- sc_start4(bl,SC_SPIRIT,100,skill_lv,skill_id,0,0,skill->get_time(skill_id,skill_lv)));
- sc_start(src,SC_SMA,100,skill_lv,skill->get_time(SL_SMA,skill_lv));
+ sc_start4(bl,SC_SOULLINK,100,skill_lv,skill_id,0,0,skill->get_time(skill_id,skill_lv)));
+ sc_start(src,SC_SMA_READY,100,skill_lv,skill->get_time(SL_SMA,skill_lv));
break;
case SL_HIGH:
if (sd && !(dstsd && (dstsd->class_&JOBL_UPPER) && !(dstsd->class_&JOBL_2) && dstsd->status.base_level < 70)) {
@@ -7159,7 +7434,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
}
clif->skill_nodamage(src,bl,skill_id,skill_lv,
sc_start4(bl,type,100,skill_lv,skill_id,0,0,skill->get_time(skill_id,skill_lv)));
- sc_start(src,SC_SMA,100,skill_lv,skill->get_time(SL_SMA,skill_lv));
+ sc_start(src,SC_SMA_READY,100,skill_lv,skill->get_time(SL_SMA,skill_lv));
break;
case SL_SWOO:
@@ -7179,7 +7454,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
}
clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)));
if (skill_id == SL_SKE)
- sc_start(src,SC_SMA,100,skill_lv,skill->get_time(SL_SMA,skill_lv));
+ sc_start(src,SC_SMA_READY,100,skill_lv,skill->get_time(SL_SMA,skill_lv));
break;
// New guild skills [Celest]
@@ -7189,7 +7464,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
sc_start(bl,type,100,skill_lv,skill->get_time(skill_id, skill_lv));
} else if (status_get_guild_id(src)) {
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- map_foreachinrange(skill->area_sub, src,
+ iMap->foreachinrange(skill->area_sub, src,
skill->get_splash(skill_id, skill_lv), BL_PC,
src,skill_id,skill_lv,tick, flag|BCT_GUILD|1,
skill->castend_nodamage_id);
@@ -7203,7 +7478,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
sc_start(bl,type,100,skill_lv,skill->get_time(skill_id, skill_lv));
} else if (status_get_guild_id(src)) {
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- map_foreachinrange(skill->area_sub, src,
+ iMap->foreachinrange(skill->area_sub, src,
skill->get_splash(skill_id, skill_lv), BL_PC,
src,skill_id,skill_lv,tick, flag|BCT_GUILD|1,
skill->castend_nodamage_id);
@@ -7217,7 +7492,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
clif->skill_nodamage(src,bl,AL_HEAL,status_percent_heal(bl,90,90),1);
} else if (status_get_guild_id(src)) {
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- map_foreachinrange(skill->area_sub, src,
+ iMap->foreachinrange(skill->area_sub, src,
skill->get_splash(skill_id, skill_lv), BL_PC,
src,skill_id,skill_lv,tick, flag|BCT_GUILD|1,
skill->castend_nodamage_id);
@@ -7241,9 +7516,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if ((dstsd = g->member[i].sd) != NULL && sd != dstsd && !dstsd->state.autotrade && !pc_isdead(dstsd)) {
if (map[dstsd->bl.m].flag.nowarp && !map_flag_gvg2(dstsd->bl.m))
continue;
- if(map_getcell(src->m,src->x+dx[j],src->y+dy[j],CELL_CHKNOREACH))
+ if(iMap->getcell(src->m,src->x+dx[j],src->y+dy[j],CELL_CHKNOREACH))
dx[j] = dy[j] = 0;
- pc_setpos(dstsd, map_id2index(src->m), src->x+dx[j], src->y+dy[j], CLR_RESPAWN);
+ pc->setpos(dstsd, map_id2index(src->m), src->x+dx[j], src->y+dy[j], CLR_RESPAWN);
}
}
if (sd)
@@ -7264,7 +7539,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case SG_HATE:
if (sd) {
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- if (!pc_set_hate_mob(sd, skill_lv-1, bl))
+ if (!pc->set_hate_mob(sd, skill_lv-1, bl))
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
}
break;
@@ -7273,9 +7548,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if(sd) {
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
if(rnd()%100 < (20+10*skill_lv))
- pc_addspiritball(sd,skill->get_time(skill_id,skill_lv),10);
+ pc->addspiritball(sd,skill->get_time(skill_id,skill_lv),10);
else if(sd->spiritball > 0)
- pc_delspiritball(sd,1,0);
+ pc->delspiritball(sd,1,0);
}
break;
@@ -7323,7 +7598,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
}
//TODO: Shouldn't also players and the like switch targets?
- map_foreachinrange(skill->chastle_mob_changetarget,src,
+ iMap->foreachinrange(skill->chastle_mob_changetarget,src,
AREA_SIZE, BL_MOB, bl, src);
}
}
@@ -7343,7 +7618,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
else if(r<per[i][1]) //Master
bl = battle->get_master(src);
else //Enemy
- bl = map_id2bl(battle->get_target(src));
+ bl = iMap->id2bl(battle->get_target(src));
if (!bl) bl = src;
i = skill->calc_heal(src, bl, skill_id, 1+rnd()%skill_lv, true);
@@ -7368,7 +7643,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case NPC_DRAGONFEAR:
if (flag&1) {
- const enum sc_type sc[] = { SC_STUN, SC_SILENCE, SC_CONFUSION, SC_BLEEDING };
+ const enum sc_type sc[] = { SC_STUN, SC_SILENCE, SC_CONFUSION, SC_BLOODING };
int j;
j = i = rnd()%ARRAYLENGTH(sc);
while ( !sc_start2(bl,sc[i],100,skill_lv,src->id,skill->get_time2(skill_id,i+1)) ) {
@@ -7395,7 +7670,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
else {
skill_area_temp[2] = 0; //For SD_PREAMBLE
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- map_foreachinrange(skill->area_sub, bl,
+ iMap->foreachinrange(skill->area_sub, bl,
skill->get_splash(skill_id, skill_lv),BL_CHAR,
src,skill_id,skill_lv,tick, flag|BCT_ENEMY|SD_PREAMBLE|1,
skill->castend_nodamage_id);
@@ -7407,7 +7682,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
else {
skill_area_temp[2] = 0; //For SD_PREAMBLE
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- map_foreachinrange(skill->area_sub, bl,
+ iMap->foreachinrange(skill->area_sub, bl,
skill->get_splash(skill_id, skill_lv),BL_CHAR,
src,skill_id,skill_lv,tick, flag|BCT_ENEMY|SD_PREAMBLE|1,
skill->castend_nodamage_id);
@@ -7447,7 +7722,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
{
skill_area_temp[2] = 0;
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- map_foreachinrange(skill->area_sub, src,
+ iMap->foreachinrange(skill->area_sub, src,
skill->get_splash(skill_id,skill_lv),BL_CHAR,
src,skill_id,skill_lv,tick,flag|BCT_ENEMY|SD_PREAMBLE|1,
skill->castend_nodamage_id);
@@ -7459,13 +7734,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
i = skill->get_splash(skill_id,skill_lv);
if( skill_id == LG_EARTHDRIVE ) {
int dummy = 1;
- map_foreachinarea(skill->cell_overlap, src->m, src->x-i, src->y-i, src->x+i, src->y+i, BL_SKILL, LG_EARTHDRIVE, &dummy, src);
+ iMap->foreachinarea(skill->cell_overlap, src->m, src->x-i, src->y-i, src->x+i, src->y+i, BL_SKILL, LG_EARTHDRIVE, &dummy, src);
}
- map_foreachinrange(skill->area_sub, bl,i,BL_CHAR,
+ iMap->foreachinrange(skill->area_sub, bl,i,BL_CHAR,
src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
break;
case RK_STONEHARDSKIN:
- if( sd && pc_checkskill(sd,RK_RUNEMASTERY) >= 4 )
+ if( sd )
{
int heal = sstatus->hp / 4; // 25% HP
if( status_charge(bl,heal,0) )
@@ -7475,7 +7750,6 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
}
break;
case RK_REFRESH:
- if( sd && pc_checkskill(sd,RK_RUNEMASTERY) >= 8 )
{
int heal = status_get_max_hp(bl) * 25 / 100;
clif->skill_nodamage(src,bl,skill_id,skill_lv,
@@ -7486,8 +7760,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
break;
case RK_MILLENNIUMSHIELD:
- if( sd && pc_checkskill(sd,RK_RUNEMASTERY) >= 9 )
- {
+ if( sd ){
short shields = (rnd()%100<50) ? 4 : ((rnd()%100<80) ? 3 : 2);
sc_start4(bl,type,100,skill_lv,shields,1000,0,skill->get_time(skill_id,skill_lv));
clif->millenniumshield(sd,shields);
@@ -7495,31 +7768,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
}
break;
- case RK_GIANTGROWTH:
- case RK_VITALITYACTIVATION:
- case RK_ABUNDANCE:
- case RK_CRUSHSTRIKE:
- if( sd )
- {
- int lv = 1; // RK_GIANTGROWTH
- if( skill_id == RK_VITALITYACTIVATION )
- lv = 2;
- else if( skill_id == RK_ABUNDANCE )
- lv = 6;
- else if( skill_id == RK_CRUSHSTRIKE )
- lv = 7;
- if( pc_checkskill(sd,RK_RUNEMASTERY) >= lv )
- clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)));
- }
- break;
-
case RK_FIGHTINGSPIRIT:
if( flag&1 ) {
if( src == bl )
- sc_start2(bl,type,100,skill_area_temp[5],10*(sd?pc_checkskill(sd,RK_RUNEMASTERY):10),skill->get_time(skill_id,skill_lv));
+ sc_start2(bl,type,100,skill_area_temp[5],10*(sd?pc->checkskill(sd,RK_RUNEMASTERY):10),skill->get_time(skill_id,skill_lv));
else
sc_start(bl,type,100,skill_area_temp[5]/4,skill->get_time(skill_id,skill_lv));
- } else if( sd && pc_checkskill(sd,RK_RUNEMASTERY) >= 5 ) {
+ } else if( sd ) {
if( sd->status.party_id ) {
i = party_foreachsamemap(skill->area_sub,sd,skill->get_splash(skill_id,skill_lv),src,skill_id,skill_lv,tick,BCT_PARTY,skill->area_sub_count);
skill_area_temp[5] = 7 * i; // ATK
@@ -7536,7 +7791,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
{
short count = 1;
skill_area_temp[2] = 0;
- map_foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|SD_PREAMBLE|SD_SPLASH|1,skill->castend_damage_id);
+ iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|SD_PREAMBLE|SD_SPLASH|1,skill->castend_damage_id);
if( tsc && tsc->data[SC_ROLLINGCUTTER] )
{ // Every time the skill is casted the status change is reseted adding a counter.
count += (short)tsc->data[SC_ROLLINGCUTTER]->val1;
@@ -7590,7 +7845,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case GC_PHANTOMMENACE:
clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- map_foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,
+ iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,
src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
break;
@@ -7622,8 +7877,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case AB_CLEMENTIA:
case AB_CANTO:
{
- int bless_lv = pc_checkskill(sd,AL_BLESSING) + (sd->status.job_level / 10);
- int agi_lv = pc_checkskill(sd,AL_INCAGI) + (sd->status.job_level / 10);
+ int bless_lv = pc->checkskill(sd,AL_BLESSING) + (sd->status.job_level / 10);
+ int agi_lv = pc->checkskill(sd,AL_INCAGI) + (sd->status.job_level / 10);
if( sd == NULL || sd->status.party_id == 0 || flag&1 )
clif->skill_nodamage(bl, bl, skill_id, skill_lv, sc_start(bl,type,100,
(skill_id == AB_CLEMENTIA)? bless_lv : (skill_id == AB_CANTO)? agi_lv : skill_lv, skill->get_time(skill_id,skill_lv)));
@@ -7642,7 +7897,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case AB_CHEAL:
if( sd == NULL || sd->status.party_id == 0 || flag&1 ) {
if( sd && tstatus && !battle->check_undead(tstatus->race, tstatus->def_ele) ) {
- i = skill->calc_heal(src, bl, AL_HEAL, pc_checkskill(sd, AL_HEAL), true);
+ i = skill->calc_heal(src, bl, AL_HEAL, pc->checkskill(sd, AL_HEAL), true);
if( (dstsd && pc_ismadogear(dstsd)) || status_isimmune(bl))
i = 0; // Should heal by 0 or won't do anything?? in iRO it breaks the healing to members.. [malufett]
@@ -7662,7 +7917,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
sc_start(bl, type, 40 + 5 * skill_lv, skill_lv, skill->get_time(skill_id, skill_lv));
else
{
- map_foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_CHAR,
+ iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_CHAR,
src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id);
clif->skill_nodamage(src, bl, skill_id, skill_lv, 1);
}
@@ -7671,14 +7926,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case AB_LAUDAAGNUS:
if( flag&1 || sd == NULL ) {
if( tsc && (tsc->data[SC_FREEZE] || tsc->data[SC_STONE] || tsc->data[SC_BLIND] ||
- tsc->data[SC_BURNING] || tsc->data[SC_FREEZING] || tsc->data[SC_CRYSTALIZE])) {
+ tsc->data[SC_BURNING] || tsc->data[SC_FROSTMISTY] || tsc->data[SC_CRYSTALIZE])) {
// Success Chance: (40 + 10 * Skill Level) %
if( rnd()%100 > 40+10*skill_lv ) break;
status_change_end(bl, SC_FREEZE, INVALID_TIMER);
status_change_end(bl, SC_STONE, INVALID_TIMER);
status_change_end(bl, SC_BLIND, INVALID_TIMER);
status_change_end(bl, SC_BURNING, INVALID_TIMER);
- status_change_end(bl, SC_FREEZING, INVALID_TIMER);
+ status_change_end(bl, SC_FROSTMISTY, INVALID_TIMER);
status_change_end(bl, SC_CRYSTALIZE, INVALID_TIMER);
}else //Success rate only applies to the curing effect and not stat bonus. Bonus status only applies to non infected targets
clif->skill_nodamage(bl, bl, skill_id, skill_lv,
@@ -7717,71 +7972,33 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
}
if(status_isimmune(bl) || !tsc || !tsc->count)
break;
- for(i=0;i<SC_MAX;i++)
+ for(i = 0; i < SC_MAX; i++)
{
- if (!tsc->data[i])
- continue;
- switch (i) {
- case SC_WEIGHT50: case SC_WEIGHT90: case SC_HALLUCINATION:
- case SC_STRIPWEAPON: case SC_STRIPSHIELD: case SC_STRIPARMOR:
- case SC_STRIPHELM: case SC_CP_WEAPON: case SC_CP_SHIELD:
- case SC_CP_ARMOR: case SC_CP_HELM: case SC_COMBO:
- case SC_STRFOOD: case SC_AGIFOOD: case SC_VITFOOD:
- case SC_INTFOOD: case SC_DEXFOOD: case SC_LUKFOOD:
- case SC_HITFOOD: case SC_FLEEFOOD: case SC_BATKFOOD:
- case SC_WATKFOOD: case SC_MATKFOOD: case SC_DANCING:
- case SC_SPIRIT: case SC_AUTOBERSERK:
- case SC_CARTBOOST: case SC_MELTDOWN: case SC_SAFETYWALL:
- case SC_SMA: case SC_SPEEDUP0: case SC_NOCHAT:
- case SC_ANKLE: case SC_SPIDERWEB: case SC_JAILED:
- case SC_ITEMBOOST: case SC_EXPBOOST: case SC_LIFEINSURANCE:
- case SC_BOSSMAPINFO: case SC_PNEUMA: case SC_AUTOSPELL:
- case SC_INCHITRATE: case SC_INCATKRATE: case SC_NEN:
- case SC_READYSTORM: case SC_READYDOWN: case SC_READYTURN:
- case SC_READYCOUNTER:case SC_DODGE: case SC_WARM:
- case SC_SPEEDUP1: case SC_AUTOTRADE: case SC_CRITICALWOUND:
- case SC_JEXPBOOST: case SC_INVINCIBLE: case SC_INVINCIBLEOFF:
- case SC_HELLPOWER: case SC_MANU_ATK: case SC_MANU_DEF:
- case SC_SPL_ATK: case SC_SPL_DEF: case SC_MANU_MATK:
- case SC_SPL_MATK: case SC_RICHMANKIM: case SC_ETERNALCHAOS:
- case SC_DRUMBATTLE: case SC_NIBELUNGEN: case SC_ROKISWEIL:
- case SC_INTOABYSS: case SC_SIEGFRIED: case SC_WHISTLE:
- case SC_ASSNCROS: case SC_POEMBRAGI: case SC_APPLEIDUN:
- case SC_HUMMING: case SC_DONTFORGETME: case SC_FORTUNE:
- case SC_SERVICE4U: case SC_FOOD_STR_CASH: case SC_FOOD_AGI_CASH:
- case SC_FOOD_VIT_CASH: case SC_FOOD_DEX_CASH: case SC_FOOD_INT_CASH:
- case SC_FOOD_LUK_CASH: case SC_ELECTRICSHOCKER: case SC_BITE:
- case SC__STRIPACCESSORY: case SC__ENERVATION: case SC__GROOMY:
- case SC__IGNORANCE: case SC__LAZINESS: case SC__UNLUCKY:
- case SC__WEAKNESS: //case SC_SAVAGE_STEAK: case SC_COCKTAIL_WARG_BLOOD:
- case SC_MAGNETICFIELD://case SC_MINOR_BBQ: case SC_SIROMA_ICE_TEA:
- //case SC_DROCERA_HERB_STEAMED: case SC_PUTTI_TAILS_NOODLES:
- case SC_NEUTRALBARRIER_MASTER: case SC_NEUTRALBARRIER:
- case SC_STEALTHFIELD_MASTER: case SC_STEALTHFIELD:
- case SC_LEADERSHIP: case SC_GLORYWOUNDS: case SC_SOULCOLD:
- case SC_HAWKEYES: case SC_GUILDAURA: case SC_PUSH_CART:
- case SC_PARTYFLEE: case SC_GT_REVITALIZE:
- case SC_RAISINGDRAGON: case SC_GT_ENERGYGAIN: case SC_GT_CHANGE:
- #ifdef RENEWAL
- case SC_EXTREMITYFIST2:
- #endif
+ if ( !tsc->data[i] )
continue;
- case SC_ASSUMPTIO:
- if( bl->type == BL_MOB )
+ if( SC_COMMON_MAX > i )
+ if ( status_get_sc_type(i)&SC_NO_CLEARANCE )
continue;
- break;
+ switch (i) {
+ case SC_ASSUMPTIO:
+ if( bl->type == BL_MOB )
+ continue;
+ break;
+ case SC_BERSERK:
+ case SC_SATURDAY_NIGHT_FEVER:
+ tsc->data[i]->val2=0; //Mark a dispelled berserk to avoid setting hp to 100 by setting hp penalty to 0.
+ break;
}
- if(i==SC_BERSERK || i==SC_SATURDAYNIGHTFEVER) tsc->data[i]->val2=0; //Mark a dispelled berserk to avoid setting hp to 100 by setting hp penalty to 0.
status_change_end(bl,(sc_type)i,INVALID_TIMER);
}
break;
}
- map_foreachinrange(skill->area_sub, bl, i, BL_CHAR, src, skill_id, skill_lv, tick, flag|1, skill->castend_damage_id);
+ iMap->foreachinrange(skill->area_sub, bl, i, BL_CHAR, src, skill_id, skill_lv, tick, flag|1, skill->castend_damage_id);
break;
case AB_SILENTIUM:
// Should the level of Lex Divina be equivalent to the level of Silentium or should the highest level learned be used? [LimitLine]
- map_foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_CHAR,
+ iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id, skill_lv), BL_CHAR,
src, PR_LEXDIVINA, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id);
clif->skill_nodamage(src, bl, skill_id, skill_lv, 1);
break;
@@ -7793,7 +8010,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv));
else
{
- map_foreachinrange(skill->area_sub,src,skill->get_splash(skill_id, skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,(map_flag_vs(src->m)?BCT_ALL:BCT_ENEMY|BCT_SELF)|flag|1,skill->castend_nodamage_id);
+ iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id, skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,(map_flag_vs(src->m)?BCT_ALL:BCT_ENEMY|BCT_SELF)|flag|1,skill->castend_nodamage_id);
clif->skill_nodamage(src, bl, skill_id, skill_lv, 1);
}
break;
@@ -7813,7 +8030,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if( !(tsc && tsc->data[type]) ){
i = sc_start2(bl,type,rate,skill_lv,src->id,(src == bl)?5000:(bl->type == BL_PC)?skill->get_time(skill_id,skill_lv):skill->get_time2(skill_id, skill_lv));
clif->skill_nodamage(src,bl,skill_id,skill_lv,i);
- if( !i )
+ if( sd && !i )
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
}
}else
@@ -7823,51 +8040,33 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case WL_FROSTMISTY:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- map_foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_CHAR|BL_SKILL,src,skill_id,skill_lv,tick,flag|BCT_ENEMY,skill->castend_damage_id);
+ iMap->foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_CHAR|BL_SKILL,src,skill_id,skill_lv,tick,flag|BCT_ENEMY,skill->castend_damage_id);
break;
case WL_JACKFROST:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- map_foreachinshootrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_CHAR|BL_SKILL,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
+ iMap->foreachinshootrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_CHAR|BL_SKILL,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
break;
case WL_MARSHOFABYSS:
- // Should marsh of abyss still apply half reduction to players after the 28/10 patch? [LimitLine]
clif->skill_nodamage(src, bl, skill_id, skill_lv,
- sc_start4(bl, type, 100, skill_lv, status_get_int(src), sd ? sd->status.job_level : 50, 0,
- skill->get_time(skill_id, skill_lv)));
+ sc_start(bl, type, 100, skill_lv, skill->get_time(skill_id, skill_lv)));
break;
case WL_SIENNAEXECRATE:
- if( status_isimmune(bl) || !tsc )
- break;
-
if( flag&1 ) {
- if( bl->id == skill_area_temp[1] )
- break; // Already work on this target
-
+ if( status_isimmune(bl) || !tsc )
+ break;
if( tsc && tsc->data[SC_STONE] )
status_change_end(bl,SC_STONE,INVALID_TIMER);
else
- status_change_start(bl,SC_STONE,10000,skill_lv,0,0,1000,skill->get_time(skill_id, skill_lv),2);
+ status_change_start(bl,SC_STONE,10000,skill_lv,0,0,500,skill->get_time(skill_id, skill_lv),2);
} else {
- int rate = 40 + 8 * skill_lv + ( sd? sd->status.job_level : 50 ) / 4;
- // IroWiki says Rate should be reduced by target stats, but currently unknown
- if( rnd()%100 < rate ) { // Success on First Target
- if( !tsc->data[SC_STONE] )
- rate = status_change_start(bl,SC_STONE,10000,skill_lv,0,0,1000,skill->get_time(skill_id, skill_lv),2);
- else {
- rate = 1;
- status_change_end(bl,SC_STONE,INVALID_TIMER);
- }
-
- if( rate ) {
- skill_area_temp[1] = bl->id;
- map_foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_nodamage_id);
- }
- // Doesn't send failure packet if it fails on defense.
- }
- else if( sd ) // Failure on Rate
+ int rate = 45 + 5 * skill_lv;
+ if( rnd()%100 < rate ){
+ clif->skill_nodamage(src, bl, skill_id, skill_lv, 1);
+ iMap->foreachinrange(skill_area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill_castend_nodamage_id);
+ }else if( sd ) // Failure on Rate
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
}
break;
@@ -7876,36 +8075,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case WL_SUMMONBL:
case WL_SUMMONWB:
case WL_SUMMONSTONE:
- {
- short element = 0, sctype = 0, pos = -1;
- struct status_change *sc = status_get_sc(src);
- if( !sc ) break;
-
- for( i = SC_SPHERE_1; i <= SC_SPHERE_5; i++ )
- {
- if( !sctype && !sc->data[i] )
- sctype = i; // Take the free SC
- if( sc->data[i] )
- pos = max(sc->data[i]->val2,pos);
- }
-
- if( !sctype )
- {
- if( sd ) // No free slots to put SC
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_SUMMON,0);
+ for( i = SC_SUMMON1; i <= SC_SUMMON5; i++ ){
+ if( tsc && !tsc->data[i] ){ // officially it doesn't work like a stack
+ int ele = WLS_FIRE + (skill_id - WL_SUMMONFB) - (skill_id == WL_SUMMONSTONE ? 4 : 0);
+ clif->skill_nodamage(src, bl, skill_id, skill_lv,
+ sc_start(bl, (sc_type)i, 100, ele, skill->get_time(skill_id, skill_lv)));
break;
}
-
- pos++; // Used in val2 for SC. Indicates the order of this ball
- switch( skill_id ) { // Set val1. The SC element for this ball
- case WL_SUMMONFB: element = WLS_FIRE; break;
- case WL_SUMMONBL: element = WLS_WIND; break;
- case WL_SUMMONWB: element = WLS_WATER; break;
- case WL_SUMMONSTONE: element = WLS_STONE; break;
- }
-
- sc_start4(src,sctype,100,element,pos,skill_lv,0,skill->get_time(skill_id,skill_lv));
- clif->skill_nodamage(src,bl,skill_id,0,0);
}
break;
@@ -7913,10 +8089,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if( sd ) {
struct status_change *sc = status_get_sc(bl);
- for( i = SC_SPELLBOOK1; i <= SC_MAXSPELLBOOK; i++)
+ for( i = SC_SPELLBOOK1; i <= SC_SPELLBOOK7; i++)
if( sc && !sc->data[i] )
break;
- if( i == SC_MAXSPELLBOOK ) {
+ if( i == SC_SPELLBOOK7 ) {
clif->skill_fail(sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_READING, 0);
break;
}
@@ -7937,9 +8113,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case RA_WUGMASTERY:
if( sd ) {
if( !pc_iswug(sd) )
- pc_setoption(sd,sd->sc.option|OPTION_WUG);
+ pc->setoption(sd,sd->sc.option|OPTION_WUG);
else
- pc_setoption(sd,sd->sc.option&~OPTION_WUG);
+ pc->setoption(sd,sd->sc.option&~OPTION_WUG);
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
}
break;
@@ -7947,11 +8123,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case RA_WUGRIDER:
if( sd ) {
if( !pc_isridingwug(sd) && pc_iswug(sd) ) {
- pc_setoption(sd,sd->sc.option&~OPTION_WUG);
- pc_setoption(sd,sd->sc.option|OPTION_WUGRIDER);
+ pc->setoption(sd,sd->sc.option&~OPTION_WUG);
+ pc->setoption(sd,sd->sc.option|OPTION_WUGRIDER);
} else if( pc_isridingwug(sd) ) {
- pc_setoption(sd,sd->sc.option&~OPTION_WUGRIDER);
- pc_setoption(sd,sd->sc.option|OPTION_WUG);
+ pc->setoption(sd,sd->sc.option&~OPTION_WUGRIDER);
+ pc->setoption(sd,sd->sc.option|OPTION_WUG);
}
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
}
@@ -7960,7 +8136,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case RA_WUGDASH:
if( tsce ) {
clif->skill_nodamage(src,bl,skill_id,skill_lv,status_change_end(bl, type, INVALID_TIMER));
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
if( sd && pc_isridingwug(sd) ) {
@@ -7972,7 +8148,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case RA_SENSITIVEKEEN:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
clif->skill_damage(src,src,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
- map_foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR|BL_SKILL,src,skill_id,skill_lv,tick,flag|BCT_ENEMY,skill->castend_damage_id);
+ iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR|BL_SKILL,src,skill_id,skill_lv,tick,flag|BCT_ENEMY,skill->castend_damage_id);
break;
/**
* Mechanic
@@ -7981,9 +8157,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case NC_B_SIDESLIDE:
{
uint8 dir = (skill_id == NC_F_SIDESLIDE) ? (unit_getdir(src)+4)%8 : unit_getdir(src);
- skill->blown(src,bl,skill->get_blewcount(skill_id,skill_lv),dir,0x1);
+ skill->blown(src,bl,skill->get_blewcount(skill_id,skill_lv),dir,0);
clif->slide(src,src->x,src->y);
- clif->fixpos(src); //Aegis sent this packet
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
}
break;
@@ -7991,7 +8166,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case NC_SELFDESTRUCTION:
if( sd ) {
if( pc_ismadogear(sd) )
- pc_setmadogear(sd, 0);
+ pc->setmadogear(sd, 0);
clif->skill_nodamage(src, bl, skill_id, skill_lv, 1);
skill->castend_damage_id(src, src, skill_id, skill_lv, tick, flag);
status_set_sp(src, 0, 0);
@@ -8002,15 +8177,15 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
clif->skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
clif->skill_nodamage(src, bl, skill_id, skill_lv,
sc_start(bl,type, 30 + 12 * skill_lv,skill_lv,skill->get_time(skill_id,skill_lv)));
- if( sd ) pc_overheat(sd,1);
+ if( sd ) pc->overheat(sd,1);
break;
case NC_MAGNETICFIELD:
if( (i = sc_start2(bl,type,100,skill_lv,src->id,skill->get_time(skill_id,skill_lv))) )
{
- map_foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),splash_target(src),src,skill_id,skill_lv,tick,flag|BCT_ENEMY|SD_SPLASH|1,skill->castend_damage_id);;
+ iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),splash_target(src),src,skill_id,skill_lv,tick,flag|BCT_ENEMY|SD_SPLASH|1,skill->castend_damage_id);;
clif->skill_damage(src,src,tick,status_get_amotion(src),0,-30000,1,skill_id,skill_lv,6);
- if (sd) pc_overheat(sd,1);
+ if (sd) pc->overheat(sd,1);
}
clif->skill_nodamage(src,src,skill_id,skill_lv,i);
break;
@@ -8036,7 +8211,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case NC_DISJOINT:
{
if( bl->type != BL_MOB ) break;
- md = map_id2md(bl->id);
+ md = iMap->id2md(bl->id);
if( md && md->class_ >= MOBID_SILVERSNIPER && md->class_ <= MOBID_MAGICDECOY_WIND )
status_kill(bl);
clif->skill_nodamage(src, bl, skill_id, skill_lv, 1);
@@ -8080,7 +8255,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
}
} else {
clif->skill_nodamage(src, bl, skill_id, 0, 1);
- map_foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR,
+ iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR,
src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id);
}
break;
@@ -8118,7 +8293,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case LG_TRAMPLE:
clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
- map_foreachinrange(skill->destroy_trap,bl,skill->get_splash(skill_id,skill_lv),BL_SKILL,tick);
+ iMap->foreachinrange(skill->destroy_trap,bl,skill->get_splash(skill_id,skill_lv),BL_SKILL,tick);
break;
case LG_REFLECTDAMAGE:
@@ -8158,7 +8333,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
sc_start(bl,SC_SHIELDSPELL_DEF,100,opt,-1);
clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
if( rate < brate )
- map_foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
+ iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
status_change_end(bl,SC_SHIELDSPELL_DEF,INVALID_TIMER);
break;
case 2:
@@ -8186,14 +8361,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
sc_start(bl,SC_SHIELDSPELL_MDEF,100,opt,-1);
clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
if( rate < brate )
- map_foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|2,skill->castend_damage_id);
+ iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|2,skill->castend_damage_id);
status_change_end(bl,SC_SHIELDSPELL_MDEF,INVALID_TIMER);
break;
case 2:
sc_start(bl,SC_SHIELDSPELL_MDEF,100,opt,-1);
clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
if( rate < brate )
- map_foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_nodamage_id);
+ iMap->foreachinrange(skill->area_sub,src,skill->get_splash(skill_id,skill_lv),BL_CHAR,src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_nodamage_id);
break;
case 3:
if( sc_start(bl,SC_SHIELDSPELL_MDEF,brate,opt,sd->bonus.shieldmdef * 30000) )
@@ -8245,15 +8420,42 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv));
else {
skill_area_temp[2] = 0;
- map_foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_PC,src,skill_id,skill_lv,tick,flag|SD_PREAMBLE|BCT_PARTY|BCT_SELF|1,skill->castend_nodamage_id);
+ iMap->foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_PC,src,skill_id,skill_lv,tick,flag|SD_PREAMBLE|BCT_PARTY|BCT_SELF|1,skill->castend_nodamage_id);
+ clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
+ }
+ break;
+ case LG_KINGS_GRACE:
+ if( flag&1 ){
+ sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv));
+ for(i=0; i<SC_MAX; i++)
+ {
+ if (!tsc->data[i])
+ continue;
+ switch(i){
+ case SC_POISON: case SC_BLIND:
+ case SC_FREEZE: case SC_STONE:
+ case SC_STUN: case SC_SLEEP:
+ case SC_BLOODING: case SC_CURSE:
+ case SC_CONFUSION: case SC_ILLUSION:
+ case SC_SILENCE: case SC_BURNING:
+ case SC_CRYSTALIZE: case SC_FROSTMISTY:
+ case SC_DEEP_SLEEP: case SC_FEAR:
+ case SC_MANDRAGORA:
+ status_change_end(bl, (sc_type)i, INVALID_TIMER);
+ }
+ }
+ }else {
+ skill_area_temp[2] = 0;
+ if( !map_flag_vs(src->m) && !map_flag_gvg(src->m) )
+ flag |= BCT_GUILD;
+ iMap->foreachinrange(skill->area_sub,bl,skill->get_splash(skill_id,skill_lv),BL_PC,src,skill_id,skill_lv,tick,flag|SD_PREAMBLE|BCT_PARTY|BCT_SELF|1,skill->castend_nodamage_id);
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
}
break;
-
case LG_INSPIRATION:
if( sd && !map[sd->bl.m].flag.noexppenalty && sd->status.base_level != MAX_LEVEL ) {
- sd->status.base_exp -= min(sd->status.base_exp, pc_nextbaseexp(sd) * 1 / 100); // 1% penalty.
- sd->status.job_exp -= min(sd->status.job_exp, pc_nextjobexp(sd) * 1 / 100);
+ sd->status.base_exp -= min(sd->status.base_exp, pc->nextbaseexp(sd) * 1 / 100); // 1% penalty.
+ sd->status.job_exp -= min(sd->status.job_exp, pc->nextjobexp(sd) * 1 / 100);
clif->updatestatus(sd,SP_BASEEXP);
clif->updatestatus(sd,SP_JOBEXP);
}
@@ -8265,18 +8467,18 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if( is_boss(bl) ) break;
if( sc_start2(bl, type, 100, skill_lv, src->id, skill->get_time(skill_id, skill_lv))) {
if( bl->type == BL_MOB )
- mob_unlocktarget((TBL_MOB*)bl,gettick());
+ mob_unlocktarget((TBL_MOB*)bl,iTimer->gettick());
unit_stop_attack(bl);
clif->bladestop(src, bl->id, 1);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 1;
}
} else {
int count = 0;
clif->skill_damage(src, bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
- count = map_forcountinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv), (sd)?sd->spiritball_old:15, // Assume 15 spiritballs in non-charactors
+ count = iMap->forcountinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv), (sd)?sd->spiritball_old:15, // Assume 15 spiritballs in non-charactors
BL_CHAR, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id);
- if( sd ) pc_delspiritball(sd, count, 0);
+ if( sd ) pc->delspiritball(sd, count, 0);
clif->skill_nodamage(src, src, skill_id, skill_lv,
sc_start2(src, SC_CURSEDCIRCLE_ATKER, 100, skill_lv, count, skill->get_time(skill_id,skill_lv)));
}
@@ -8287,7 +8489,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
short max = 5 + skill_lv;
sc_start(bl, SC_EXPLOSIONSPIRITS, 100, skill_lv, skill->get_time(skill_id, skill_lv));
for( i = 0; i < max; i++ ) // Don't call more than max available spheres.
- pc_addspiritball(sd, skill->get_time(skill_id, skill_lv), max);
+ pc->addspiritball(sd, skill->get_time(skill_id, skill_lv), max);
clif->skill_nodamage(src, bl, skill_id, skill_lv, sc_start(bl, type, 100, skill_lv,skill->get_time(skill_id, skill_lv)));
}
break;
@@ -8298,13 +8500,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if( dstsd && dstsd->spiritball && (sd == dstsd || map_flag_vs(src->m)) && (dstsd->class_&MAPID_BASEMASK)!=MAPID_GUNSLINGER )
{
i = dstsd->spiritball; //1%sp per spiritball.
- pc_delspiritball(dstsd, dstsd->spiritball, 0);
+ pc->delspiritball(dstsd, dstsd->spiritball, 0);
}
if( i ) status_percent_heal(src, 0, i);
clif->skill_nodamage(src, bl, skill_id, skill_lv, i ? 1:0);
} else {
clif->skill_damage(src,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
- map_foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|BCT_SELF|SD_SPLASH|1, skill->castend_nodamage_id);
+ iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|BCT_SELF|SD_SPLASH|1, skill->castend_nodamage_id);
}
break;
@@ -8313,8 +8515,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
break;
if( sd && dstsd->spiritball <= 5 ) {
for(i = 0; i <= 5; i++) {
- pc_addspiritball(dstsd, skill->get_time(MO_CALLSPIRITS, pc_checkskill(sd,MO_CALLSPIRITS)), i);
- pc_delspiritball(sd, sd->spiritball, 0);
+ pc->addspiritball(dstsd, skill->get_time(MO_CALLSPIRITS, pc->checkskill(sd,MO_CALLSPIRITS)), i);
+ pc->delspiritball(sd, sd->spiritball, 0);
}
}
clif->skill_nodamage(src, bl, skill_id, skill_lv, 1);
@@ -8341,9 +8543,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
status_change_end(bl, SC_POISON, INVALID_TIMER);
status_change_end(bl, SC_SILENCE, INVALID_TIMER);
status_change_end(bl, SC_BLIND, INVALID_TIMER);
- status_change_end(bl, SC_HALLUCINATION, INVALID_TIMER);
+ status_change_end(bl, SC_ILLUSION, INVALID_TIMER);
status_change_end(bl, SC_BURNING, INVALID_TIMER);
- status_change_end(bl, SC_FREEZING, INVALID_TIMER);
+ status_change_end(bl, SC_FROSTMISTY, INVALID_TIMER);
}
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
@@ -8354,6 +8556,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
clif->skill_nodamage(src,bl,skill_id,skill_lv,
sc_start2(bl,type,100,skill_lv,src->id,skill->get_time(skill_id,skill_lv)));
break;
+ case SR_FLASHCOMBO:
+ clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
+ for(i = SR_FLASHCOMBO_ATK_STEP1; i <= SR_FLASHCOMBO_ATK_STEP4; i++)
+ skill->addtimerskill(src, tick + 500 * (i - SR_FLASHCOMBO_ATK_STEP1), bl->id, 0, 0, i, skill_lv, BF_WEAPON, flag|SD_LEVEL);
+ break;
case WA_SWING_DANCE:
case WA_MOONLIT_SERENADE:
if( sd == NULL || sd->status.party_id == 0 || (flag & 1) )
@@ -8368,7 +8575,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case MI_RUSH_WINDMILL:
case MI_ECHOSONG:
if( sd == NULL || sd->status.party_id == 0 || (flag & 1) )
- sc_start4(bl,type,100,skill_lv,6*skill_lv,(sd?pc_checkskill(sd,WM_LESSON):0),(sd?sd->status.job_level:0),skill->get_time(skill_id,skill_lv));
+ sc_start4(bl,type,100,skill_lv,6*skill_lv,(sd?pc->checkskill(sd,WM_LESSON):0),(sd?sd->status.job_level:0),skill->get_time(skill_id,skill_lv));
else if( sd ) { // Only shows effects on caster.
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
party_foreachsamemap(skill->area_sub, sd, skill->get_splash(skill_id, skill_lv), src, skill_id, skill_lv, tick, flag|BCT_PARTY|1, skill->castend_nodamage_id);
@@ -8393,7 +8600,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
tstatus->hp = heal;
tstatus->sp -= tstatus->sp * ( 120 - 20 * skill_lv ) / 100;
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- pc_revive((TBL_PC*)bl,heal,0);
+ pc->revive((TBL_PC*)bl,heal,0);
clif->resurrection(bl,1);
}
}
@@ -8407,16 +8614,16 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if( flag&1 ) {
sc_start2(bl,type,(skill_id==WM_VOICEOFSIREN)?20+10*skill_lv:100,skill_lv,(skill_id==WM_VOICEOFSIREN)?src->id:0,skill->get_time(skill_id,skill_lv));
} else {
- map_foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),(skill_id==WM_VOICEOFSIREN)?BL_CHAR|BL_SKILL:BL_PC, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id);
+ iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),(skill_id==WM_VOICEOFSIREN)?BL_CHAR|BL_SKILL:BL_PC, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id);
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
}
break;
case WM_GLOOMYDAY:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- if( dstsd && ( pc_checkskill(dstsd,KN_BRANDISHSPEAR) || pc_checkskill(dstsd,LK_SPIRALPIERCE) ||
- pc_checkskill(dstsd,CR_SHIELDCHARGE) || pc_checkskill(dstsd,CR_SHIELDBOOMERANG) ||
- pc_checkskill(dstsd,PA_SHIELDCHAIN) || pc_checkskill(dstsd,LG_SHIELDPRESS) ) )
+ if( dstsd && ( pc->checkskill(dstsd,KN_BRANDISHSPEAR) || pc->checkskill(dstsd,LK_SPIRALPIERCE) ||
+ pc->checkskill(dstsd,CR_SHIELDCHARGE) || pc->checkskill(dstsd,CR_SHIELDBOOMERANG) ||
+ pc->checkskill(dstsd,PA_SHIELDCHAIN) || pc->checkskill(dstsd,LG_SHIELDPRESS) ) )
{
sc_start(bl,SC_GLOOMYDAY_SK,100,skill_lv,skill->get_time(skill_id,skill_lv));
break;
@@ -8437,12 +8644,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
clif->skill_fail(sd,skill_id,USESKILL_FAIL_NEED_HELPER,0);
break;
}
- if( map_foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id,skill_lv),
+ if( iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id,skill_lv),
BL_PC, src, skill_id, skill_lv, tick, BCT_ENEMY, skill->area_sub_count) > 7 )
flag |= 2;
else
flag |= 1;
- map_foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),BL_PC, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|BCT_SELF, skill->castend_nodamage_id);
+ iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),BL_PC, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|BCT_SELF, skill->castend_nodamage_id);
clif->skill_nodamage(src, bl, skill_id, skill_lv,
sc_start(src,SC_STOP,100,skill_lv,skill->get_time2(skill_id,skill_lv)));
if( flag&2 ) // Dealed here to prevent conflicts
@@ -8476,7 +8683,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
} else { // These affect to all targets arround the caster.
short lv = (short)skill_lv;
skill_area_temp[0] = (sd) ? skill->check_pc_partner(sd,skill_id,&lv,skill->get_splash(skill_id,skill_lv),1) : 50; // 50% chance in non BL_PC (clones).
- map_foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),BL_PC, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id);
+ iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),BL_PC, src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id);
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
}
break;
@@ -8515,7 +8722,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if (!target_id)
break;
if (skill->get_casttype(improv_skill_id) == CAST_GROUND) {
- bl = map_id2bl(target_id);
+ bl = iMap->id2bl(target_id);
if (!bl) bl = src;
unit_skilluse_pos(src, bl->x, bl->y, improv_skill_id, improv_skill_lv);
} else
@@ -8549,10 +8756,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if(!mapindex)
{ //Given map not found?
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
- pc_setpos(sd, mapindex, x, y, CLR_TELEPORT);
+ pc->setpos(sd, mapindex, x, y, CLR_TELEPORT);
}
break;
@@ -8569,7 +8776,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case SO_ARRULLO:
{
- // [(15 + 5 * Skill Level) + ( Caster’s INT / 5 ) + ( Caster’s Job Level / 5 ) - ( Target’s INT / 6 ) - ( Target’s LUK / 10 )] %
+ // [(15 + 5 * Skill Level) + ( Caster?s INT / 5 ) + ( Caster?s Job Level / 5 ) - ( Target?s INT / 6 ) - ( Target?s LUK / 10 )] %
int rate = (15 + 5 * skill_lv) + status_get_int(src)/5 + (sd ? sd->status.job_level : 0);
rate -= status_get_int(bl)/6 - status_get_luk(bl)/10;
clif->skill_nodamage(src, bl, skill_id, skill_lv, 1);
@@ -8579,13 +8786,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case WM_LULLABY_DEEPSLEEP:
if( flag&1 ){
- //[(Skill Level x 4) + (Voice Lessons Skill Level x 2) + (Caster’s Base Level / 15) + (Caster’s Job Level / 5)] %
- int rate = (4 * skill_lv) + ( (sd) ? pc_checkskill(sd,WM_LESSON)*2 + sd->status.job_level/5 : 0 ) + status_get_lv(src) / 15;
+ //[(Skill Level x 4) + (Voice Lessons Skill Level x 2) + (Caster?s Base Level / 15) + (Caster?s Job Level / 5)] %
+ int rate = (4 * skill_lv) + ( (sd) ? pc->checkskill(sd,WM_LESSON)*2 + sd->status.job_level/5 : 0 ) + status_get_lv(src) / 15;
if( bl != src )
sc_start(bl,type,rate,skill_lv,skill->get_time(skill_id,skill_lv));
}else {
clif->skill_nodamage(src, bl, skill_id, skill_lv, 1);
- map_foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR,
+ iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR,
src, skill_id, skill_lv, tick, flag|BCT_ALL|1, skill->castend_nodamage_id);
}
break;
@@ -8704,7 +8911,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
sc_start(bl, type, 25 + 10 * skill_lv, skill_lv, skill->get_time(skill_id, skill_lv))) )
status_zap(bl, 0, status_get_max_sp(bl) * (25 + 5 * skill_lv) / 100);
} else
- map_foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR,
+ iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR,
src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id);
break;
@@ -8721,7 +8928,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if( itemdb_is_GNbomb(ammo_id) ) {
if(battle->check_target(src,bl,BCT_ENEMY) > 0) {// Only attack if the target is an enemy.
if( ammo_id == 13263 )
- map_foreachincell(skill->area_sub,bl->m,bl->x,bl->y,BL_CHAR,src,GN_SLINGITEM_RANGEMELEEATK,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
+ iMap->foreachincell(skill->area_sub,bl->m,bl->x,bl->y,BL_CHAR,src,GN_SLINGITEM_RANGEMELEEATK,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
else
skill->attack(BF_WEAPON,src,src,bl,GN_SLINGITEM_RANGEMELEEATK,skill_lv,tick,flag);
} else //Otherwise, it fails, shows animation and removes items.
@@ -8826,7 +9033,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if(sd) {
int ttype = skill->get_ele(skill_id, skill_lv);
clif->skill_nodamage(src, bl, skill_id, skill_lv, 1);
- pc_add_talisman(sd, skill->get_time(skill_id, skill_lv), 10, ttype);
+ ARR_FIND(1, 6, i, sd->charm[i] > 0 && ttype != i);
+ if( i < 6 )
+ pc->del_charm(sd, sd->charm[i], i); // replace with a new one.
+ pc->add_charm(sd, skill->get_time(skill_id, skill_lv), 10, ttype);
}
break;
@@ -8840,10 +9050,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
md->master_id = src->id;
md->special_state.ai = AI_ZANZOU;
if( md->deletetimer != INVALID_TIMER )
- delete_timer(md->deletetimer, mob_timer_delete);
- md->deletetimer = add_timer (gettick() + skill->get_time(skill_id, skill_lv), mob_timer_delete, md->bl.id, 0);
+ iTimer->delete_timer(md->deletetimer, mob_timer_delete);
+ md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob_timer_delete, md->bl.id, 0);
mob_spawn( md );
- pc_setinvincibletimer(sd,500);// unlock target lock
+ pc->setinvincibletimer(sd,500);// unlock target lock
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
skill->blown(src,bl,skill->get_blewcount(skill_id,skill_lv),unit_getdir(bl),0);
}
@@ -8851,45 +9061,50 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
break;
case KO_KYOUGAKU:
- if( dstsd && tsc && !tsc->data[type] && rand()%100 < tstatus->int_/2 ){
- clif->skill_nodamage(src,bl,skill_id,skill_lv,
- sc_start(bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)));
- }else if( sd )
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ {
+ int rate = max(5, (45 + 5 * skill_lv - status_get_int(bl) / 10));
+ if( sd && !map_flag_gvg(src->m) ){
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_SIZE, 0);
+ break;
+ }
+ if( dstsd && tsc && !tsc->data[type] && rand()%100 < rate ){
+ clif->skill_nodamage(src, bl, skill_id, skill_lv,
+ sc_start(bl, type, 100, skill_lv, skill->get_time(skill_id, skill_lv)));
+ }else if( sd )
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0);
+ }
break;
case KO_JYUSATSU:
if( dstsd && tsc && !tsc->data[type] &&
- rand()%100 < ((45+5*skill_lv) + skill_lv*5 - status_get_int(bl)/2) ){//[(Base chance of success) + (Skill Level x 5) - (int / 2)]%.
- clif->skill_nodamage(src,bl,skill_id,skill_lv,
- status_change_start(bl,type,10000,skill_lv,0,0,0,skill->get_time(skill_id,skill_lv),1));
- status_zap(bl, tstatus->max_hp*skill_lv*5/100 , 0);
+ rand()%100 < (10 * (5 * skill_lv - status_get_int(bl) / 2 + 45 + 5 * skill_lv)) ){
+ clif->skill_nodamage(src, bl, skill_id, skill_lv,
+ status_change_start(bl, type, 10000, skill_lv, 0, 0, 0, skill->get_time(skill_id, skill_lv), 1));
+ status_zap(bl, tstatus->max_hp * skill_lv * 5 / 100 , 0);
if( status_get_lv(bl) <= status_get_lv(src) )
- status_change_start(bl,SC_COMA,10,skill_lv,0,src->id,0,0,0);
+ status_change_start(bl, SC_COMA, skill_lv, skill_lv, 0, src->id, 0, 0, 0);
}else if( sd )
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0);
break;
case KO_GENWAKU:
- if ( !map_flag_gvg(src->m) && ( dstsd || dstmd ) && battle->check_target(src,bl,BCT_ENEMY) > 0 ) {
+ if ( !map_flag_gvg(src->m) && ( dstsd || dstmd ) && !(tstatus->mode&MD_PLANT) && battle->check_target(src,bl,BCT_ENEMY) > 0 ) {
int x = src->x, y = src->y;
-
- if( sd && rnd()%100 > ((45+5*skill_lv) - status_get_int(bl)/10) ){//[(Base chance of success) - (Intelligence Objectives / 10)]%.
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ if( sd && rnd()%100 > max(5, (45 + 5 * skill_lv) - status_get_int(bl) / 10) ){//[(Base chance of success) - ( target's int / 10)]%.
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0);
break;
}
- if (unit_movepos(src,bl->x,bl->y,0,0)) {
- clif->skill_nodamage(src,src,skill_id,skill_lv,1);
- clif->slide(src,bl->x,bl->y) ;
- sc_start(src,SC_CONFUSION,80,skill_lv,skill->get_time(skill_id,skill_lv));
- if (unit_movepos(bl,x,y,0,0))
+ if (unit_movepos(src, bl->x, bl->y, 0, 0)) {
+ clif->skill_nodamage(src, src, skill_id, skill_lv, 1);
+ clif->slide(src, bl->x, bl->y) ;
+ sc_start(src, SC_CONFUSION, 25, skill_lv, skill->get_time(skill_id, skill_lv));
+ if ( !is_boss(bl) && unit_stop_walking(&sd->bl, 1) && unit_movepos(bl, x, y, 0, 0) )
{
- clif->skill_damage(bl,bl,tick, status_get_amotion(src), 0, -30000, 1, skill_id, -1, 6);
- if( bl->type == BL_PC && pc_issit((TBL_PC*)bl))
- clif->sitting(bl); //Avoid sitting sync problem
- clif->slide(bl,x,y) ;
- sc_start(bl,SC_CONFUSION,80,skill_lv,skill->get_time(skill_id,skill_lv));
+ if( dstsd && pc_issit(dstsd) )
+ pc->setstand(dstsd);
+ clif->slide(bl, x, y) ;
+ sc_start(bl, SC_CONFUSION, 75, skill_lv, skill->get_time(skill_id, skill_lv));
}
}
}
@@ -8899,7 +9114,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case OB_OBOROGENSOU:
if( sd && ( (skill_id == OB_OBOROGENSOU && bl->type == BL_MOB) // This skill does not work on monsters.
|| is_boss(bl) ) ){ // Does not work on Boss monsters.
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_TOTARGET_PLAYER, 0);
break;
}
case KO_IZAYOI:
@@ -8915,7 +9130,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if( flag&1 ){
if(tsc && ( tsc->option&(OPTION_CLOAK|OPTION_HIDE) ||
tsc->data[SC_CAMOUFLAGE] || tsc->data[SC__SHADOWFORM] ||
- tsc->data[SC_MARIONETTE] || tsc->data[SC_HARMONIZE])){
+ tsc->data[SC_MARIONETTE_MASTER] || tsc->data[SC_HARMONIZE])){
sc_start(src, type, 100, skill_lv, skill->get_time(skill_id, skill_lv));
sc_start(bl, type, 100, skill_lv, skill->get_time(skill_id, skill_lv));
status_change_end(bl, SC_HIDING, INVALID_TIMER);
@@ -8923,7 +9138,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
status_change_end(bl, SC_CLOAKINGEXCEED, INVALID_TIMER);
status_change_end(bl, SC_CAMOUFLAGE, INVALID_TIMER);
status_change_end(bl, SC__SHADOWFORM, INVALID_TIMER);
- status_change_end(bl, SC_MARIONETTE, INVALID_TIMER);
+ status_change_end(bl, SC_MARIONETTE_MASTER, INVALID_TIMER);
status_change_end(bl, SC_HARMONIZE, INVALID_TIMER);
}
if( skill_area_temp[2] == 1 ){
@@ -8932,7 +9147,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
}
}else{
skill_area_temp[2] = 0;
- map_foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_nodamage_id);
+ iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY|SD_SPLASH|1, skill->castend_nodamage_id);
}
break;
@@ -8940,7 +9155,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
struct status_change *ssc = status_get_sc(src);
struct block_list *m_bl = battle->get_master(src);
const enum sc_type scs[] = {
- SC_MANDRAGORA, SC_HARMONIZE, SC_DEEPSLEEP, SC_VOICEOFSIREN, SC_SLEEP, SC_CONFUSION, SC_HALLUCINATION
+ SC_MANDRAGORA, SC_HARMONIZE, SC_DEEP_SLEEP, SC_SIREN, SC_SLEEP, SC_CONFUSION, SC_ILLUSION
};
int heal;
if(tsc){
@@ -9010,27 +9225,31 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
int summons[5] = {1004, 1303, 1303, 1994, 1994};
int qty[5] = {3 , 3 , 4 , 4 , 5};
struct mob_data *md;
- int i;
+ int i, dummy = 0;
+ i = iMap->foreachinmap(skill->check_condition_mob_master_sub ,hd->bl.m, BL_MOB, hd->bl.id, summons[skill_lv-1], skill_id, &dummy);
+ if(i >= qty[skill_lv-1])
+ break;
+
for(i=0; i<qty[skill_lv - 1]; i++){ //easy way
md = mob_once_spawn_sub(src, src->m, src->x, src->y, status_get_name(src), summons[skill_lv - 1], "", SZ_SMALL, AI_ATTACK);
if (md) {
- md->master_id = src->id;
+ md->master_id = src->id;
if (md->deletetimer != INVALID_TIMER)
- delete_timer(md->deletetimer, mob_timer_delete);
- md->deletetimer = add_timer(gettick() + skill->get_time(skill_id, skill_lv), mob_timer_delete, md->bl.id, 0);
+ iTimer->delete_timer(md->deletetimer, mob_timer_delete);
+ md->deletetimer = iTimer->add_timer(iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob_timer_delete, md->bl.id, 0);
mob_spawn(md); //Now it is ready for spawning.
- sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_ASSIST, 0, 60000);
+ sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_CANATTACK|MD_AGGRESSIVE, 0, 60000);
}
}
- if (hd)
- skill->blockhomun_start(hd, skill_id, skill->get_cooldown(skill_id, skill_lv));
+ if (hd)
+ skill->blockhomun_start(hd, skill_id, skill->get_cooldown(skill_id, skill_lv));
}
break;
default:
ShowWarning("skill_castend_nodamage_id: Unknown skill used:%d\n",skill_id);
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 1;
}
@@ -9046,7 +9265,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
}
if( sd && !(flag&1) ) { // ensure that the skill last-cast tick is recorded
- sd->canskill_tick = gettick();
+ sd->canskill_tick = iTimer->gettick();
if( sd->state.arrow_atk ) { // consume arrow on last invocation to this skill.
battle->consume_ammo(sd, skill_id, skill_lv);
@@ -9056,334 +9275,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
skill->consume_requirement(sd,skill_id,skill_lv,2);
}
- map_freeblock_unlock();
- return 0;
-}
-
-/*==========================================
- *
- *------------------------------------------*/
-int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data)
-{
- struct block_list *target, *src;
- struct map_session_data *sd;
- struct mob_data *md;
- struct unit_data *ud;
- struct status_change *sc = NULL;
- int inf,inf2,flag = 0;
-
- src = map_id2bl(id);
- if( src == NULL )
- {
- ShowDebug("skill_castend_id: src == NULL (tid=%d, id=%d)\n", tid, id);
- return 0;// not found
- }
-
- ud = unit_bl2ud(src);
- if( ud == NULL )
- {
- ShowDebug("skill_castend_id: ud == NULL (tid=%d, id=%d)\n", tid, id);
- return 0;// ???
- }
-
- sd = BL_CAST(BL_PC, src);
- md = BL_CAST(BL_MOB, src);
-
- if( src->prev == NULL ) {
- ud->skilltimer = INVALID_TIMER;
- return 0;
- }
-
- if(ud->skill_id != SA_CASTCANCEL && ud->skill_id != SO_SPELLFIST) {// otherwise handled in unit_skillcastcancel()
- if( ud->skilltimer != tid ) {
- ShowError("skill_castend_id: Timer mismatch %d!=%d!\n", ud->skilltimer, tid);
- ud->skilltimer = INVALID_TIMER;
- return 0;
- }
-
- if( sd && ud->skilltimer != INVALID_TIMER && (pc_checkskill(sd,SA_FREECAST) > 0 || ud->skill_id == LG_EXEEDBREAK) )
- {// restore original walk speed
- ud->skilltimer = INVALID_TIMER;
- status_calc_bl(&sd->bl, SCB_SPEED);
- }
-
- ud->skilltimer = INVALID_TIMER;
- }
-
- if (ud->skilltarget == id)
- target = src;
- else
- target = map_id2bl(ud->skilltarget);
-
- // Use a do so that you can break out of it when the skill fails.
- do {
- if(!target || target->prev==NULL) break;
-
- if(src->m != target->m || status_isdead(src)) break;
-
- switch (ud->skill_id) {
- //These should become skill_castend_pos
- case WE_CALLPARTNER:
- if(sd) clif->callpartner(sd);
- case WE_CALLPARENT:
- case WE_CALLBABY:
- case AM_RESURRECTHOMUN:
- case PF_SPIDERWEB:
- //Find a random spot to place the skill. [Skotlex]
- inf2 = skill->get_splash(ud->skill_id, ud->skill_lv);
- ud->skillx = target->x + inf2;
- ud->skilly = target->y + inf2;
- if (inf2 && !map_random_dir(target, &ud->skillx, &ud->skilly)) {
- ud->skillx = target->x;
- ud->skilly = target->y;
- }
- ud->skilltimer=tid;
- return skill->castend_pos(tid,tick,id,data);
- case GN_WALLOFTHORN:
- ud->skillx = target->x;
- ud->skilly = target->y;
- ud->skilltimer = tid;
- return skill->castend_pos(tid,tick,id,data);
- }
-
- if(ud->skill_id == RG_BACKSTAP) {
- uint8 dir = map_calc_dir(src,target->x,target->y),t_dir = unit_getdir(target);
- if(check_distance_bl(src, target, 0) || map_check_dir(dir,t_dir)) {
- break;
- }
- }
-
- if( ud->skill_id == PR_TURNUNDEAD ) {
- struct status_data *tstatus = status_get_status_data(target);
- if( !battle->check_undead(tstatus->race, tstatus->def_ele) )
- break;
- }
-
- if( ud->skill_id == RA_WUGSTRIKE ){
- if( !path_search(NULL,src->m,src->x,src->y,target->x,target->y,1,CELL_CHKNOREACH))
- break;
- }
-
- if( ud->skill_id == PR_LEXDIVINA || ud->skill_id == MER_LEXDIVINA )
- {
- sc = status_get_sc(target);
- if( battle->check_target(src,target, BCT_ENEMY) <= 0 && (!sc || !sc->data[SC_SILENCE]) )
- { //If it's not an enemy, and not silenced, you can't use the skill on them. [Skotlex]
- clif->skill_nodamage (src, target, ud->skill_id, ud->skill_lv, 0);
- break;
- }
- }
- else
- { // Check target validity.
- inf = skill->get_inf(ud->skill_id);
- inf2 = skill->get_inf2(ud->skill_id);
-
- if(inf&INF_ATTACK_SKILL ||
- (inf&INF_SELF_SKILL && inf2&INF2_NO_TARGET_SELF) //Combo skills
- ) // Casted through combo.
- inf = BCT_ENEMY; //Offensive skill.
- else if(inf2&INF2_NO_ENEMY)
- inf = BCT_NOENEMY;
- else
- inf = 0;
-
- if(inf2 & (INF2_PARTY_ONLY|INF2_GUILD_ONLY) && src != target)
- {
- inf |=
- (inf2&INF2_PARTY_ONLY?BCT_PARTY:0)|
- (inf2&INF2_GUILD_ONLY?BCT_GUILD:0);
- //Remove neutral targets (but allow enemy if skill is designed to be so)
- inf &= ~BCT_NEUTRAL;
- }
-
- if( sd && (inf2&INF2_CHORUS_SKILL) && skill->check_pc_partner(sd, ud->skill_id, &ud->skill_lv, 1, 0) < 1 ) {
- clif->skill_fail(sd, ud->skill_id, USESKILL_FAIL_NEED_HELPER, 0);
- break;
- }
-
- if( ud->skill_id >= SL_SKE && ud->skill_id <= SL_SKA && target->type == BL_MOB )
- {
- if( ((TBL_MOB*)target)->class_ == MOBID_EMPERIUM )
- break;
- }
- else if (inf && battle->check_target(src, target, inf) <= 0){
- if (sd) clif->skill_fail(sd,ud->skill_id,USESKILL_FAIL_LEVEL,0);
- break;
- }
-
- if(inf&BCT_ENEMY && (sc = status_get_sc(target)) &&
- sc->data[SC_FOGWALL] &&
- rnd() % 100 < 75) { //Fogwall makes all offensive-type targetted skills fail at 75%
- if (sd) clif->skill_fail(sd, ud->skill_id, USESKILL_FAIL_LEVEL, 0);
- break;
- }
- }
-
- //Avoid doing double checks for instant-cast skills.
- if (tid != INVALID_TIMER && !status_check_skilluse(src, target, ud->skill_id, 1))
- break;
-
- if(md) {
- md->last_thinktime=tick +MIN_MOBTHINKTIME;
- if(md->skill_idx >= 0 && md->db->skill[md->skill_idx].emotion >= 0)
- clif->emotion(src, md->db->skill[md->skill_idx].emotion);
- }
-
- if(src != target && battle_config.skill_add_range &&
- !check_distance_bl(src, target, skill->get_range2(src,ud->skill_id,ud->skill_lv)+battle_config.skill_add_range))
- {
- if (sd) {
- clif->skill_fail(sd,ud->skill_id,USESKILL_FAIL_LEVEL,0);
- if(battle_config.skill_out_range_consume) //Consume items anyway. [Skotlex]
- skill->consume_requirement(sd,ud->skill_id,ud->skill_lv,3);
- }
- break;
- }
-
- if( sd )
- {
- if( !skill->check_condition_castend(sd, ud->skill_id, ud->skill_lv) )
- break;
- else
- skill->consume_requirement(sd,ud->skill_id,ud->skill_lv,1);
- }
-#ifdef OFFICIAL_WALKPATH
- if( !path_search_long(NULL, src->m, src->x, src->y, target->x, target->y, CELL_CHKWALL) )
- break;
-#endif
- if( (src->type == BL_MER || src->type == BL_HOM) && !skill->check_condition_mercenary(src, ud->skill_id, ud->skill_lv, 1) )
- break;
-
- if (ud->state.running && ud->skill_id == TK_JUMPKICK) {
- ud->state.running = 0;
- status_change_end(src, SC_RUN, INVALID_TIMER);
- flag = 1;
- }
-
- if (ud->walktimer != INVALID_TIMER && ud->skill_id != TK_RUN && ud->skill_id != RA_WUGDASH)
- unit_stop_walking(src,1);
-
- if( !sd || sd->skillitem != ud->skill_id || skill->get_delay(ud->skill_id,ud->skill_lv) )
- ud->canact_tick = tick + skill->delay_fix(src, ud->skill_id, ud->skill_lv); //Tests show wings don't overwrite the delay but skill scrolls do. [Inkfish]
- if (sd) { //Cooldown application
- int i, cooldown = skill->get_cooldown(ud->skill_id, ud->skill_lv);
- for (i = 0; i < ARRAYLENGTH(sd->skillcooldown) && sd->skillcooldown[i].id; i++) { // Increases/Decreases cooldown of a skill by item/card bonuses.
- if (sd->skillcooldown[i].id == ud->skill_id){
- cooldown += sd->skillcooldown[i].val;
- break;
- }
- }
- if(cooldown)
- skill->blockpc_start(sd, ud->skill_id, cooldown, false);
- }
- if( battle_config.display_status_timers && sd )
- clif->status_change(src, SI_ACTIONDELAY, 1, skill->delay_fix(src, ud->skill_id, ud->skill_lv), 0, 0, 0);
- if( sd )
- {
- switch( ud->skill_id )
- {
- case GS_DESPERADO:
- sd->canequip_tick = tick + skill->get_time(ud->skill_id, ud->skill_lv);
- break;
- case CR_GRANDCROSS:
- case NPC_GRANDDARKNESS:
- if( (sc = status_get_sc(src)) && sc->data[SC_STRIPSHIELD] )
- {
- const struct TimerData *timer = get_timer(sc->data[SC_STRIPSHIELD]->timer);
- if( timer && timer->func == status_change_timer && DIFF_TICK(timer->tick,gettick()+skill->get_time(ud->skill_id, ud->skill_lv)) > 0 )
- break;
- }
- sc_start2(src, SC_STRIPSHIELD, 100, 0, 1, skill->get_time(ud->skill_id, ud->skill_lv));
- break;
- }
- }
- if (skill->get_state(ud->skill_id) != ST_MOVE_ENABLE)
- unit_set_walkdelay(src, tick, battle_config.default_walk_delay+skill->get_walkdelay(ud->skill_id, ud->skill_lv), 1);
-
- if(battle_config.skill_log && battle_config.skill_log&src->type)
- ShowInfo("Type %d, ID %d skill castend id [id =%d, lv=%d, target ID %d]\n",
- src->type, src->id, ud->skill_id, ud->skill_lv, target->id);
-
- map_freeblock_lock();
-
- // SC_MAGICPOWER needs to switch states before any damage is actually dealt
- skill->toggle_magicpower(src, ud->skill_id);
- if( ud->skill_id != RA_CAMOUFLAGE ) // only normal attack and auto cast skills benefit from its bonuses
- status_change_end(src,SC_CAMOUFLAGE, INVALID_TIMER);
-
- if (skill->get_casttype(ud->skill_id) == CAST_NODAMAGE)
- skill->castend_nodamage_id(src,target,ud->skill_id,ud->skill_lv,tick,flag);
- else
- skill->castend_damage_id(src,target,ud->skill_id,ud->skill_lv,tick,flag);
-
- sc = status_get_sc(src);
- if(sc && sc->count) {
- if(sc->data[SC_SPIRIT] &&
- sc->data[SC_SPIRIT]->val2 == SL_WIZARD &&
- sc->data[SC_SPIRIT]->val3 == ud->skill_id &&
- ud->skill_id != WZ_WATERBALL)
- sc->data[SC_SPIRIT]->val3 = 0; //Clear bounced spell check.
-
- if( sc->data[SC_DANCING] && skill->get_inf2(ud->skill_id)&INF2_SONG_DANCE && sd )
- skill->blockpc_start(sd,BD_ADAPTATION,3000, false);
- }
-
- if( sd && ud->skill_id != SA_ABRACADABRA && ud->skill_id != WM_RANDOMIZESPELL ) // they just set the data so leave it as it is.[Inkfish]
- sd->skillitem = sd->skillitemlv = 0;
-
- if (ud->skilltimer == INVALID_TIMER) {
- if(md) md->skill_idx = -1;
- else ud->skill_id = 0; //mobs can't clear this one as it is used for skill condition 'afterskill'
- ud->skill_lv = ud->skilltarget = 0;
- }
- map_freeblock_unlock();
- return 1;
- } while(0);
-
- //Skill failed.
- if (ud->skill_id == MO_EXTREMITYFIST && sd && !(sc && sc->data[SC_FOGWALL]))
- { //When Asura fails... (except when it fails from Fog of Wall)
- //Consume SP/spheres
- skill->consume_requirement(sd,ud->skill_id, ud->skill_lv,1);
- status_set_sp(src, 0, 0);
- sc = &sd->sc;
- if (sc->count)
- { //End states
- status_change_end(src, SC_EXPLOSIONSPIRITS, INVALID_TIMER);
- status_change_end(src, SC_BLADESTOP, INVALID_TIMER);
-#ifdef RENEWAL
- sc_start(src, SC_EXTREMITYFIST2, 100, ud->skill_lv, skill->get_time(ud->skill_id, ud->skill_lv));
-#endif
- }
- if (target && target->m == src->m)
- { //Move character to target anyway.
- int dir, x, y;
- dir = map_calc_dir(src,target->x,target->y);
- if( dir > 0 && dir < 4) x = -2;
- else if( dir > 4 ) x = 2;
- else x = 0;
- if( dir > 2 && dir < 6 ) y = -2;
- else if( dir == 7 || dir < 2 ) y = 2;
- else y = 0;
- if (unit_movepos(src, src->x+x, src->y+y, 1, 1))
- { //Display movement + animation.
- clif->slide(src,src->x,src->y);
- clif->skill_damage(src,target,tick,sd->battle_status.amotion,0,0,1,ud->skill_id, ud->skill_lv, 5);
- }
- clif->skill_fail(sd,ud->skill_id,USESKILL_FAIL_LEVEL,0);
- }
- }
-
- ud->skill_id = ud->skill_lv = ud->skilltarget = 0;
- if( !sd || sd->skillitem != ud->skill_id || skill->get_delay(ud->skill_id,ud->skill_lv) )
- ud->canact_tick = tick;
- //You can't place a skill failed packet here because it would be
- //sent in ALL cases, even cases where skill_check_condition fails
- //which would lead to double 'skill failed' messages u.u [Skotlex]
- if(sd)
- sd->skillitem = sd->skillitemlv = 0;
- else if(md)
- md->skill_idx = -1;
+ iMap->freeblock_unlock();
return 0;
}
@@ -9392,7 +9284,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data)
*------------------------------------------*/
int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data)
{
- struct block_list* src = map_id2bl(id);
+ struct block_list* src = iMap->id2bl(id);
int maxcount;
struct map_session_data *sd;
struct unit_data *ud = unit_bl2ud(src);
@@ -9415,7 +9307,7 @@ int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data)
return 0;
}
- if( sd && ud->skilltimer != INVALID_TIMER && ( pc_checkskill(sd,SA_FREECAST) > 0 || ud->skill_id == LG_EXEEDBREAK ) )
+ if( sd && ud->skilltimer != INVALID_TIMER && ( pc->checkskill(sd,SA_FREECAST) > 0 || ud->skill_id == LG_EXEEDBREAK ) )
{// restore original walk speed
ud->skilltimer = INVALID_TIMER;
status_calc_bl(&sd->bl, SCB_SPEED);
@@ -9507,7 +9399,7 @@ int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data)
skill->blockpc_start(sd, ud->skill_id, cooldown, false);
}
if( battle_config.display_status_timers && sd )
- clif->status_change(src, SI_ACTIONDELAY, 1, skill->delay_fix(src, ud->skill_id, ud->skill_lv), 0, 0, 0);
+ clif->status_change(src, SI_POSTDELAY, 1, skill->delay_fix(src, ud->skill_id, ud->skill_lv), 0, 0, 0);
// if( sd )
// {
// switch( ud->skill_id )
@@ -9519,7 +9411,7 @@ int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data)
// }
unit_set_walkdelay(src, tick, battle_config.default_walk_delay+skill->get_walkdelay(ud->skill_id, ud->skill_lv), 1);
status_change_end(src,SC_CAMOUFLAGE, INVALID_TIMER);// only normal attack and auto cast skills benefit from its bonuses
- map_freeblock_lock();
+ iMap->freeblock_lock();
skill->castend_pos2(src,ud->skillx,ud->skilly,ud->skill_id,ud->skill_lv,tick,0);
if( sd && sd->skillitem != AL_WARP ) // Warp-Portal thru items will clear data in skill_castend_map. [Inkfish]
@@ -9531,7 +9423,7 @@ int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data)
ud->skill_lv = ud->skillx = ud->skilly = 0;
}
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 1;
} while(0);
@@ -9553,6 +9445,143 @@ static int skill_count_wos(struct block_list *bl,va_list ap) {
}
return 0;
}
+
+/*==========================================
+ *
+ *------------------------------------------*/
+int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char *map)
+{
+ nullpo_ret(sd);
+
+//Simplify skill_failed code.
+#define skill_failed(sd) { sd->menuskill_id = sd->menuskill_val = 0; }
+ if(skill_id != sd->menuskill_id)
+ return 0;
+
+ if( sd->bl.prev == NULL || pc_isdead(sd) ) {
+ skill_failed(sd);
+ return 0;
+ }
+
+ if( ( sd->sc.opt1 && sd->sc.opt1 != OPT1_BURNING ) || sd->sc.option&OPTION_HIDE ) {
+ skill_failed(sd);
+ return 0;
+ }
+ if(sd->sc.count && (
+ sd->sc.data[SC_SILENCE] ||
+ sd->sc.data[SC_ROKISWEIL] ||
+ sd->sc.data[SC_AUTOCOUNTER] ||
+ sd->sc.data[SC_STEELBODY] ||
+ (sd->sc.data[SC_DANCING] && skill_id < RK_ENCHANTBLADE && !pc->checkskill(sd, WM_LESSON)) ||
+ sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
+ sd->sc.data[SC_BASILICA] ||
+ sd->sc.data[SC_MARIONETTE_MASTER] ||
+ sd->sc.data[SC_WHITEIMPRISON] ||
+ (sd->sc.data[SC_STASIS] && skill->block_check(&sd->bl, SC_STASIS, skill_id)) ||
+ (sd->sc.data[SC_KG_KAGEHUMI] && skill->block_check(&sd->bl, SC_KG_KAGEHUMI, skill_id)) ||
+ sd->sc.data[SC_OBLIVIONCURSE] ||
+ sd->sc.data[SC__MANHOLE] ||
+ (sd->sc.data[SC_VOLCANIC_ASH] && rnd()%2) //50% fail chance under ASH
+ )) {
+ skill_failed(sd);
+ return 0;
+ }
+
+ pc_stop_attack(sd);
+ pc_stop_walking(sd,0);
+
+ if(battle_config.skill_log && battle_config.skill_log&BL_PC)
+ ShowInfo("PC %d skill castend skill =%d map=%s\n",sd->bl.id,skill_id,map);
+
+ if(strcmp(map,"cancel")==0) {
+ skill_failed(sd);
+ return 0;
+ }
+
+ switch(skill_id) {
+ case AL_TELEPORT:
+ if(strcmp(map,"Random")==0)
+ pc->randomwarp(sd,CLR_TELEPORT);
+ else if (sd->menuskill_val > 1) //Need lv2 to be able to warp here.
+ pc->setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
+ break;
+
+ case AL_WARP:
+ {
+ const struct point *p[4];
+ struct skill_unit_group *group;
+ int i, lv, wx, wy;
+ int maxcount=0;
+ int x,y;
+ unsigned short mapindex;
+
+ mapindex = mapindex_name2id((char*)map);
+ sd->state.workinprogress = 0;
+ if(!mapindex) { //Given map not found?
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ skill_failed(sd);
+ return 0;
+ }
+ p[0] = &sd->status.save_point;
+ p[1] = &sd->status.memo_point[0];
+ p[2] = &sd->status.memo_point[1];
+ p[3] = &sd->status.memo_point[2];
+
+ if((maxcount = skill->get_maxcount(skill_id, sd->menuskill_val)) > 0) {
+ for(i=0;i<MAX_SKILLUNITGROUP && sd->ud.skillunit[i] && maxcount;i++) {
+ if(sd->ud.skillunit[i]->skill_id == skill_id)
+ maxcount--;
+ }
+ if(!maxcount) {
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ skill_failed(sd);
+ return 0;
+ }
+ }
+
+ lv = sd->skillitem==skill_id?sd->skillitemlv:pc->checkskill(sd,skill_id);
+ wx = sd->menuskill_val>>16;
+ wy = sd->menuskill_val&0xffff;
+
+ if( lv <= 0 ) return 0;
+ if( lv > 4 ) lv = 4; // crash prevention
+
+ // check if the chosen map exists in the memo list
+ ARR_FIND( 0, lv, i, mapindex == p[i]->map );
+ if( i < lv ) {
+ x=p[i]->x;
+ y=p[i]->y;
+ } else {
+ skill_failed(sd);
+ return 0;
+ }
+
+ if(!skill->check_condition_castend(sd, sd->menuskill_id, lv)) { // This checks versus skill_id/skill_lv...
+ skill_failed(sd);
+ return 0;
+ }
+
+ skill->consume_requirement(sd,sd->menuskill_id,lv,2);
+ sd->skillitem = sd->skillitemlv = 0; // Clear data that's skipped in 'skill_castend_pos' [Inkfish]
+
+ if((group=skill->unitsetting(&sd->bl,skill_id,lv,wx,wy,0))==NULL) {
+ skill_failed(sd);
+ return 0;
+ }
+
+ group->val1 = (group->val1<<16)|(short)0;
+ // record the destination coordinates
+ group->val2 = (x<<16)|y;
+ group->val3 = mapindex;
+ }
+ break;
+ }
+
+ sd->menuskill_id = sd->menuskill_val = 0;
+ return 0;
+#undef skill_failed
+}
+
/*==========================================
*
*------------------------------------------*/
@@ -9600,11 +9629,11 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
case PR_BENEDICTIO:
skill_area_temp[1] = src->id;
i = skill->get_splash(skill_id, skill_lv);
- map_foreachinarea(skill->area_sub,
+ iMap->foreachinarea(skill->area_sub,
src->m, x-i, y-i, x+i, y+i, BL_PC,
src, skill_id, skill_lv, tick, flag|BCT_ALL|1,
skill->castend_nodamage_id);
- map_foreachinarea(skill->area_sub,
+ iMap->foreachinarea(skill->area_sub,
src->m, x-i, y-i, x+i, y+i, BL_CHAR,
src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1,
skill->castend_damage_id);
@@ -9612,7 +9641,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
case BS_HAMMERFALL:
i = skill->get_splash(skill_id, skill_lv);
- map_foreachinarea (skill->area_sub,
+ iMap->foreachinarea (skill->area_sub,
src->m, x-i, y-i, x+i, y+i, BL_CHAR,
src, skill_id, skill_lv, tick, flag|BCT_ENEMY|2,
skill->castend_nodamage_id);
@@ -9620,17 +9649,17 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
case HT_DETECTING:
i = skill->get_splash(skill_id, skill_lv);
- map_foreachinarea( status_change_timer_sub,
+ iMap->foreachinarea( status_change_timer_sub,
src->m, x-i, y-i, x+i,y+i,BL_CHAR,
src,NULL,SC_SIGHT,tick);
if(battle_config.traps_setting&1)
- map_foreachinarea( skill_reveal_trap,
+ iMap->foreachinarea( skill_reveal_trap,
src->m, x-i, y-i, x+i,y+i,BL_SKILL);
break;
case SR_RIDEINLIGHTNING:
i = skill->get_splash(skill_id, skill_lv);
- map_foreachinarea(skill->area_sub, src->m, x-i, y-i, x+i, y+i, BL_CHAR,
+ iMap->foreachinarea(skill->area_sub, src->m, x-i, y-i, x+i, y+i, BL_CHAR,
src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_damage_id);
break;
@@ -9641,7 +9670,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
struct skill_unit_group *sg;
if ((sg= skill->locate_element_field(src)) != NULL && ( sg->skill_id == SA_VOLCANO || sg->skill_id == SA_DELUGE || sg->skill_id == SA_VIOLENTGALE ))
{
- if (sg->limit - DIFF_TICK(gettick(), sg->tick) > 0) {
+ if (sg->limit - DIFF_TICK(iTimer->gettick(), sg->tick) > 0) {
skill->unitsetting(src,skill_id,skill_lv,x,y,0);
return 0; // not to consume items
} else
@@ -9719,6 +9748,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
case NJ_HUUMA:
#endif
case NPC_EVILLAND:
+ case WL_COMET:
case RA_ELECTRICSHOCKER:
case RA_CLUSTERBOMB:
case RA_MAGENTATRAP:
@@ -9755,6 +9785,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
case MH_POISON_MIST:
case MH_STEINWAND:
case MH_XENO_SLASHER:
+ case NC_MAGMA_ERUPTION:
flag|=1;//Set flag to 1 to prevent deleting ammo (it will be deleted on group-delete).
case GS_GROUNDDRIFT: //Ammo should be deleted right away.
skill->unitsetting(src,skill_id,skill_lv,x,y,0);
@@ -9768,7 +9799,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
if( sc->data[SC_BASILICA] )
status_change_end(src, SC_BASILICA, INVALID_TIMER); // Cancel Basilica
else { // Create Basilica. Start SC on caster. Unit timer start SC on others.
- if( map_foreachinrange(skill_count_wos, src, 2, BL_MOB|BL_PC, src) ) {
+ if( iMap->foreachinrange(skill_count_wos, src, 2, BL_MOB|BL_PC, src) ) {
if( sd )
clif->skill_fail(sd,skill_id,USESKILL_FAIL,0);
return 1;
@@ -9789,7 +9820,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
break;
case RG_CLEANER: // [Valaris]
i = skill->get_splash(skill_id, skill_lv);
- map_foreachinarea(skill->graffitiremover,src->m,x-i,y-i,x+i,y+i,BL_SKILL);
+ iMap->foreachinarea(skill->graffitiremover,src->m,x-i,y-i,x+i,y+i,BL_SKILL);
break;
case SO_WARMER:
@@ -9866,8 +9897,8 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
md->master_id = src->id;
md->special_state.ai = (skill_id == AM_SPHEREMINE) ? AI_SPHERE : AI_FLORA;
if( md->deletetimer != INVALID_TIMER )
- delete_timer(md->deletetimer, mob_timer_delete);
- md->deletetimer = add_timer (gettick() + skill->get_time(skill_id,skill_lv), mob_timer_delete, md->bl.id, 0);
+ iTimer->delete_timer(md->deletetimer, mob_timer_delete);
+ md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id,skill_lv), mob_timer_delete, md->bl.id, 0);
mob_spawn (md); //Now it is ready for spawning.
}
}
@@ -9877,7 +9908,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
case CR_SLIMPITCHER:
if (sd) {
int i = skill_lv%11 - 1;
- int j = pc_search_inventory(sd,skill_db[skill_id].itemid[i]);
+ int j = pc->search_inventory(sd,skill_db[skill_id].itemid[i]);
if( j < 0 || skill_db[skill_id].itemid[i] <= 0 || sd->inventory_data[j] == NULL || sd->status.inventory[j].amount < skill_db[skill_id].amount[i] )
{
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
@@ -9889,17 +9920,17 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
run_script(sd->inventory_data[j]->script,0,sd->bl.id,0);
potion_flag = 0;
//Apply skill bonuses
- i = pc_checkskill(sd,CR_SLIMPITCHER)*10
- + pc_checkskill(sd,AM_POTIONPITCHER)*10
- + pc_checkskill(sd,AM_LEARNINGPOTION)*5
- + pc_skillheal_bonus(sd, skill_id);
+ i = pc->checkskill(sd,CR_SLIMPITCHER)*10
+ + pc->checkskill(sd,AM_POTIONPITCHER)*10
+ + pc->checkskill(sd,AM_LEARNINGPOTION)*5
+ + pc->skillheal_bonus(sd, skill_id);
potion_hp = potion_hp * (100+i)/100;
potion_sp = potion_sp * (100+i)/100;
if(potion_hp > 0 || potion_sp > 0) {
i = skill->get_splash(skill_id, skill_lv);
- map_foreachinarea(skill->area_sub,
+ iMap->foreachinarea(skill->area_sub,
src->m,x-i,y-i,x+i,y+i,BL_CHAR,
src,skill_id,skill_lv,tick,flag|BCT_PARTY|BCT_GUILD|1,
skill->castend_nodamage_id);
@@ -9908,7 +9939,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
int i = skill_lv%11 - 1;
struct item_data *item;
i = skill_db[skill_id].itemid[i];
- item = itemdb_search(i);
+ item = itemdb->search(i);
potion_flag = 1;
potion_hp = 0;
potion_sp = 0;
@@ -9921,7 +9952,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
if(potion_hp > 0 || potion_sp > 0) {
i = skill->get_splash(skill_id, skill_lv);
- map_foreachinarea(skill->area_sub,
+ iMap->foreachinarea(skill->area_sub,
src->m,x-i,y-i,x+i,y+i,BL_CHAR,
src,skill_id,skill_lv,tick,flag|BCT_PARTY|BCT_GUILD|1,
skill->castend_nodamage_id);
@@ -9934,7 +9965,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
int dummy = 1;
clif->skill_poseffect(src,skill_id,skill_lv,x,y,tick);
i = skill->get_splash(skill_id, skill_lv);
- map_foreachinarea(skill->cell_overlap, src->m, x-i, y-i, x+i, y+i, BL_SKILL, HW_GANBANTEIN, &dummy, src);
+ iMap->foreachinarea(skill->cell_overlap, src->m, x-i, y-i, x+i, y+i, BL_SKILL, HW_GANBANTEIN, &dummy, src);
} else {
if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 1;
@@ -9950,7 +9981,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
// Plant Cultivation [Celest]
case CR_CULTIVATION:
if (sd) {
- if( map_count_oncell(src->m,x,y,BL_CHAR) > 0 )
+ if( iMap->count_oncell(src->m,x,y,BL_CHAR) > 0 )
{
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 1;
@@ -9965,8 +9996,8 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
if ((i = skill->get_time(skill_id, skill_lv)) > 0)
{
if( md->deletetimer != INVALID_TIMER )
- delete_timer(md->deletetimer, mob_timer_delete);
- md->deletetimer = add_timer (tick + i, mob_timer_delete, md->bl.id, 0);
+ iTimer->delete_timer(md->deletetimer, mob_timer_delete);
+ md->deletetimer = iTimer->add_timer (tick + i, mob_timer_delete, md->bl.id, 0);
}
mob_spawn (md);
}
@@ -10017,14 +10048,15 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
case NC_COLDSLOWER:
case NC_ARMSCANNON:
case RK_DRAGONBREATH:
+ case RK_DRAGONBREATH_WATER:
i = skill->get_splash(skill_id,skill_lv);
- map_foreachinarea(skill->area_sub,src->m,x-i,y-i,x+i,y+i,splash_target(src),
+ iMap->foreachinarea(skill->area_sub,src->m,x-i,y-i,x+i,y+i,splash_target(src),
src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
break;
case SO_ARRULLO:
i = skill->get_splash(skill_id,skill_lv);
- map_foreachinarea(skill->area_sub,src->m,x-i,y-i,x+i,y+i,splash_target(src),
+ iMap->foreachinarea(skill->area_sub,src->m,x-i,y-i,x+i,y+i,splash_target(src),
src, skill_id, skill_lv, tick, flag|BCT_ENEMY|1, skill->castend_nodamage_id);
break;
/**
@@ -10046,24 +10078,13 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
case AB_EPICLESIS:
if( (sg = skill->unitsetting(src, skill_id, skill_lv, x, y, 0)) ) {
i = sg->unit->range;
- map_foreachinarea(skill->area_sub, src->m, x - i, y - i, x + i, y + i, BL_CHAR, src, ALL_RESURRECTION, 1, tick, flag|BCT_NOENEMY|1,skill->castend_nodamage_id);
+ iMap->foreachinarea(skill->area_sub, src->m, x - i, y - i, x + i, y + i, BL_CHAR, src, ALL_RESURRECTION, 1, tick, flag|BCT_NOENEMY|1,skill->castend_nodamage_id);
}
break;
- /**
- * Warlock
- **/
- case WL_COMET:
- if( sc ) {
- sc->comet_x = x;
- sc->comet_y = y;
- }
- i = skill->get_splash(skill_id,skill_lv);
- map_foreachinarea(skill->area_sub,src->m,x-i,y-i,x+i,y+i,splash_target(src),src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
- break;
case WL_EARTHSTRAIN:
{
- int i, wave = skill_lv + 4, dir = map_calc_dir(src,x,y);
+ int i, wave = skill_lv + 4, dir = iMap->calc_dir(src,x,y);
int sx = x = src->x, sy = y = src->y; // Store first caster's location to avoid glitch on unit setting
for( i = 1; i <= wave; i++ )
@@ -10074,7 +10095,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
case 2: sx = x - i; break;
case 6: sx = x + i; break;
}
- skill->addtimerskill(src,gettick() + (150 * i),0,sx,sy,skill_id,skill_lv,dir,flag&2);
+ skill->addtimerskill(src,iTimer->gettick() + (50 * i),0,sx,sy,skill_id,skill_lv,dir,flag&2);
}
}
break;
@@ -10083,7 +10104,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
**/
case RA_DETONATOR:
i = skill->get_splash(skill_id, skill_lv);
- map_foreachinarea(skill->detonator, src->m, x-i, y-i, x+i, y+i, BL_SKILL, src);
+ iMap->foreachinarea(skill->detonator, src->m, x-i, y-i, x+i, y+i, BL_SKILL, src);
clif->skill_damage(src, src, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6);
break;
/**
@@ -10094,7 +10115,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
skill->clear_unitgroup(src); // To remove previous skills - cannot used combined
if( (sg = skill->unitsetting(src,skill_id,skill_lv,src->x,src->y,0)) != NULL ) {
sc_start2(src,skill_id == NC_NEUTRALBARRIER ? SC_NEUTRALBARRIER_MASTER : SC_STEALTHFIELD_MASTER,100,skill_lv,sg->group_id,skill->get_time(skill_id,skill_lv));
- if( sd ) pc_overheat(sd,1);
+ if( sd ) pc->overheat(sd,1);
}
break;
@@ -10109,8 +10130,8 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
md->master_id = src->id;
md->special_state.ai = AI_FLORA;
if( md->deletetimer != INVALID_TIMER )
- delete_timer(md->deletetimer, mob_timer_delete);
- md->deletetimer = add_timer (gettick() + skill->get_time(skill_id, skill_lv), mob_timer_delete, md->bl.id, 0);
+ iTimer->delete_timer(md->deletetimer, mob_timer_delete);
+ md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob_timer_delete, md->bl.id, 0);
mob_spawn( md );
}
}
@@ -10121,10 +10142,10 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
break;
case SC_FEINTBOMB:
- clif->skill_nodamage(src,src,skill_id,skill_lv,1);
skill->unitsetting(src,skill_id,skill_lv,x,y,0); // Set bomb on current Position
+ clif->skill_nodamage(src,src,skill_id,skill_lv,1);
if( skill->blown(src,src,6,unit_getdir(src),0) )
- skill->castend_nodamage_id(src,src,TF_HIDING,1,tick,0);
+ skill->castend_nodamage_id(src,src,TF_HIDING,1,tick,0x2);
break;
case LG_OVERBRAND:
@@ -10132,10 +10153,10 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
int width;//according to data from irowiki it actually is a square
for( width = 0; width < 7; width++ )
for( i = 0; i < 7; i++ )
- map_foreachincell(skill->area_sub, src->m, x-2+i, y-2+width, splash_target(src), src, LG_OVERBRAND_BRANDISH, skill_lv, tick, flag|BCT_ENEMY,skill->castend_damage_id);
+ iMap->foreachincell(skill->area_sub, src->m, x-2+i, y-2+width, splash_target(src), src, LG_OVERBRAND_BRANDISH, skill_lv, tick, flag|BCT_ENEMY,skill->castend_damage_id);
for( width = 0; width < 7; width++ )
for( i = 0; i < 7; i++ )
- map_foreachincell(skill->area_sub, src->m, x-2+i, y-2+width, splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY,skill->castend_damage_id);
+ iMap->foreachincell(skill->area_sub, src->m, x-2+i, y-2+width, splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY,skill->castend_damage_id);
}
break;
@@ -10144,7 +10165,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
status_change_end(src,SC_BANDING,INVALID_TIMER);
else if( (sg = skill->unitsetting(src,skill_id,skill_lv,src->x,src->y,0)) != NULL ) {
sc_start4(src,SC_BANDING,100,skill_lv,0,0,sg->group_id,skill->get_time(skill_id,skill_lv));
- if( sd ) pc_banding(sd,skill_lv);
+ if( sd ) pc->banding(sd,skill_lv);
}
clif->skill_nodamage(src,src,skill_id,skill_lv,1);
break;
@@ -10152,7 +10173,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
case LG_RAYOFGENESIS:
if( status_charge(src,status_get_max_hp(src)*3*skill_lv / 100,0) ) {
i = skill->get_splash(skill_id,skill_lv);
- map_foreachinarea(skill->area_sub,src->m,x-i,y-i,x+i,y+i,splash_target(src),
+ iMap->foreachinarea(skill->area_sub,src->m,x-i,y-i,x+i,y+i,splash_target(src),
src,skill_id,skill_lv,tick,flag|BCT_ENEMY|1,skill->castend_damage_id);
} else if( sd )
clif->skill_fail(sd,skill_id,USESKILL_FAIL,0);
@@ -10160,13 +10181,13 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
case WM_DOMINION_IMPULSE:
i = skill->get_splash(skill_id, skill_lv);
- map_foreachinarea( skill->activate_reverberation,
+ iMap->foreachinarea( skill->activate_reverberation,
src->m, x-i, y-i, x+i,y+i,BL_SKILL);
break;
case WM_GREAT_ECHO:
flag|=1; // Should counsume 1 item per skill usage.
- map_foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY, skill->castend_damage_id);
+ iMap->foreachinrange(skill->area_sub, src, skill->get_splash(skill_id,skill_lv),splash_target(src), src, skill_id, skill_lv, tick, flag|BCT_ENEMY, skill->castend_damage_id);
break;
case GN_CRAZYWEED: {
int area = skill->get_splash(GN_CRAZYWEED_ATK, skill_lv);
@@ -10198,10 +10219,10 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
clif->changetraplook(&ud->skillunit[i]->unit->bl, UNT_FIRE_EXPANSION_TEAR_GAS);
break;
case 5:
- map_foreachinarea(skill->area_sub, src->m,
+ iMap->foreachinarea(skill->area_sub, src->m,
ud->skillunit[i]->unit->bl.x - 3, ud->skillunit[i]->unit->bl.y - 3,
ud->skillunit[i]->unit->bl.x + 3, ud->skillunit[i]->unit->bl.y + 3, BL_CHAR,
- src, CR_ACIDDEMONSTRATION, sd ? pc_checkskill(sd, CR_ACIDDEMONSTRATION) : skill_lv, tick, flag|BCT_ENEMY|1|SD_LEVEL, skill->castend_damage_id);
+ src, CR_ACIDDEMONSTRATION, sd ? pc->checkskill(sd, CR_ACIDDEMONSTRATION) : skill_lv, tick, flag|BCT_ENEMY|1|SD_LEVEL, skill->castend_damage_id);
skill->delunit(ud->skillunit[i]->unit);
break;
default:
@@ -10244,7 +10265,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
status_change_end(src,SC_CURSEDCIRCLE_ATKER,INVALID_TIMER);
if( sd ) {// ensure that the skill last-cast tick is recorded
- sd->canskill_tick = gettick();
+ sd->canskill_tick = iTimer->gettick();
if( sd->state.arrow_atk && !(flag&1) ) {
// consume arrow if this is a ground skill
@@ -10258,141 +10279,6 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
return 0;
}
-/*==========================================
- *
- *------------------------------------------*/
-int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char *map)
-{
- nullpo_ret(sd);
-
-//Simplify skill_failed code.
-#define skill_failed(sd) { sd->menuskill_id = sd->menuskill_val = 0; }
- if(skill_id != sd->menuskill_id)
- return 0;
-
- if( sd->bl.prev == NULL || pc_isdead(sd) ) {
- skill_failed(sd);
- return 0;
- }
-
- if( ( sd->sc.opt1 && sd->sc.opt1 != OPT1_BURNING ) || sd->sc.option&OPTION_HIDE ) {
- skill_failed(sd);
- return 0;
- }
- if(sd->sc.count && (
- sd->sc.data[SC_SILENCE] ||
- sd->sc.data[SC_ROKISWEIL] ||
- sd->sc.data[SC_AUTOCOUNTER] ||
- sd->sc.data[SC_STEELBODY] ||
- (sd->sc.data[SC_DANCING] && skill_id < RK_ENCHANTBLADE && !pc_checkskill(sd, WM_LESSON)) ||
- sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
- sd->sc.data[SC_BASILICA] ||
- sd->sc.data[SC_MARIONETTE] ||
- sd->sc.data[SC_WHITEIMPRISON] ||
- (sd->sc.data[SC_STASIS] && skill->block_check(&sd->bl, SC_STASIS, skill_id)) ||
- (sd->sc.data[SC_KAGEHUMI] && skill->block_check(&sd->bl, SC_KAGEHUMI, skill_id)) ||
- sd->sc.data[SC_OBLIVIONCURSE] ||
- sd->sc.data[SC__MANHOLE] ||
- (sd->sc.data[SC_ASH] && rnd()%2) //50% fail chance under ASH
- )) {
- skill_failed(sd);
- return 0;
- }
-
- pc_stop_attack(sd);
- pc_stop_walking(sd,0);
-
- if(battle_config.skill_log && battle_config.skill_log&BL_PC)
- ShowInfo("PC %d skill castend skill =%d map=%s\n",sd->bl.id,skill_id,map);
-
- if(strcmp(map,"cancel")==0) {
- skill_failed(sd);
- return 0;
- }
-
- switch(skill_id) {
- case AL_TELEPORT:
- if(strcmp(map,"Random")==0)
- pc_randomwarp(sd,CLR_TELEPORT);
- else if (sd->menuskill_val > 1) //Need lv2 to be able to warp here.
- pc_setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
- break;
-
- case AL_WARP:
- {
- const struct point *p[4];
- struct skill_unit_group *group;
- int i, lv, wx, wy;
- int maxcount=0;
- int x,y;
- unsigned short mapindex;
-
- mapindex = mapindex_name2id((char*)map);
- if(!mapindex) { //Given map not found?
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- skill_failed(sd);
- return 0;
- }
- p[0] = &sd->status.save_point;
- p[1] = &sd->status.memo_point[0];
- p[2] = &sd->status.memo_point[1];
- p[3] = &sd->status.memo_point[2];
-
- if((maxcount = skill->get_maxcount(skill_id, sd->menuskill_val)) > 0) {
- for(i=0;i<MAX_SKILLUNITGROUP && sd->ud.skillunit[i] && maxcount;i++) {
- if(sd->ud.skillunit[i]->skill_id == skill_id)
- maxcount--;
- }
- if(!maxcount) {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
- skill_failed(sd);
- return 0;
- }
- }
-
- lv = sd->skillitem==skill_id?sd->skillitemlv:pc_checkskill(sd,skill_id);
- wx = sd->menuskill_val>>16;
- wy = sd->menuskill_val&0xffff;
-
- if( lv <= 0 ) return 0;
- if( lv > 4 ) lv = 4; // crash prevention
-
- // check if the chosen map exists in the memo list
- ARR_FIND( 0, lv, i, mapindex == p[i]->map );
- if( i < lv ) {
- x=p[i]->x;
- y=p[i]->y;
- } else {
- skill_failed(sd);
- return 0;
- }
-
- if(!skill->check_condition_castend(sd, sd->menuskill_id, lv)) { // This checks versus skill_id/skill_lv...
- skill_failed(sd);
- return 0;
- }
-
- skill->consume_requirement(sd,sd->menuskill_id,lv,2);
- sd->skillitem = sd->skillitemlv = 0; // Clear data that's skipped in 'skill_castend_pos' [Inkfish]
-
- if((group=skill->unitsetting(&sd->bl,skill_id,lv,wx,wy,0))==NULL) {
- skill_failed(sd);
- return 0;
- }
-
- group->val1 = (group->val1<<16)|(short)0;
- // record the destination coordinates
- group->val2 = (x<<16)|y;
- group->val3 = mapindex;
- }
- break;
- }
-
- sd->menuskill_id = sd->menuskill_val = 0;
- return 0;
-#undef skill_failed
-}
-
/// transforms 'target' skill unit into dissonance (if conditions are met)
int skill_dance_overlap_sub(struct block_list* bl, va_list ap) {
struct skill_unit* target = (struct skill_unit*)bl;
@@ -10431,7 +10317,7 @@ int skill_dance_overlap(struct skill_unit* unit, int flag) {
unit->val2 &= ~UF_ENSEMBLE;
}
- return map_foreachincell(skill->dance_overlap_sub, unit->bl.m,unit->bl.x,unit->bl.y,BL_SKILL, unit,flag);
+ return iMap->foreachincell(skill->dance_overlap_sub, unit->bl.m,unit->bl.x,unit->bl.y,BL_SKILL, unit,flag);
}
/*==========================================
@@ -10494,14 +10380,14 @@ int skill_icewall_block(struct block_list *bl,va_list ap) {
nullpo_ret(bl);
nullpo_ret(md);
- if( !md->target_id || ( target = map_id2bl(md->target_id) ) == NULL )
+ if( !md->target_id || ( target = iMap->id2bl(md->target_id) ) == NULL )
return 0;
if( path_search_long(NULL,bl->m,bl->x,bl->y,target->x,target->y,CELL_CHKICEWALL) )
return 0;
if( !check_distance_bl(bl, target, status_get_range(bl) ) ) {
- mob_unlocktarget(md,gettick());
+ mob_unlocktarget(md,iTimer->gettick());
mob_stop_walking(md,1);
}
@@ -10572,7 +10458,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
{ //Warp Portal morphing to active mode, extract relevant data from src. [Skotlex]
if( src->type != BL_SKILL ) return NULL;
group = ((TBL_SKILL*)src)->group;
- src = map_id2bl(group->src_id);
+ src = iMap->id2bl(group->src_id);
if( !src ) return NULL;
val2 = group->val2; //Copy the (x,y) position you warp to
val3 = group->val3; //as well as the mapindex to warp to.
@@ -10588,7 +10474,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
break;
case WZ_FIREPILLAR:
- if( map_getcell(src->m, x, y, CELL_CHKLANDPROTECTOR) )
+ if( iMap->getcell(src->m, x, y, CELL_CHKLANDPROTECTOR) )
return NULL;
if((flag&1)!=0)
limit=1000;
@@ -10653,7 +10539,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
old_sg->skill_id == SA_VIOLENTGALE
) && old_sg->limit > 0)
{ //Use the previous limit (minus the elapsed time) [Skotlex]
- limit = old_sg->limit - DIFF_TICK(gettick(), old_sg->tick);
+ limit = old_sg->limit - DIFF_TICK(iTimer->gettick(), old_sg->tick);
if (limit < 0) //This can happen...
limit = skill->get_time(skill_id,skill_lv);
}
@@ -10670,8 +10556,8 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
val1 = skill_lv +status->agi/10; // Flee increase
val2 = ((skill_lv+1)/2)+status->luk/10; // Perfect dodge increase
if(sd){
- val1 += pc_checkskill(sd,BA_MUSICALLESSON);
- val2 += pc_checkskill(sd,BA_MUSICALLESSON);
+ val1 += pc->checkskill(sd,BA_MUSICALLESSON);
+ val2 += pc->checkskill(sd,BA_MUSICALLESSON);
}
break;
case DC_HUMMING:
@@ -10680,47 +10566,58 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
val1 *= 2;
#endif
if(sd)
- val1 += pc_checkskill(sd,DC_DANCINGLESSON);
+ val1 += pc->checkskill(sd,DC_DANCINGLESSON);
break;
case BA_POEMBRAGI:
val1 = 3*skill_lv+status->dex/10; // Casting time reduction
//For some reason at level 10 the base delay reduction is 50%.
val2 = (skill_lv<10?3*skill_lv:50)+status->int_/5; // After-cast delay reduction
if(sd){
- val1 += 2*pc_checkskill(sd,BA_MUSICALLESSON);
- val2 += 2*pc_checkskill(sd,BA_MUSICALLESSON);
+ val1 += 2*pc->checkskill(sd,BA_MUSICALLESSON);
+ val2 += 2*pc->checkskill(sd,BA_MUSICALLESSON);
}
break;
case DC_DONTFORGETME:
+#ifdef RENEWAL
+ val1 = status->dex/10 + 3*skill_lv; // ASPD decrease
+ val2 = status->agi/10 + 2*skill_lv; // Movement speed adjustment.
+#else
val1 = status->dex/10 + 3*skill_lv + 5; // ASPD decrease
val2 = status->agi/10 + 3*skill_lv + 5; // Movement speed adjustment.
+#endif
if(sd){
- val1 += pc_checkskill(sd,DC_DANCINGLESSON);
- val2 += pc_checkskill(sd,DC_DANCINGLESSON);
+ val1 += pc->checkskill(sd,DC_DANCINGLESSON);
+ val2 += pc->checkskill(sd,DC_DANCINGLESSON);
}
break;
case BA_APPLEIDUN:
val1 = 5+2*skill_lv+status->vit/10; // MaxHP percent increase
if(sd)
- val1 += pc_checkskill(sd,BA_MUSICALLESSON);
+ val1 += pc->checkskill(sd,BA_MUSICALLESSON);
break;
case DC_SERVICEFORYOU:
val1 = 15+skill_lv+(status->int_/10); // MaxSP percent increase TO-DO: this INT bonus value is guessed
val2 = 20+3*skill_lv+(status->int_/10); // SP cost reduction
if(sd){
- val1 += pc_checkskill(sd,DC_DANCINGLESSON); //TO-DO This bonus value is guessed
- val2 += pc_checkskill(sd,DC_DANCINGLESSON); //TO-DO Should be half this value
+ val1 += pc->checkskill(sd,DC_DANCINGLESSON); //TO-DO This bonus value is guessed
+ val2 += pc->checkskill(sd,DC_DANCINGLESSON); //TO-DO Should be half this value
}
break;
case BA_ASSASSINCROSS:
+#ifdef RENEWAL
+ val1 = 10 + skill_lv + (status->agi/10); // ASPD increase
+ if(sd)
+ val1 += 4*pc->checkskill(sd,BA_MUSICALLESSON);
+#else
val1 = 100+(10*skill_lv)+(status->agi/10); // ASPD increase
if(sd)
- val1 += 5*pc_checkskill(sd,BA_MUSICALLESSON);
+ val1 += 5*pc->checkskill(sd,BA_MUSICALLESSON);
+#endif
break;
case DC_FORTUNEKISS:
val1 = 10+skill_lv+(status->luk/10); // Critical increase
if(sd)
- val1 += pc_checkskill(sd,DC_DANCINGLESSON);
+ val1 += pc->checkskill(sd,DC_DANCINGLESSON);
val1*=10; //Because every 10 crit is an actual cri point.
break;
case BD_DRUMBATTLEFIELD:
@@ -10802,6 +10699,12 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
case GD_HAWKEYES:
limit = 1000000;//it doesn't matter
break;
+ case WL_COMET:
+ if( sc ) {
+ sc->comet_x = x;
+ sc->comet_y = y;
+ }
+ break;
case LG_BANDING:
limit = -1;
break;
@@ -10809,7 +10712,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
interval = limit;
val2 = 1;
case WM_POEMOFNETHERWORLD: // Can't be placed on top of Land Protector.
- if( map_getcell(src->m, x, y, CELL_CHKLANDPROTECTOR) )
+ if( iMap->getcell(src->m, x, y, CELL_CHKLANDPROTECTOR) )
return NULL;
break;
case SO_CLOUD_KILL:
@@ -10820,7 +10723,6 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
break;
case SO_VACUUM_EXTREME:
range++;
-
break;
case SC_BLOODYLUST:
skill->clear_group(src, 32);
@@ -10832,13 +10734,13 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
break;
case KO_ZENKAI:
if( sd ){
- ARR_FIND(1, 6, i, sd->talisman[i] > 0);
+ ARR_FIND(1, 6, i, sd->charm[i] > 0);
if( i < 5 ){
- val1 = sd->talisman[i]; // no. of aura
+ val1 = sd->charm[i]; // no. of aura
val2 = i; // aura type
limit += val1 * 1000;
subunt = i - 1;
- pc_del_talisman(sd, sd->talisman[i], i);
+ pc->del_charm(sd, sd->charm[i], i);
}
}
break;
@@ -10855,7 +10757,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
group->state.guildaura = ( skill_id >= GD_LEADERSHIP && skill_id <= GD_HAWKEYES )?1:0;
group->item_id = req_item;
//if tick is greater than current, do not invoke onplace function just yet. [Skotlex]
- if (DIFF_TICK(group->tick, gettick()) > SKILLUNITTIMER_INTERVAL)
+ if (DIFF_TICK(group->tick, iTimer->gettick()) > SKILLUNITTIMER_INTERVAL)
active_flag = 0;
if(skill_id==HT_TALKIEBOX || skill_id==RG_GRAFFITI){
@@ -10888,7 +10790,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
int val2 = 0;
int alive = 1;
- if( !group->state.song_dance && !map_getcell(src->m,ux,uy,CELL_CHKREACH) )
+ if( !group->state.song_dance && !iMap->getcell(src->m,ux,uy,CELL_CHKREACH) )
continue; // don't place skill units on walls (except for songs/dances/encores)
if( battle_config.skill_wall_check && skill->get_unit_flag(skill_id)&UF_PATHCHECK && !path_search_long(NULL,src->m,ux,uy,x,y,CELL_CHKWALL) )
continue; // no path between cell and center of casting.
@@ -10900,7 +10802,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
break;
case WZ_ICEWALL:
val1 = (skill_lv <= 1) ? 500 : 200 + 200*skill_lv;
- val2 = map_getcell(src->m, ux, uy, CELL_GETTYPE);
+ val2 = iMap->getcell(src->m, ux, uy, CELL_GETTYPE);
break;
case HT_LANDMINE:
case MA_LANDMINE:
@@ -10953,7 +10855,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
val2 |= UF_RANGEDSINGLEUNIT; // center.
if( range <= 0 )
- map_foreachincell(skill->cell_overlap,src->m,ux,uy,BL_SKILL,skill_id, &alive, src);
+ iMap->foreachincell(skill->cell_overlap,src->m,ux,uy,BL_SKILL,skill_id, &alive, src);
if( !alive )
continue;
@@ -10969,7 +10871,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
// execute on all targets standing on this cell
if (range==0 && active_flag)
- map_foreachincell(skill->unit_effect,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,gettick(),1);
+ iMap->foreachincell(skill->unit_effect,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,iTimer->gettick(),1);
}
if (!group->alive_count) { //No cells? Something that was blocked completely by Land Protector?
@@ -10980,7 +10882,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
//success, unit created.
switch( skill_id ) {
case WZ_ICEWALL:
- map_foreachinrange(skill->icewall_block, src, AREA_SIZE, BL_MOB);
+ iMap->foreachinrange(skill->icewall_block, src, AREA_SIZE, BL_MOB);
break;
case NJ_TATAMIGAESHI: //Store number of tiles.
group->val1 = group->alive_count;
@@ -11008,9 +10910,9 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned
return 0;
nullpo_ret(sg=src->group);
- nullpo_ret(ss=map_id2bl(sg->src_id));
+ nullpo_ret(ss=iMap->id2bl(sg->src_id));
- if( skill->get_type(sg->skill_id) == BF_MAGIC && map_getcell(bl->m, bl->x, bl->y, CELL_CHKLANDPROTECTOR) && sg->skill_id != SA_LANDPROTECTOR )
+ if( skill->get_type(sg->skill_id) == BF_MAGIC && iMap->getcell(bl->m, bl->x, bl->y, CELL_CHKLANDPROTECTOR) && sg->skill_id != SA_LANDPROTECTOR )
return 0; //AoE skills are ineffective. [Skotlex]
sc = status_get_sc(bl);
@@ -11030,10 +10932,10 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned
} else if( sc && battle->check_target(&sg->unit->bl,bl,sg->target_flag) > 0 ) {
int sec = skill->get_time2(sg->skill_id,sg->skill_lv);
if( status_change_start(bl,type,10000,sg->skill_lv,1,sg->group_id,0,sec,8) ) {
- const struct TimerData* td = sc->data[type]?get_timer(sc->data[type]->timer):NULL;
+ const struct TimerData* td = sc->data[type]?iTimer->get_timer(sc->data[type]->timer):NULL;
if( td )
sec = DIFF_TICK(td->tick, tick);
- map_moveblock(bl, src->bl.x, src->bl.y, tick);
+ iMap->moveblock(bl, src->bl.x, src->bl.y, tick);
clif->fixpos(bl);
sg->val2 = bl->id;
}
@@ -11058,11 +10960,11 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned
break; //Does not affect the caster.
if (!sce) {
TBL_PC *sd = BL_CAST(BL_PC, bl); //prevent fullheal exploit
- if (sd && sd->bloodylust_tick && DIFF_TICK(gettick(), sd->bloodylust_tick) < skill->get_time2(SC_BLOODYLUST, 1))
+ if (sd && sd->bloodylust_tick && DIFF_TICK(iTimer->gettick(), sd->bloodylust_tick) < skill->get_time2(SC_BLOODYLUST, 1))
clif->skill_nodamage(&src->bl,bl,sg->skill_id,sg->skill_lv,
sc_start4(bl, type, 100, sg->skill_lv, 1, 0, 0, skill->get_time(LK_BERSERK, sg->skill_lv)));
else {
- if (sd) sd->bloodylust_tick = gettick();
+ if (sd) sd->bloodylust_tick = iTimer->gettick();
clif->skill_nodamage(&src->bl,bl,sg->skill_id,sg->skill_lv,
sc_start4(bl, type, 100, sg->skill_lv, 0, 0, 0, skill->get_time(LK_BERSERK, sg->skill_lv)));
}
@@ -11085,15 +10987,15 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned
if( --count <= 0 )
skill->del_unitgroup(sg,ALC_MARK);
- if ( map_mapindex2mapid(sg->val3) == sd->bl.m && x == sd->bl.x && y == sd->bl.y )
+ if ( iMap->mapindex2mapid(sg->val3) == sd->bl.m && x == sd->bl.x && y == sd->bl.y )
working = 1;/* we break it because officials break it, lovely stuff. */
sg->val1 = (count<<16)|working;
- pc_setpos(sd,m,x,y,CLR_TELEPORT);
+ pc->setpos(sd,m,x,y,CLR_TELEPORT);
}
} else if(bl->type == BL_MOB && battle_config.mob_warp&2) {
- int16 m = map_mapindex2mapid(sg->val3);
+ int16 m = iMap->mapindex2mapid(sg->val3);
if (m < 0) break; //Map not available on this map-server.
unit_warp(bl,m,sg->val2>>16,sg->val2&0xffff,CLR_TELEPORT);
}
@@ -11130,7 +11032,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned
case UNT_INTOABYSS:
case UNT_SIEGFRIED:
//Needed to check when a dancer/bard leaves their ensemble area.
- if (sg->src_id==bl->id && !(sc && sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_BARDDANCER))
+ if (sg->src_id==bl->id && !(sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_BARDDANCER))
return skill_id;
if (!sce)
sc_start4(bl,type,100,sg->skill_lv,sg->val1,sg->val2,0,sg->limit);
@@ -11143,7 +11045,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned
case UNT_DONTFORGETME:
case UNT_FORTUNEKISS:
case UNT_SERVICEFORYOU:
- if (sg->src_id==bl->id && !(sc && sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_BARDDANCER))
+ if (sg->src_id==bl->id && !(sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_BARDDANCER))
return 0;
if (!sc) return 0;
@@ -11152,8 +11054,8 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned
else if (sce->val4 == 1) {
//Readjust timers since the effect will not last long.
sce->val4 = 0;
- delete_timer(sce->timer, status_change_timer);
- sce->timer = add_timer(tick+sg->limit, status_change_timer, bl->id, type);
+ iTimer->delete_timer(sce->timer, status_change_timer);
+ sce->timer = iTimer->add_timer(tick+sg->limit, status_change_timer, bl->id, type);
}
break;
@@ -11196,7 +11098,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned
case UNT_VOLCANIC_ASH:
if (!sce)
- sc_start(bl, SC_ASH, 100, sg->skill_lv, skill->get_time(MH_VOLCANIC_ASH, sg->skill_lv));
+ sc_start(bl, SC_VOLCANIC_ASH, 100, sg->skill_lv, skill->get_time(MH_VOLCANIC_ASH, sg->skill_lv));
break;
case UNT_GD_LEADERSHIP:
@@ -11231,7 +11133,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
return 0;
nullpo_ret(sg=src->group);
- nullpo_ret(ss=map_id2bl(sg->src_id));
+ nullpo_ret(ss=iMap->id2bl(sg->src_id));
tsd = BL_CAST(BL_PC, bl);
tsc = status_get_sc(bl);
@@ -11263,7 +11165,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
ts->tick = tick+sg->interval;
if ((skill_id==CR_GRANDCROSS || skill_id==NPC_GRANDDARKNESS) && !battle_config.gx_allhit)
- ts->tick += sg->interval*(map_count_oncell(bl->m,bl->x,bl->y,BL_CHAR)-1);
+ ts->tick += sg->interval*(iMap->count_oncell(bl->m,bl->x,bl->y,BL_CHAR)-1);
}
switch (sg->unit_id) {
@@ -11413,7 +11315,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
if( sg->val2 == 0 && tsc && (sg->unit_id == UNT_ANKLESNARE || bl->id != sg->src_id) ) {
int sec = skill->get_time2(sg->skill_id,sg->skill_lv);
if( status_change_start(bl,type,10000,sg->skill_lv,sg->group_id,0,0,sec, 8) ) {
- const struct TimerData* td = tsc->data[type]?get_timer(tsc->data[type]->timer):NULL;
+ const struct TimerData* td = tsc->data[type]?iTimer->get_timer(tsc->data[type]->timer):NULL;
if( td )
sec = DIFF_TICK(td->tick, tick);
if( sg->unit_id == UNT_MANHOLE || battle_config.skill_trap_type || !map_flag_gvg(src->bl.m) ) {
@@ -11444,12 +11346,12 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
break;
if( status_change_start(bl,type,10000,sg->skill_lv,sg->group_id,0,0,skill->get_time2(sg->skill_id, sg->skill_lv), 8) ) {
- map_moveblock(bl, src->bl.x, src->bl.y, tick);
+ iMap->moveblock(bl, src->bl.x, src->bl.y, tick);
clif->fixpos(bl);
}
- map_foreachinrange(skill->trap_splash, &src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl, tick);
+ iMap->foreachinrange(skill->trap_splash, &src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl, tick);
sg->unit_id = UNT_USED_TRAPS; //Changed ID so it does not invoke a for each in area again.
}
break;
@@ -11479,7 +11381,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
case UNT_FLASHER:
case UNT_FREEZINGTRAP:
case UNT_FIREPILLAR_ACTIVE:
- map_foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl,tick);
+ iMap->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl,tick);
if (sg->unit_id != UNT_FIREPILLAR_ACTIVE)
clif->changetraplook(&src->bl, sg->unit_id==UNT_LANDMINE?UNT_FIREPILLAR_ACTIVE:UNT_USED_TRAPS);
sg->limit=DIFF_TICK(tick,sg->tick)+1500 +
@@ -11522,7 +11424,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
if( md && md->class_ == MOBID_EMPERIUM )
break;
#endif
- if( sg->src_id == bl->id && !(tsc && tsc->data[SC_SPIRIT] && tsc->data[SC_SPIRIT]->val2 == SL_BARDDANCER) )
+ if( sg->src_id == bl->id && !(tsc && tsc->data[SC_SOULLINK] && tsc->data[SC_SOULLINK]->val2 == SL_BARDDANCER) )
break; // affects self only when soullinked
heal = skill->calc_heal(ss,bl,sg->skill_id, sg->skill_lv, true);
if( tsc->data[SC_AKAITSUKI] && heal )
@@ -11553,7 +11455,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
status_heal(bl,heal,0,0);
break;
case 1: // End all negative status
- status_change_clear_buffs(bl,6);
+ status_change_clear_buffs(bl,2);
if (tsd) clif->gospel_info(tsd, 0x15);
break;
case 2: // Immunity to all status
@@ -11576,7 +11478,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
sc_start(bl,SC_BLESSING,100,10,time);
break;
case 7: // Level 10 Increase AGI
- sc_start(bl,SC_INCREASEAGI,100,10,time);
+ sc_start(bl,SC_INC_AGI,100,10,time);
break;
case 8: // Enchant weapon with Holy element
sc_start(bl,SC_ASPERSIO,100,1,time);
@@ -11657,6 +11559,8 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
case UNT_FIREWALK:
case UNT_ELECTRICWALK:
case UNT_PSYCHIC_WAVE:
+ case UNT_MAGMA_ERUPTION:
+ case UNT_MAKIBISHI:
skill->attack(skill->get_type(sg->skill_id),ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0);
break;
@@ -11665,7 +11569,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
case UNT_GROUNDDRIFT_POISON:
case UNT_GROUNDDRIFT_WATER:
case UNT_GROUNDDRIFT_FIRE:
- map_foreachinrange(skill->trap_splash,&src->bl,
+ iMap->foreachinrange(skill->trap_splash,&src->bl,
skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag,
&src->bl,tick);
sg->unit_id = UNT_USED_TRAPS;
@@ -11702,7 +11606,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
}
}
/* Enable this if kRO fix the current skill. Currently no damage on undead and demon monster. [Jobbie]
- else if( battle->check_target(ss, bl, BCT_ENEMY) > 0 && battle_check_undead(tstatus->race, tstatus->def_ele) )
+ else if( battle->check_target(ss, bl, BCT_ENEMY) > 0 && battle->check_undead(tstatus->race, tstatus->def_ele) )
skill->castend_damage_id(&src->bl, bl, sg->skill_id, sg->skill_lv, 0, 0);*/
break;
@@ -11715,14 +11619,14 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
case UNT_DIMENSIONDOOR:
if( tsd && !map[bl->m].flag.noteleport )
- pc_randomwarp(tsd,3);
+ pc->randomwarp(tsd,3);
else if( bl->type == BL_MOB && battle_config.mob_warp&8 )
unit_warp(bl,-1,-1,-1,3);
break;
case UNT_REVERBERATION:
clif->changetraplook(&src->bl,UNT_USED_TRAPS);
- map_foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl,tick);
+ iMap->foreachinrange(skill->trap_splash,&src->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &src->bl,tick);
sg->limit = DIFF_TICK(tick,sg->tick)+1000;
sg->unit_id = UNT_USED_TRAPS;
break;
@@ -11745,16 +11649,16 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
if( !sg->val2 ) {
int sec = skill->get_time2(sg->skill_id, sg->skill_lv);
if( sc_start(bl, type, 100, sg->skill_lv, sec) ) {
- const struct TimerData* td = tsc->data[type]?get_timer(tsc->data[type]->timer):NULL;
+ const struct TimerData* td = tsc->data[type]?iTimer->get_timer(tsc->data[type]->timer):NULL;
if( td )
sec = DIFF_TICK(td->tick, tick);
- ///map_moveblock(bl, src->bl.x, src->bl.y, tick); // in official server it doesn't behave like this. [malufett]
+ ///iMap->moveblock(bl, src->bl.x, src->bl.y, tick); // in official server it doesn't behave like this. [malufett]
clif->fixpos(bl);
sg->val2 = bl->id;
} else
sec = 3000; // Couldn't trap it?
sg->limit = DIFF_TICK(tick, sg->tick) + sec;
- } else if( tsc->data[SC_THORNSTRAP] && bl->id == sg->val2 )
+ } else if( tsc->data[SC_THORNS_TRAP] && bl->id == sg->val2 )
skill->attack(skill->get_type(GN_THORNS_TRAP), ss, ss, bl, sg->skill_id, sg->skill_lv, tick, SD_LEVEL|SD_ANIMATION);
}
break;
@@ -11765,14 +11669,14 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
case 1:
case 2:
default:
- sc_start(bl, SC_BURNING, 4 + 4 * sg->skill_lv, sg->skill_lv,
+ sc_start4(bl, SC_BURNING, 4 + 4 * sg->skill_lv, sg->skill_lv, 0, ss->id, 0,
skill->get_time2(sg->skill_id, sg->skill_lv));
skill->attack(skill->get_type(sg->skill_id), ss, &src->bl, bl,
sg->skill_id, sg->skill_lv + 10 * sg->val2, tick, 0);
break;
case 3:
skill->attack(skill->get_type(CR_ACIDDEMONSTRATION), ss, &src->bl, bl,
- CR_ACIDDEMONSTRATION, sd ? pc_checkskill(sd, CR_ACIDDEMONSTRATION) : sg->skill_lv, tick, 0);
+ CR_ACIDDEMONSTRATION, sd ? pc->checkskill(sd, CR_ACIDDEMONSTRATION) : sg->skill_lv, tick, 0);
break;
}
@@ -11882,36 +11786,31 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
case UNT_ZENKAI_WATER:
sc_start(bl, SC_CRYSTALIZE, sg->val1*5, sg->skill_lv, skill->get_time2(sg->skill_id, sg->skill_lv));
sc_start(bl, SC_FREEZE, sg->val1*5, sg->skill_lv, skill->get_time2(sg->skill_id, sg->skill_lv));
- sc_start(bl, SC_FREEZING, sg->val1*5, sg->skill_lv, skill->get_time2(sg->skill_id, sg->skill_lv));
+ sc_start(bl, SC_FROSTMISTY, sg->val1*5, sg->skill_lv, skill->get_time2(sg->skill_id, sg->skill_lv));
break;
case UNT_ZENKAI_LAND:
sc_start(bl, SC_STONE, sg->val1*5, sg->skill_lv, skill->get_time2(sg->skill_id, sg->skill_lv));
sc_start(bl, SC_POISON, sg->val1*5, sg->skill_lv, skill->get_time2(sg->skill_id, sg->skill_lv));
break;
case UNT_ZENKAI_FIRE:
- sc_start(bl, SC_BURNING, sg->val1*5, sg->skill_lv, skill->get_time2(sg->skill_id, sg->skill_lv));
+ sc_start4(bl, SC_BURNING, sg->val1*5, sg->skill_lv, 0, ss->id, 0, skill->get_time2(sg->skill_id, sg->skill_lv));
break;
case UNT_ZENKAI_WIND:
sc_start(bl, SC_SILENCE, sg->val1*5, sg->skill_lv, skill->get_time2(sg->skill_id, sg->skill_lv));
sc_start(bl, SC_SLEEP, sg->val1*5, sg->skill_lv, skill->get_time2(sg->skill_id, sg->skill_lv));
- sc_start(bl, SC_DEEPSLEEP, sg->val1*5, sg->skill_lv, skill->get_time2(sg->skill_id, sg->skill_lv));
+ sc_start(bl, SC_DEEP_SLEEP, sg->val1*5, sg->skill_lv, skill->get_time2(sg->skill_id, sg->skill_lv));
break;
}
}else
sc_start2(bl,type,100,sg->val1,sg->val2,skill->get_time2(sg->skill_id, sg->skill_lv));
break;
- case UNT_MAKIBISHI:
- skill->attack(BF_MISC, ss, &src->bl, bl, sg->skill_id, sg->skill_lv, tick, 0);
- sg->limit = DIFF_TICK(tick, sg->tick);
- sg->unit_id = UNT_USED_TRAPS;
- break;
-
case UNT_LAVA_SLIDE:
skill->attack(BF_WEAPON, ss, &src->bl, bl, sg->skill_id, sg->skill_lv, tick, 0);
if(++sg->val1 > 4) //after 5 stop hit and destroy me
sg->limit = DIFF_TICK(tick, sg->tick);
break;
+
case UNT_POISON_MIST:
skill->attack(BF_MAGIC, ss, &src->bl, bl, sg->skill_id, sg->skill_lv, tick, 0);
status_change_start(bl, SC_BLIND, rnd() % 100 > sg->skill_lv * 10, sg->skill_lv, sg->skill_id, 0, 0, skill->get_time2(sg->skill_id, sg->skill_lv), 2|8);
@@ -11963,7 +11862,7 @@ int skill_unit_onout (struct skill_unit *src, struct block_list *bl, unsigned in
break;
case UNT_SPIDERWEB: {
- struct block_list *target = map_id2bl(sg->val2);
+ struct block_list *target = iMap->id2bl(sg->val2);
if (target && target==bl)
{
if (sce && sce->val3 == sg->group_id)
@@ -12053,11 +11952,11 @@ static int skill_unit_onleft (uint16 skill_id, struct block_list *bl, unsigned i
case DC_FORTUNEKISS:
case DC_SERVICEFORYOU:
if (sce) {
- delete_timer(sce->timer, status_change_timer);
+ iTimer->delete_timer(sce->timer, status_change_timer);
//NOTE: It'd be nice if we could get the skill_lv for a more accurate extra time, but alas...
//not possible on our current implementation.
sce->val4 = 1; //Store the fact that this is a "reduced" duration effect.
- sce->timer = add_timer(tick+skill->get_time2(skill_id,1), status_change_timer, bl->id, type);
+ sce->timer = iTimer->add_timer(tick+skill->get_time2(skill_id,1), status_change_timer, bl->id, type);
}
break;
case PF_FOGWALL:
@@ -12067,8 +11966,8 @@ static int skill_unit_onleft (uint16 skill_id, struct block_list *bl, unsigned i
if (bl->type == BL_PC) //Players get blind ended inmediately, others have it still for 30 secs. [Skotlex]
status_change_end(bl, SC_BLIND, INVALID_TIMER);
else {
- delete_timer(sce->timer, status_change_timer);
- sce->timer = add_timer(30000+tick, status_change_timer, bl->id, SC_BLIND);
+ iTimer->delete_timer(sce->timer, status_change_timer);
+ sce->timer = iTimer->add_timer(30000+tick, status_change_timer, bl->id, SC_BLIND);
}
}
}
@@ -12199,7 +12098,7 @@ int skill_check_condition_char_sub (struct block_list *bl, va_list ap) {
switch(skill_id) {
case PR_BENEDICTIO: {
- uint8 dir = map_calc_dir(&sd->bl,tsd->bl.x,tsd->bl.y);
+ uint8 dir = iMap->calc_dir(&sd->bl,tsd->bl.x,tsd->bl.y);
dir = (unit_getdir(&sd->bl) + dir)%8; //This adjusts dir to account for the direction the sd is facing.
if ((tsd->class_&MAPID_BASEMASK) == MAPID_ACOLYTE && (dir == 2 || dir == 6) //Must be standing to the left/right of Priest.
&& sd->status.sp >= 10)
@@ -12213,7 +12112,7 @@ int skill_check_condition_char_sub (struct block_list *bl, va_list ap) {
return 1;
case WL_COMET:
// Comet does not consume Red Gemstones when there is at least 1 Warlock class next to the caster
- if( ( sd->class_&MAPID_THIRDMASK ) == MAPID_WARLOCK )
+ if( ( tsd->class_&MAPID_THIRDMASK ) == MAPID_WARLOCK )
p_sd[(*c)++] = tsd->bl.id;
return 1;
case LG_RAYOFGENESIS:
@@ -12228,7 +12127,7 @@ int skill_check_condition_char_sub (struct block_list *bl, va_list ap) {
return 0;
if (sd->status.sex != tsd->status.sex &&
(tsd->class_&MAPID_UPPERMASK) == MAPID_BARDDANCER &&
- (skill_lv = pc_checkskill(tsd, skill_id)) > 0 &&
+ (skill_lv = pc->checkskill(tsd, skill_id)) > 0 &&
(tsd->weapontype1==W_MUSICAL || tsd->weapontype1==W_WHIP) &&
sd->status.party_id && tsd->status.party_id &&
sd->status.party_id == tsd->status.party_id &&
@@ -12264,26 +12163,26 @@ int skill_check_pc_partner (struct map_session_data *sd, uint16 skill_id, short*
switch (skill_id) {
case PR_BENEDICTIO:
for (i = 0; i < c; i++) {
- if ((tsd = map_id2sd(p_sd[i])) != NULL)
+ if ((tsd = iMap->id2sd(p_sd[i])) != NULL)
status_charge(&tsd->bl, 0, 10);
}
return c;
case AB_ADORAMUS:
- if( c > 0 && (tsd = map_id2sd(p_sd[0])) != NULL ) {
+ if( c > 0 && (tsd = iMap->id2sd(p_sd[0])) != NULL ) {
i = 2 * (*skill_lv);
status_charge(&tsd->bl, 0, i);
}
break;
case WM_GREAT_ECHO:
for( i = 0; i < c; i++ ) {
- if( (tsd = map_id2sd(p_sd[i])) != NULL )
+ if( (tsd = iMap->id2sd(p_sd[i])) != NULL )
status_zap(&tsd->bl,0,skill->get_sp(skill_id,*skill_lv)/c);
}
break;
default: //Warning: Assuming Ensemble skills here (for speed)
if( is_chorus )
break;//Chorus skills are not to be parsed as ensambles
- if (c > 0 && sd->sc.data[SC_DANCING] && (tsd = map_id2sd(p_sd[0])) != NULL) {
+ if (c > 0 && sd->sc.data[SC_DANCING] && (tsd = iMap->id2sd(p_sd[0])) != NULL) {
sd->sc.data[SC_DANCING]->val4 = tsd->bl.id;
sc_start4(&tsd->bl,SC_DANCING,100,skill_id,sd->sc.data[SC_DANCING]->val2,*skill_lv,sd->bl.id,skill->get_time(skill_id,*skill_lv)+1000);
clif->skill_nodamage(&tsd->bl, &sd->bl, skill_id, *skill_lv, 1);
@@ -12300,7 +12199,7 @@ int skill_check_pc_partner (struct map_session_data *sd, uint16 skill_id, short*
if( is_chorus )
i = party_foreachsamemap(skill->check_condition_char_sub,sd,AREA_SIZE,&sd->bl, &c, &p_sd, skill_id, *skill_lv);
else
- i = map_foreachinrange(skill->check_condition_char_sub, &sd->bl, range, BL_PC, &sd->bl, &c, &p_sd, skill_id);
+ i = iMap->foreachinrange(skill->check_condition_char_sub, &sd->bl, range, BL_PC, &sd->bl, &c, &p_sd, skill_id);
if ( skill_id != PR_BENEDICTIO && skill_id != AB_ADORAMUS && skill_id != WL_COMET ) //Apply the average lv to encore skills.
*skill_lv = (i+(*skill_lv))/(c+1); //I know c should be one, but this shows how it could be used for the average of n partners.
@@ -12319,10 +12218,8 @@ int skill_check_condition_mob_master_sub (struct block_list *bl, va_list ap) {
mob_class=va_arg(ap,int);
skill=va_arg(ap,int);
c=va_arg(ap,int *);
-
- if( md->master_id != src_id || md->special_state.ai != (unsigned)(skill == AM_SPHEREMINE?2:skill == KO_ZANZOU?4:3) )
+ if( md->master_id != src_id || md->special_state.ai != (unsigned)(skill == AM_SPHEREMINE?2:skill == KO_ZANZOU?4:skill == MH_SUMMON_LEGION?1:3) )
return 0; //Non alchemist summoned mobs have nothing to do here.
-
if(md->class_==mob_class)
(*c)++;
@@ -12407,7 +12304,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
if( skill_id == WZ_EARTHSPIKE && sc && sc->data[SC_EARTHSCROLL] && rnd()%100 > sc->data[SC_EARTHSCROLL]->val2 ) // [marquis007]
; //Do not consume item.
else if( sd->status.inventory[i].expire_time == 0 )
- pc_delitem(sd,i,1,0,0,LOG_TYPE_CONSUME); // Rental usable items are not consumed until expiration
+ pc->delitem(sd,i,1,0,0,LOG_TYPE_CONSUME); // Rental usable items are not consumed until expiration
}
return 1;
}
@@ -12450,11 +12347,11 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
case BS_ADRENALINE: case WS_WEAPONREFINE:
case BS_WEAPONPERFECT: case WS_CARTTERMINATION:
case BS_OVERTHRUST: case WS_OVERTHRUSTMAX:
- case BS_MAXIMIZE: case NC_AXEBOOMERANG:
- case BS_ADRENALINE2: case NC_POWERSWING:
- case BS_UNFAIRLYTRICK: case NC_AXETORNADO:
+ case BS_MAXIMIZE:
+ case BS_ADRENALINE2:
+ case BS_UNFAIRLYTRICK:
case BS_GREED:
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_MADOGEAR,0);
return 0;
default: //Only Mechanic exlcusive skill can be used.
break;
@@ -12510,30 +12407,43 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
return 0;
if(sc->data[SC_BLADESTOP])
break;
- if(sc->data[SC_COMBO] && sc->data[SC_COMBO]->val1 == MO_TRIPLEATTACK)
+ if( (i=(sc && sc->data[SC_COMBOATTACK])) && sc->data[SC_COMBOATTACK]->val1 == MO_TRIPLEATTACK )
break;
+ if( i )
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_COMBOSKILL, MO_TRIPLEATTACK);
return 0;
case MO_COMBOFINISH:
- if(!(sc && sc->data[SC_COMBO] && sc->data[SC_COMBO]->val1 == MO_CHAINCOMBO))
+ if(!sc)
return 0;
- break;
+ if( (i=(sc && sc->data[SC_COMBOATTACK])) && sc->data[SC_COMBOATTACK]->val1 == MO_CHAINCOMBO )
+ break;
+ if( i )
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_COMBOSKILL, MO_CHAINCOMBO);
+ return 0;
case CH_TIGERFIST:
- if(!(sc && sc->data[SC_COMBO] && sc->data[SC_COMBO]->val1 == MO_COMBOFINISH))
+ if(!sc)
return 0;
- break;
+ if( (i=(sc && sc->data[SC_COMBOATTACK])) && sc->data[SC_COMBOATTACK]->val1 == MO_COMBOFINISH )
+ break;
+ if( i )
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_COMBOSKILL, MO_COMBOFINISH);
+ return 0;
case CH_CHAINCRUSH:
- if(!(sc && sc->data[SC_COMBO]))
- return 0;
- if(sc->data[SC_COMBO]->val1 != MO_COMBOFINISH && sc->data[SC_COMBO]->val1 != CH_TIGERFIST)
+ if(!sc)
return 0;
- break;
+ if( (i=(sc && sc->data[SC_COMBOATTACK])) && sc->data[SC_COMBOATTACK]->val1 == CH_TIGERFIST )
+ break;
+ if( i )
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_COMBOSKILL, CH_TIGERFIST);
+ return 0;
case MO_EXTREMITYFIST:
// if(sc && sc->data[SC_EXTREMITYFIST]) //To disable Asura during the 5 min skill block uncomment this...
// return 0;
if( sc && (sc->data[SC_BLADESTOP] || sc->data[SC_CURSEDCIRCLE_ATKER]) )
break;
- if( sc && sc->data[SC_COMBO] ) {
- switch(sc->data[SC_COMBO]->val1) {
+ if( sc && sc->data[SC_COMBOATTACK] )
+ {
+ switch(sc->data[SC_COMBOATTACK]->val1) {
case MO_COMBOFINISH:
case CH_TIGERFIST:
case CH_CHAINCRUSH:
@@ -12575,17 +12485,17 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
case TK_COUNTER:
if ((sd->class_&MAPID_UPPERMASK) == MAPID_SOUL_LINKER)
return 0; //Anti-Soul Linker check in case you job-changed with Stances active.
- if(!(sc && sc->data[SC_COMBO]) || sc->data[SC_COMBO]->val1 == TK_JUMPKICK)
+ if(!(sc && sc->data[SC_COMBOATTACK]) || sc->data[SC_COMBOATTACK]->val1 == TK_JUMPKICK)
return 0; //Combo needs to be ready
- if (sc->data[SC_COMBO]->val3) { //Kick chain
+ if (sc->data[SC_COMBOATTACK]->val3) { //Kick chain
//Do not repeat a kick.
- if (sc->data[SC_COMBO]->val3 != skill_id)
+ if (sc->data[SC_COMBOATTACK]->val3 != skill_id)
break;
- status_change_end(&sd->bl, SC_COMBO, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_COMBOATTACK, INVALID_TIMER);
return 0;
}
- if(sc->data[SC_COMBO]->val1 != skill_id && !( sd && sd->status.base_level >= 90 && pc_famerank(sd->status.char_id, MAPID_TAEKWON) )) { //Cancel combo wait.
+ if(sc->data[SC_COMBOATTACK]->val1 != skill_id && !( sd && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) )) { //Cancel combo wait.
unit_cancel_combo(&sd->bl);
return 0;
}
@@ -12619,12 +12529,12 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
break;
case SL_SMA:
- if(!(sc && sc->data[SC_SMA]))
+ if(!(sc && sc->data[SC_SMA_READY]))
return 0;
break;
case HT_POWER:
- if(!(sc && sc->data[SC_COMBO] && sc->data[SC_COMBO]->val1 == skill_id))
+ if(!(sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == skill_id))
return 0;
break;
@@ -12642,7 +12552,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
for (i=0;i<size*size;i++) {
x = sd->bl.x+(i%size-range);
y = sd->bl.y+(i/size-range);
- if (map_getcell(sd->bl.m,x,y,CELL_CHKWALL)) {
+ if (iMap->getcell(sd->bl.m,x,y,CELL_CHKWALL)) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 0;
}
@@ -12652,8 +12562,8 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
case PR_REDEMPTIO:
{
int exp;
- if( ((exp = pc_nextbaseexp(sd)) > 0 && get_percentage(sd->status.base_exp, exp) < 1) ||
- ((exp = pc_nextjobexp(sd)) > 0 && get_percentage(sd->status.job_exp, exp) < 1)) {
+ if( ((exp = pc->nextbaseexp(sd)) > 0 && get_percentage(sd->status.base_exp, exp) < 1) ||
+ ((exp = pc->nextjobexp(sd)) > 0 && get_percentage(sd->status.job_exp, exp) < 1)) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); //Not enough exp.
return 0;
}
@@ -12661,7 +12571,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
}
case AM_TWILIGHT2:
case AM_TWILIGHT3:
- if (!party_skill_check(sd, sd->status.party_id, skill_id, skill_lv))
+ if (!party->skill_check(sd, sd->status.party_id, skill_id, skill_lv))
{
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 0;
@@ -12690,7 +12600,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 0;
case SG_FUSION:
- if (sc && sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_STAR)
+ if (sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_STAR)
break;
//Auron insists we should implement SP consumption when you are not Soul Linked. [Skotlex]
//Only invoke on skill begin cast (instant cast skill). [Kevin]
@@ -12732,7 +12642,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
return 0;
}
case NJ_BUNSINJYUTSU:
- if (!(sc && sc->data[SC_NEN])) {
+ if (!(sc && sc->data[SC_NJ_NEN])) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 0;
}
@@ -12794,7 +12704,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
* Warlock
**/
case WL_COMET:
- if( skill->check_pc_partner(sd,skill_id,&skill_lv,1,0) <= 0 && ((i = pc_search_inventory(sd,require.itemid[0])) < 0 || sd->status.inventory[i].amount < require.amount[0]) )
+ if( skill->check_pc_partner(sd,skill_id,&skill_lv,1,0) <= 0 && ((i = pc->search_inventory(sd,require.itemid[0])) < 0 || sd->status.inventory[i].amount < require.amount[0]) )
{
//clif->skill_fail(sd,skill_id,USESKILL_FAIL_NEED_ITEM,require.amount[0],require.itemid[0]);
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
@@ -12805,13 +12715,36 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
case WL_SUMMONBL:
case WL_SUMMONWB:
case WL_SUMMONSTONE:
- if( sc )
+ case WL_TETRAVORTEX:
+ case WL_RELEASE:
{
- ARR_FIND(SC_SPHERE_1,SC_SPHERE_5+1,i,!sc->data[i]);
- if( i == SC_SPHERE_5+1 )
- { // No more free slots
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_SUMMON,0);
- return 0;
+ int x = SC_SUMMON1;
+ i = 0;
+ for(; x <= SC_SUMMON5; x++)
+ if( sc && sc->data[x] )
+ i++;
+
+ switch(skill_id){
+ case WL_TETRAVORTEX:
+ if( i < 4 ){
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_CONDITION,0);
+ return 0;
+ }
+ break;
+ case WL_RELEASE:
+ for(x = SC_SPELLBOOK7; x >= SC_SPELLBOOK1; x--)
+ if( sc && sc->data[x] )
+ i++;
+ if( i == 0 ){
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_SUMMON_NONE,0);
+ return 0;
+ }
+ break;
+ default:
+ if( i == 5 ){
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_SUMMON,0);
+ return 0;
+ }
}
}
break;
@@ -12826,7 +12759,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
break;
case GC_COUNTERSLASH:
case GC_WEAPONCRUSH:
- if( !(sc && sc->data[SC_COMBO] && sc->data[SC_COMBO]->val1 == GC_WEAPONBLOCKING) ) {
+ if( !(sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == GC_WEAPONBLOCKING) ) {
clif->skill_fail(sd, skill_id, USESKILL_FAIL_GC_WEAPONBLOCKING, 0);
return 0;
}
@@ -12835,26 +12768,26 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
* Ranger
**/
case RA_WUGMASTERY:
- if( pc_isfalcon(sd) || pc_isridingwug(sd) || sd->sc.data[SC__GROOMY]) {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ if( pc_isfalcon(sd) || pc_isridingwug(sd) || sd->sc.data[SC__GROOMY] ) {
+ clif->skill_fail(sd,skill_id,sd->sc.data[SC__GROOMY]?USESKILL_FAIL_MANUAL_NOTIFY:USESKILL_FAIL_CONDITION,0);
return 0;
}
break;
case RA_WUGSTRIKE:
if( !pc_iswug(sd) && !pc_isridingwug(sd) ) {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_CONDITION,0);
return 0;
}
break;
case RA_WUGRIDER:
if( pc_isfalcon(sd) || ( !pc_isridingwug(sd) && !pc_iswug(sd) ) ) {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_CONDITION,0);
return 0;
}
break;
case RA_WUGDASH:
if(!pc_isridingwug(sd)) {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_CONDITION,0);
return 0;
}
break;
@@ -12896,10 +12829,13 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
}
break;
case SR_FALLENEMPIRE:
- if( !(sc && sc->data[SC_COMBO] && sc->data[SC_COMBO]->val1 == SR_DRAGONCOMBO) )
+ if( !sc )
return 0;
- break;
-
+ if( (i=(sc && sc->data[SC_COMBOATTACK])) && sc->data[SC_COMBOATTACK]->val1 == SR_DRAGONCOMBO )
+ break;
+ if( i )
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_COMBOSKILL, SR_DRAGONCOMBO);
+ return 0;
case SR_CRESCENTELBOW:
if( sc && sc->data[SC_CRESCENTELBOW] ) {
clif->skill_fail(sd, skill_id, USESKILL_FAIL_DUPLICATE, 0);
@@ -12908,7 +12844,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
break;
case SR_CURSEDCIRCLE:
if (map_flag_gvg(sd->bl.m)) {
- if (map_foreachinrange(mob_count_sub, &sd->bl, skill->get_splash(skill_id, skill_lv), BL_MOB,
+ if (iMap->foreachinrange(mob_count_sub, &sd->bl, skill->get_splash(skill_id, skill_lv), BL_MOB,
MOBID_EMPERIUM, MOBID_GUARIDAN_STONE1, MOBID_GUARIDAN_STONE2)) {
char output[128];
sprintf(output, "You're too close to a stone or emperium to do this skill");
@@ -12954,7 +12890,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
break;
case SO_EL_CONTROL:
if( !sd->status.ele_id || !sd->ed ) {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_EL_SUMMON,0);
return 0;
}
break;
@@ -12966,7 +12902,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
break;
case LG_REFLECTDAMAGE:
case CR_REFLECTSHIELD:
- if( sc && sc->data[SC_KYOMU] && rand()%100 < 30){
+ if( sc && sc->data[SC_KYOMU] && rand()%100 < 5 * sc->data[SC_KYOMU]->val1 ){
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 0;
}
@@ -12977,18 +12913,17 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
case KO_DOHU_KOUKAI:
{
int ttype = skill->get_ele(skill_id, skill_lv);
- ARR_FIND(1, 5, i, sd->talisman[i] > 0 && i != ttype);
- if( (i < 5 && i != ttype) || sd->talisman[ttype] >= 10 ){
- clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0);
+ if( sd->charm[ttype] >= 10 ){
+ clif->skill_fail(sd, skill_id, USESKILL_FAIL_SUMMON, 0);
return 0;
}
}
break;
case KO_KAIHOU:
case KO_ZENKAI:
- ARR_FIND(1, 6, i, sd->talisman[i] > 0);
+ ARR_FIND(1, 6, i, sd->charm[i] > 0);
if( i > 4 ) {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_SUMMON,0);
return 0;
}
break;
@@ -13032,7 +12967,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
}
case ST_CART:
if(!pc_iscarton(sd)) {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_CART,0);
return 0;
}
break;
@@ -13050,7 +12985,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
break;
case ST_EXPLOSIONSPIRITS:
if(!(sc && sc->data[SC_EXPLOSIONSPIRITS])) {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_EXPLOSIONSPIRITS,0);
return 0;
}
break;
@@ -13061,8 +12996,8 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
}
break;
case ST_MOVE_ENABLE:
- if (sc && sc->data[SC_COMBO] && sc->data[SC_COMBO]->val1 == skill_id)
- sd->ud.canmove_tick = gettick(); //When using a combo, cancel the can't move delay to enable the skill. [Skotlex]
+ if (sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == skill_id)
+ sd->ud.canmove_tick = iTimer->gettick(); //When using a combo, cancel the can't move delay to enable the skill. [Skotlex]
if (!unit_can_move(&sd->bl)) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
@@ -13070,15 +13005,15 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
}
break;
case ST_WATER:
- if (sc && (sc->data[SC_DELUGE] || sc->data[SC_SUITON]))
+ if (sc && (sc->data[SC_DELUGE] || sc->data[SC_NJ_SUITON]))
break;
- if (map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKWATER))
+ if (iMap->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKWATER))
break;
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 0;
case ST_RIDINGDRAGON:
if( !pc_isridingdragon(sd) ) {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_DRAGON,0);
return 0;
}
break;
@@ -13096,7 +13031,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
break;
case ST_MADO:
if( !pc_ismadogear(sd) ) {
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_MADOGEAR,0);
return 0;
}
break;
@@ -13163,7 +13098,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
return 0;
}
- if( sd->sc.data[SC_COMBO] ) {
+ if( sd->sc.data[SC_COMBOATTACK] ) {
switch( skill_id ) {
case MO_CHAINCOMBO:
case MO_COMBOFINISH:
@@ -13174,12 +13109,14 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
case TK_STORMKICK:
case TK_DOWNKICK:
case TK_COUNTER:
+ case TK_JUMPKICK:
case HT_POWER:
case GC_COUNTERSLASH:
case GC_WEAPONCRUSH:
case SR_FALLENEMPIRE:
case SR_DRAGONCOMBO:
case SR_TIGERCANNON:
+ case SR_GATEOFHELL:
break;
default: return 0;
}
@@ -13252,7 +13189,7 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id,
int maxcount = (skill_id==AM_CANNIBALIZE)? 6-skill_lv : skill->get_maxcount(skill_id,skill_lv);
int mob_class = (skill_id==AM_CANNIBALIZE)? summons[skill_lv-1] :1142;
if(battle_config.land_skill_limit && maxcount>0 && (battle_config.land_skill_limit&BL_PC)) {
- i = map_foreachinmap(skill->check_condition_mob_master_sub ,sd->bl.m, BL_MOB, sd->bl.id, mob_class, skill_id, &c);
+ i = iMap->foreachinmap(skill->check_condition_mob_master_sub ,sd->bl.m, BL_MOB, sd->bl.id, mob_class, skill_id, &c);
if(c >= maxcount ||
(skill_id==AM_CANNIBALIZE && c != i && battle_config.summon_flora&2))
{ //Fails when: exceed max limit. There are other plant types already out.
@@ -13273,9 +13210,9 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id,
if( battle_config.land_skill_limit && maxcount > 0 && ( battle_config.land_skill_limit&BL_PC ) ) {
if( skill_id == NC_MAGICDECOY ) {
for( j = mob_class; j <= 2046; j++ )
- map_foreachinmap(skill->check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, j, skill_id, &c);
+ iMap->foreachinmap(skill->check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, j, skill_id, &c);
} else
- map_foreachinmap(skill->check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, mob_class, skill_id, &c);
+ iMap->foreachinmap(skill->check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, mob_class, skill_id, &c);
if( c >= maxcount ) {
clif->skill_fail(sd , skill_id, USESKILL_FAIL_LEVEL, 0);
return 0;
@@ -13285,7 +13222,7 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id,
break;
case KO_ZANZOU: {
int c = 0;
- i = map_foreachinmap(skill->check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, 2308, skill_id, &c);
+ i = iMap->foreachinmap(skill->check_condition_mob_master_sub, sd->bl.m, BL_MOB, sd->bl.id, 2308, skill_id, &c);
if( c >= skill->get_maxcount(skill_id,skill_lv) || c != i) {
clif->skill_fail(sd , skill_id, USESKILL_FAIL_LEVEL, 0);
return 0;
@@ -13310,7 +13247,10 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id,
if( require.ammo ) { //Skill requires stuff equipped in the arrow slot.
if((i=sd->equip_index[EQI_AMMO]) < 0 || !sd->inventory_data[i] ) {
- clif->arrow_fail(sd,0);
+ if( require.ammo&1<<8 )
+ clif->skill_fail(sd,skill_id,USESKILL_FAIL_CANONBALL,0);
+ else
+ clif->arrow_fail(sd,0);
return 0;
} else if( sd->status.inventory[i].amount < require.ammo_qty ) {
char e_msg[100];
@@ -13332,14 +13272,41 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id,
for( i = 0; i < MAX_SKILL_ITEM_REQUIRE; ++i ) {
if( !require.itemid[i] )
continue;
- index[i] = pc_search_inventory(sd,require.itemid[i]);
+ index[i] = pc->search_inventory(sd,require.itemid[i]);
if( index[i] < 0 || sd->status.inventory[index[i]].amount < require.amount[i] ) {
- if( require.itemid[i] == ITEMID_RED_GEMSTONE )
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_REDJAMSTONE,0);// red gemstone required
- else if( require.itemid[i] == ITEMID_BLUE_GEMSTONE )
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_BLUEJAMSTONE,0);// blue gemstone required
- else
- clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
+ useskill_fail_cause cause = USESKILL_FAIL_NEED_ITEM;
+ switch( skill_id ){
+ case NC_SILVERSNIPER:
+ case NC_MAGICDECOY:
+ cause = USESKILL_FAIL_STUFF_INSUFFICIENT;
+ break;
+ default:
+ switch(require.itemid[i]){
+ case ITEMID_RED_GEMSTONE:
+ cause = USESKILL_FAIL_REDJAMSTONE; break;
+ case ITEMID_BLUE_GEMSTONE:
+ cause = USESKILL_FAIL_BLUEJAMSTONE; break;
+ case ITEMID_HOLY_WATER:
+ cause = USESKILL_FAIL_HOLYWATER; break;
+ case ITEMID_ANCILLA:
+ cause = USESKILL_FAIL_ANCILLA; break;
+ case ITEMID_ACCELERATOR:
+ case ITEMID_HOVERING_BOOSTER:
+ case ITEMID_SUICIDAL_DEVICE:
+ case ITEMID_SHAPE_SHIFTER:
+ case ITEMID_COOLING_DEVICE:
+ case ITEMID_MAGNETIC_FIELD_GENERATOR:
+ case ITEMID_BARRIER_BUILDER:
+ case ITEMID_CAMOUFLAGE_GENERATOR:
+ case ITEMID_REPAIR_KIT:
+ case ITEMID_MONKEY_SPANNER:
+ cause = USESKILL_FAIL_NEED_EQUIPMENT;
+ default:
+ clif->skill_fail(sd, skill_id, cause, max(1,require.amount[i])|(require.itemid[i] << 16));
+ return 0;
+ }
+ }
+ clif->skill_fail(sd, skill_id, cause, 0);
return 0;
}
}
@@ -13349,23 +13316,31 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id,
// type&2: consume items (after skill was used)
// type&1: consume the others (before skill was used)
-int skill_consume_requirement( struct map_session_data *sd, uint16 skill_id, uint16 skill_lv, short type)
-{
+int skill_consume_requirement( struct map_session_data *sd, uint16 skill_id, uint16 skill_lv, short type) {
struct skill_condition req;
nullpo_ret(sd);
req = skill->get_requirement(sd,skill_id,skill_lv);
- if( type&1 )
- {
- if( skill_id == CG_TAROTCARD || sd->state.autocast )
- req.sp = 0; // TarotCard will consume sp in skill_cast_nodamage_id [Inkfish]
+ if( type&1 ) {
+
+ switch( skill_id ) {
+ case CG_TAROTCARD: // TarotCard will consume sp in skill_cast_nodamage_id [Inkfish]
+ case MC_IDENTIFY:
+ req.sp = 0;
+ break;
+ default:
+ if( sd->state.autocast )
+ req.sp = 0;
+ break;
+ }
+
if(req.hp || req.sp)
status_zap(&sd->bl, req.hp, req.sp);
if(req.spiritball > 0)
- pc_delspiritball(sd,req.spiritball,0);
+ pc->delspiritball(sd,req.spiritball,0);
if(req.zeny > 0)
{
@@ -13373,7 +13348,7 @@ int skill_consume_requirement( struct map_session_data *sd, uint16 skill_id, uin
req.zeny = 0; //Zeny is reduced on skill->attack.
if( sd->status.zeny < req.zeny )
req.zeny = sd->status.zeny;
- pc_payzeny(sd,req.zeny,LOG_TYPE_CONSUME,NULL);
+ pc->payzeny(sd,req.zeny,LOG_TYPE_CONSUME,NULL);
}
}
@@ -13390,7 +13365,7 @@ int skill_consume_requirement( struct map_session_data *sd, uint16 skill_id, uin
if( !req.itemid[i] )
continue;
- if( itemid_isgemstone(req.itemid[i]) && skill_id != HW_GANBANTEIN && sc && sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_WIZARD )
+ if( itemid_isgemstone(req.itemid[i]) && skill_id != HW_GANBANTEIN && sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_WIZARD )
continue; //Gemstones are checked, but not substracted from inventory.
switch( skill_id ){
@@ -13415,8 +13390,8 @@ int skill_consume_requirement( struct map_session_data *sd, uint16 skill_id, uin
break;
}
- if( (n = pc_search_inventory(sd,req.itemid[i])) >= 0 )
- pc_delitem(sd,n,req.amount[i],0,1,LOG_TYPE_CONSUME);
+ if( (n = pc->search_inventory(sd,req.itemid[i])) >= 0 )
+ pc->delitem(sd,n,req.amount[i],0,1,LOG_TYPE_CONSUME);
}
}
@@ -13494,10 +13469,12 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16
if( sc ) {
if( sc->data[SC__LAZINESS] )
req.sp += req.sp + sc->data[SC__LAZINESS]->val1 * 10;
- if (sc->data[SC_UNLIMITEDHUMMINGVOICE])
- req.sp += req.sp * sc->data[SC_UNLIMITEDHUMMINGVOICE]->val2 / 100;
+ if( sc->data[SC_UNLIMITED_HUMMING_VOICE] )
+ req.sp += req.sp * sc->data[SC_UNLIMITED_HUMMING_VOICE]->val2 / 100;
if( sc->data[SC_RECOGNIZEDSPELL] )
req.sp += req.sp / 4;
+ if( sc->data[SC_TELEKINESIS_INTENSE] && skill->get_ele(skill_id, skill_lv) == ELE_GHOST)
+ req.sp -= req.sp * sc->data[SC_TELEKINESIS_INTENSE]->val2 / 100;
}
req.zeny = skill_db[idx].zeny[skill_lv-1];
@@ -13583,9 +13560,9 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16
req.amount[i] = 1; // Hocus Pocus allways use at least 1 gem
}
}
- if( skill_id >= HT_SKIDTRAP && skill_id <= HT_TALKIEBOX && pc_checkskill(sd, RA_RESEARCHTRAP) > 0){
+ if( skill_id >= HT_SKIDTRAP && skill_id <= HT_TALKIEBOX && pc->checkskill(sd, RA_RESEARCHTRAP) > 0){
int16 itIndex;
- if( (itIndex = pc_search_inventory(sd,req.itemid[i])) < 0 || ( itIndex >= 0 && sd->status.inventory[itIndex].amount < req.amount[i] ) ){
+ if( (itIndex = pc->search_inventory(sd,req.itemid[i])) < 0 || ( itIndex >= 0 && sd->status.inventory[itIndex].amount < req.amount[i] ) ){
req.itemid[i] = ITEMID_TRAP_ALLOY;
req.amount[i] = 1;
}
@@ -13613,18 +13590,18 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16
// Check for cost reductions due to skills & SCs
switch(skill_id) {
case MC_MAMMONITE:
- if(pc_checkskill(sd,BS_UNFAIRLYTRICK)>0)
+ if(pc->checkskill(sd,BS_UNFAIRLYTRICK)>0)
req.zeny -= req.zeny*10/100;
break;
case AL_HOLYLIGHT:
- if(sc && sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_PRIEST)
+ if(sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_PRIEST)
req.sp *= 5;
break;
case SL_SMA:
case SL_STUN:
case SL_STIN:
{
- int kaina_lv = pc_checkskill(sd,SL_KAINA);
+ int kaina_lv = pc->checkskill(sd,SL_KAINA);
if(kaina_lv==0 || sd->status.base_level<70)
break;
@@ -13641,7 +13618,7 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16
case MO_COMBOFINISH:
case CH_TIGERFIST:
case CH_CHAINCRUSH:
- if(sc && sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_MONK)
+ if(sc && sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_MONK)
req.sp -= req.sp*25/100; //FIXME: Need real data. this is a custom value.
break;
case MO_BODYRELOCATION:
@@ -13653,9 +13630,9 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16
{
if( sc->data[SC_BLADESTOP] )
req.spiritball--;
- else if( sc->data[SC_COMBO] )
+ else if( sc->data[SC_COMBOATTACK] )
{
- switch( sc->data[SC_COMBO]->val1 )
+ switch( sc->data[SC_COMBOATTACK]->val1 )
{
case MO_COMBOFINISH:
req.spiritball = 4;
@@ -13675,14 +13652,14 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16
req.spiritball = sd->spiritball?sd->spiritball:15;
break;
case SR_GATEOFHELL:
- if( sc && sc->data[SC_COMBO] && sc->data[SC_COMBO]->val1 == SR_FALLENEMPIRE )
+ if( sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == SR_FALLENEMPIRE )
req.sp -= req.sp * 10 / 100;
break;
case SO_SUMMON_AGNI:
case SO_SUMMON_AQUA:
case SO_SUMMON_VENTUS:
case SO_SUMMON_TERA:
- req.sp -= req.sp * (5 + 5 * pc_checkskill(sd,SO_EL_SYMPATHY)) / 100;
+ req.sp -= req.sp * (5 + 5 * pc->checkskill(sd,SO_EL_SYMPATHY)) / 100;
break;
case SO_PSYCHIC_WAVE:
if( sc && sc->data[SC_BLAST_OPTION] )
@@ -13752,15 +13729,15 @@ int skill_castfix_sc (struct block_list *bl, int time)
if( time < 0 )
return 0;
-
+
if( bl->type == BL_MOB ) // mobs casttime is fixed nothing to alter.
return time;
if (sc && sc->count) {
if (sc->data[SC_SLOWCAST])
time += time * sc->data[SC_SLOWCAST]->val2 / 100;
- if (sc->data[SC_PARALYSIS])
- time += sc->data[SC_PARALYSIS]->val3;
+ if (sc->data[SC_NEEDLE_OF_PARALYZE])
+ time += sc->data[SC_NEEDLE_OF_PARALYZE]->val3;
if (sc->data[SC_SUFFRAGIUM]) {
time -= time * sc->data[SC_SUFFRAGIUM]->val2 / 100;
status_change_end(bl, SC_SUFFRAGIUM, INVALID_TIMER);
@@ -13832,8 +13809,12 @@ int skill_vfcastfix (struct block_list *bl, double time, uint16 skill_id, uint16
if (sc && sc->count && !(skill->get_castnodex(skill_id, skill_lv)&2) ) {
// All variable cast additive bonuses must come first
+ if (sc->data[SC_MAGICPOWER] )
+ time += 700;
if (sc->data[SC_SLOWCAST])
VARCAST_REDUCTION(-sc->data[SC_SLOWCAST]->val2);
+ if (sc->data[SC_FROSTMISTY])
+ VARCAST_REDUCTION(-15);
// Variable cast reduction bonuses
if (sc->data[SC_SUFFRAGIUM]) {
@@ -13851,17 +13832,33 @@ int skill_vfcastfix (struct block_list *bl, double time, uint16 skill_id, uint16
VARCAST_REDUCTION(50);
if (sc->data[SC_WATER_INSIGNIA] && sc->data[SC_WATER_INSIGNIA]->val1 == 3 && (skill->get_ele(skill_id, skill_lv) == ELE_WATER))
VARCAST_REDUCTION(30); //Reduces 30% Variable Cast Time of Water spells.
+ if (sc->data[SC_TELEKINESIS_INTENSE])
+ VARCAST_REDUCTION(sc->data[SC_TELEKINESIS_INTENSE]->val2);
+ if (sc->data[SC_SOULLINK]){
+ if(sc->data[SC_SOULLINK]->val2 == SL_WIZARD || sc->data[SC_SOULLINK]->val2 == SL_BARDDANCER)
+ switch(skill_id){
+ case WZ_FIREPILLAR:
+ if(skill_lv < 5)
+ break;
+ case HW_GRAVITATION:
+ case MG_SAFETYWALL:
+ case MG_STONECURSE:
+ case BA_MUSICALSTRIKE:
+ case DC_THROWARROW:
+ VARCAST_REDUCTION(50);
+ }
+ }
// Fixed cast reduction bonuses
if( sc->data[SC__LAZINESS] )
fixcast_r = max(fixcast_r, sc->data[SC__LAZINESS]->val2);
if( sc->data[SC_SECRAMENT] )
fixcast_r = max(fixcast_r, sc->data[SC_SECRAMENT]->val2);
- if( sd && ( skill_lv = pc_checkskill(sd, WL_RADIUS) ) && skill_id >= WL_WHITEIMPRISON && skill_id <= WL_FREEZE_SP )
- fixcast_r = max(fixcast_r, 5 + skill_lv * 5);
+ if( sd && ( skill_lv = pc->checkskill(sd, WL_RADIUS) ) && (skill_id >= WL_WHITEIMPRISON && skill_id < WL_FREEZE_SP) )
+ fixcast_r = max(fixcast_r, (status_get_int(bl) + status_get_lv(bl)) / 15 + skill_lv * 5); // [{(Caster?s INT / 15) + (Caster?s Base Level / 15) + (Radius Skill Level x 5)}] %
// Fixed cast non percentage bonuses
if( sc->data[SC_MANDRAGORA] )
fixed += sc->data[SC_MANDRAGORA]->val1 * 1000 / 2;
- if (sc->data[SC_IZAYOI] && (skill_id >= NJ_TOBIDOUGU && skill_id <= NJ_ISSEN))
+ if( sc->data[SC_IZAYOI] )
fixed = 0;
if( sc->data[SC_GUST_OPTION] || sc->data[SC_BLAST_OPTION] || sc->data[SC_WILD_STORM_OPTION] )
fixed -= 1000;
@@ -13939,14 +13936,14 @@ int skill_delay_fix (struct block_list *bl, uint16 skill_id, uint16 skill_lv)
}
}
- if ( sc && sc->data[SC_SPIRIT] ) {
+ if ( sc && sc->data[SC_SOULLINK] ) {
switch (skill_id) {
case CR_SHIELDBOOMERANG:
- if (sc->data[SC_SPIRIT]->val2 == SL_CRUSADER)
+ if (sc->data[SC_SOULLINK]->val2 == SL_CRUSADER)
time /= 2;
break;
case AS_SONICBLOW:
- if (!map_flag_gvg(bl->m) && !map[bl->m].flag.battleground && sc->data[SC_SPIRIT]->val2 == SL_ASSASIN)
+ if (!map_flag_gvg(bl->m) && !map[bl->m].flag.battleground && sc->data[SC_SOULLINK]->val2 == SL_ASSASIN)
time /= 2;
break;
}
@@ -14101,7 +14098,7 @@ void skill_brandishspear_dir (struct square* tc, uint8 dir, int are) {
void skill_brandishspear(struct block_list* src, struct block_list* bl, uint16 skill_id, uint16 skill_lv, unsigned int tick, int flag)
{
int c,n=4;
- uint8 dir = map_calc_dir(src,bl->x,bl->y);
+ uint8 dir = iMap->calc_dir(src,bl->x,bl->y);
struct square tc;
int x=bl->x,y=bl->y;
skill->brandishspear_first(&tc,dir,x,y);
@@ -14110,7 +14107,7 @@ void skill_brandishspear(struct block_list* src, struct block_list* bl, uint16 s
if(skill_lv > 9){
for(c=1;c<4;c++){
- map_foreachincell(skill->area_sub,
+ iMap->foreachincell(skill->area_sub,
bl->m,tc.val1[c],tc.val2[c],BL_CHAR,
src,skill_id,skill_lv,tick, flag|BCT_ENEMY|n,
skill->castend_damage_id);
@@ -14126,7 +14123,7 @@ void skill_brandishspear(struct block_list* src, struct block_list* bl, uint16 s
if(skill_lv > 3){
for(c=0;c<5;c++){
- map_foreachincell(skill->area_sub,
+ iMap->foreachincell(skill->area_sub,
bl->m,tc.val1[c],tc.val2[c],BL_CHAR,
src,skill_id,skill_lv,tick, flag|BCT_ENEMY|n,
skill->castend_damage_id);
@@ -14138,7 +14135,7 @@ void skill_brandishspear(struct block_list* src, struct block_list* bl, uint16 s
}
for(c=0;c<10;c++){
if(c==0||c==5) skill->brandishspear_dir(&tc,dir,-1);
- map_foreachincell(skill->area_sub,
+ iMap->foreachincell(skill->area_sub,
bl->m,tc.val1[c%5],tc.val2[c%5],BL_CHAR,
src,skill_id,skill_lv,tick, flag|BCT_ENEMY|1,
skill->castend_damage_id);
@@ -14156,7 +14153,7 @@ void skill_repairweapon (struct map_session_data *sd, int idx) {
nullpo_retv(sd);
- if ( !( target_sd = map_id2sd(sd->menuskill_val) ) ) //Failed....
+ if ( !( target_sd = iMap->id2sd(sd->menuskill_val) ) ) //Failed....
return;
if( idx == 0xFFFF ) // No item selected ('Cancel' clicked)
@@ -14177,7 +14174,7 @@ void skill_repairweapon (struct map_session_data *sd, int idx) {
material = materials [ target_sd->inventory_data[idx]->wlv - 1 ]; // Lv1/2/3/4 weapons consume 1 Iron Ore/Iron/Steel/Rough Oridecon
else
material = materials [2]; // Armors consume 1 Steel
- if ( pc_search_inventory(sd,material) < 0 ) {
+ if ( pc->search_inventory(sd,material) < 0 ) {
clif->skill_fail(sd,sd->menuskill_id,USESKILL_FAIL_LEVEL,0);
return;
}
@@ -14188,7 +14185,7 @@ void skill_repairweapon (struct map_session_data *sd, int idx) {
clif->equiplist(target_sd);
- pc_delitem(sd,pc_search_inventory(sd,material),1,0,0,LOG_TYPE_CONSUME);
+ pc->delitem(sd,pc->search_inventory(sd,material),1,0,0,LOG_TYPE_CONSUME);
clif->item_repaireffect(sd,idx,0);
@@ -14204,7 +14201,7 @@ void skill_identify (struct map_session_data *sd, int idx)
int flag=1;
nullpo_retv(sd);
-
+ sd->state.workinprogress = 0;
if(idx >= 0 && idx < MAX_INVENTORY) {
if(sd->status.inventory[idx].nameid > 0 && sd->status.inventory[idx].identify == 0 ){
flag=0;
@@ -14231,32 +14228,42 @@ void skill_weaponrefine (struct map_session_data *sd, int idx)
if(item->nameid > 0 && ditem->type == IT_WEAPON)
{
- if( item->refine >= sd->menuskill_val
- || item->refine >= 10 // if it's no longer refineable
- || ditem->flag.no_refine // if the item isn't refinable
- || (i = pc_search_inventory(sd, material [ditem->wlv])) < 0 )
- {
+ if( ditem->flag.no_refine ){ // if the item isn't refinable
clif->skill_fail(sd,sd->menuskill_id,USESKILL_FAIL_LEVEL,0);
return;
}
+ if( item->refine >= sd->menuskill_val || item->refine >= 10 ){
+ clif->upgrademessage(sd->fd, 2, item->nameid);
+ return;
+ }
+ if( (i = pc->search_inventory(sd, material [ditem->wlv])) < 0 ){
+ clif->upgrademessage(sd->fd, 3, material [ditem->wlv]);
+ return;
+ }
- per = status_get_refine_chance(ditem->wlv, (int)item->refine);
- per += (((signed int)sd->status.job_level)-50)/2; //Updated per the new kro descriptions. [Skotlex]
-
- pc_delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
- if (per > rnd() % 100) {
+ per = status_get_refine_chance(ditem->wlv, (int)item->refine) * 10;
+
+ // Aegis leaked formula. [malufett]
+ if( sd->status.class_ == JOB_MECHANIC_T )
+ per += 100;
+ else
+ per += 5 * ((signed int)sd->status.job_level - 50);
+
+ pc->delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
+ if (per > rnd() % 1000) {
logs->pick_pc(sd, LOG_TYPE_OTHER, -1, item, ditem);
item->refine++;
logs->pick_pc(sd, LOG_TYPE_OTHER, 1, item, ditem);
if(item->equip) {
ep = item->equip;
- pc_unequipitem(sd,idx,3);
+ pc->unequipitem(sd,idx,3);
}
+ clif->delitem(sd,idx,1,0);
+ clif->upgrademessage(sd->fd, 0,item->nameid);
+ clif->inventorylist(sd);
clif->refine(sd->fd,0,idx,item->refine);
- clif->delitem(sd,idx,1,3);
- clif->additem(sd,idx,1,0);
if (ep)
- pc_equipitem(sd,idx,ep);
+ pc->equipitem(sd,idx,ep);
clif->misceffect(&sd->bl,3);
if(item->refine == 10 &&
item->card[0] == CARD0_FORGE &&
@@ -14264,22 +14271,22 @@ void skill_weaponrefine (struct map_session_data *sd, int idx)
{ // Fame point system [DracoRPG]
switch(ditem->wlv){
case 1:
- pc_addfame(sd,1); // Success to refine to +10 a lv1 weapon you forged = +1 fame point
+ pc->addfame(sd,1); // Success to refine to +10 a lv1 weapon you forged = +1 fame point
break;
case 2:
- pc_addfame(sd,25); // Success to refine to +10 a lv2 weapon you forged = +25 fame point
+ pc->addfame(sd,25); // Success to refine to +10 a lv2 weapon you forged = +25 fame point
break;
case 3:
- pc_addfame(sd,1000); // Success to refine to +10 a lv3 weapon you forged = +1000 fame point
+ pc->addfame(sd,1000); // Success to refine to +10 a lv3 weapon you forged = +1000 fame point
break;
}
}
} else {
item->refine = 0;
if(item->equip)
- pc_unequipitem(sd,idx,3);
+ pc->unequipitem(sd,idx,3);
clif->refine(sd->fd,1,idx,item->refine);
- pc_delitem(sd,idx,1,0,2, LOG_TYPE_OTHER);
+ pc->delitem(sd,idx,1,0,0, LOG_TYPE_OTHER);
clif->misceffect(&sd->bl,2);
clif->emotion(&sd->bl, E_OMG);
}
@@ -14298,13 +14305,13 @@ int skill_autospell (struct map_session_data *sd, uint16 skill_id)
nullpo_ret(sd);
skill_lv = sd->menuskill_val;
- lv=pc_checkskill(sd,skill_id);
+ lv=pc->checkskill(sd,skill_id);
if(!skill_lv || !lv) return 0; // Player must learn the skill before doing auto-spell [Lance]
if(skill_id==MG_NAPALMBEAT) maxlv=3;
else if(skill_id==MG_COLDBOLT || skill_id==MG_FIREBOLT || skill_id==MG_LIGHTNINGBOLT){
- if (sd->sc.data[SC_SPIRIT] && sd->sc.data[SC_SPIRIT]->val2 == SL_SAGE)
+ if (sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_SAGE)
maxlv =10; //Soul Linker bonus. [Skotlex]
else if(skill_lv==2) maxlv=1;
else if(skill_lv==3) maxlv=2;
@@ -14341,10 +14348,10 @@ int skill_sit_count (struct block_list *bl, va_list ap) {
if(!pc_issit(sd))
return 0;
- if(type&1 && pc_checkskill(sd,RG_GANGSTER) > 0)
+ if(type&1 && pc->checkskill(sd,RG_GANGSTER) > 0)
return 1;
- if(type&2 && (pc_checkskill(sd,TK_HPTIME) > 0 || pc_checkskill(sd,TK_SPTIME) > 0))
+ if(type&2 && (pc->checkskill(sd,TK_HPTIME) > 0 || pc->checkskill(sd,TK_SPTIME) > 0))
return 1;
return 0;
@@ -14359,10 +14366,10 @@ int skill_sit_in (struct block_list *bl, va_list ap) {
if(!pc_issit(sd))
return 0;
- if(type&1 && pc_checkskill(sd,RG_GANGSTER) > 0)
+ if(type&1 && pc->checkskill(sd,RG_GANGSTER) > 0)
sd->state.gangsterparadise=1;
- if(type&2 && (pc_checkskill(sd,TK_HPTIME) > 0 || pc_checkskill(sd,TK_SPTIME) > 0 )) {
+ if(type&2 && (pc->checkskill(sd,TK_HPTIME) > 0 || pc->checkskill(sd,TK_SPTIME) > 0 )) {
sd->state.rest=1;
status_calc_regen(bl, &sd->battle_status, &sd->regen);
status_calc_regen_rate(bl, &sd->regen, &sd->sc);
@@ -14392,15 +14399,15 @@ int skill_sit (struct map_session_data *sd, int type)
nullpo_ret(sd);
- if((lv = pc_checkskill(sd,RG_GANGSTER)) > 0) {
+ if((lv = pc->checkskill(sd,RG_GANGSTER)) > 0) {
flag|=1;
range = skill->get_splash(RG_GANGSTER, lv);
}
- if((lv = pc_checkskill(sd,TK_HPTIME)) > 0) {
+ if((lv = pc->checkskill(sd,TK_HPTIME)) > 0) {
flag|=2;
range = skill->get_splash(TK_HPTIME, lv);
}
- else if ((lv = pc_checkskill(sd,TK_SPTIME)) > 0) {
+ else if ((lv = pc->checkskill(sd,TK_SPTIME)) > 0) {
flag|=2;
range = skill->get_splash(TK_SPTIME, lv);
}
@@ -14414,11 +14421,11 @@ int skill_sit (struct map_session_data *sd, int type)
if (!flag) return 0;
if(type) {
- if (map_foreachinrange(skill->sit_count,&sd->bl, range, BL_PC, flag) > 1)
- map_foreachinrange(skill->sit_in,&sd->bl, range, BL_PC, flag);
+ if (iMap->foreachinrange(skill->sit_count,&sd->bl, range, BL_PC, flag) > 1)
+ iMap->foreachinrange(skill->sit_in,&sd->bl, range, BL_PC, flag);
} else {
- if (map_foreachinrange(skill->sit_count,&sd->bl, range, BL_PC, flag) < 2)
- map_foreachinrange(skill->sit_out,&sd->bl, range, BL_PC, flag);
+ if (iMap->foreachinrange(skill->sit_count,&sd->bl, range, BL_PC, flag) < 2)
+ iMap->foreachinrange(skill->sit_out,&sd->bl, range, BL_PC, flag);
}
return 0;
}
@@ -14464,7 +14471,7 @@ void skill_unitsetmapcell (struct skill_unit *src, uint16 skill_id, uint16 skill
for( y = src->bl.y - range; y <= src->bl.y + range; ++y )
for( x = src->bl.x - range; x <= src->bl.x + range; ++x )
- map_setcell(src->bl.m, x, y, cell, flag);
+ map[src->bl.m].setcell(src->bl.m, x, y, cell, flag);
}
/*==========================================
@@ -14603,7 +14610,7 @@ int skill_greed (struct block_list *bl, va_list ap) {
nullpo_ret(src = va_arg(ap, struct block_list *));
if(src->type == BL_PC && (sd=(struct map_session_data *)src) && bl->type==BL_ITEM && (fitem=(struct flooritem_data *)bl))
- pc_takeitem(sd, fitem);
+ pc->takeitem(sd, fitem);
return 0;
}
@@ -14637,11 +14644,11 @@ int skill_detonator(struct block_list *bl, va_list ap)
clif->talkiebox(bl,unit->group->valstr);
unit->group->val2 = -1;
} else
- map_foreachinrange(skill->trap_splash,bl,skill->get_splash(unit->group->skill_id,unit->group->skill_lv),unit->group->bl_flag,bl,unit->group->tick);
+ iMap->foreachinrange(skill->trap_splash,bl,skill->get_splash(unit->group->skill_id,unit->group->skill_lv),unit->group->bl_flag,bl,unit->group->tick);
clif->changetraplook(bl,unit_id == UNT_FIRINGTRAP ? UNT_DUMMYSKILL : UNT_USED_TRAPS);
unit->group->unit_id = UNT_USED_TRAPS;
- unit->group->limit = DIFF_TICK(gettick(),unit->group->tick) +
+ unit->group->limit = DIFF_TICK(iTimer->gettick(),unit->group->tick) +
(unit_id == UNT_TALKIEBOX ? 5000 : (unit_id == UNT_CLUSTERBOMB || unit_id == UNT_ICEBOUNDTRAP? 2500 : 1500) );
break;
}
@@ -14790,7 +14797,7 @@ int skill_trap_splash (struct block_list *bl, va_list ap) {
return 0;
nullpo_ret(sg = unit->group);
- nullpo_ret(ss = map_id2bl(sg->src_id));
+ nullpo_ret(ss = iMap->id2bl(sg->src_id));
if(battle->check_target(src,bl,sg->target_flag) <= 0)
return 0;
@@ -14835,7 +14842,7 @@ int skill_trap_splash (struct block_list *bl, va_list ap) {
case UNT_MAIZETRAP:
case UNT_VERDURETRAP:
if( bl->type != BL_PC && !is_boss(bl) )
- sc_start2(bl,SC_ELEMENTALCHANGE,100,sg->skill_lv,skill->get_ele(sg->skill_id,sg->skill_lv),skill->get_time2(sg->skill_id,sg->skill_lv));
+ sc_start2(bl,SC_ARMOR_PROPERTY,100,sg->skill_lv,skill->get_ele(sg->skill_id,sg->skill_lv),skill->get_time2(sg->skill_id,sg->skill_lv));
break;
case UNT_REVERBERATION:
skill->addtimerskill(ss,tick+50,bl->id,0,0,WM_REVERBERATION_MELEE,sg->skill_lv,BF_WEAPON,0); // for proper skill delay animation when use with Dominion Impulse
@@ -14854,7 +14861,7 @@ int skill_trap_splash (struct block_list *bl, va_list ap) {
int skill_enchant_elemental_end (struct block_list *bl, int type)
{
struct status_change *sc;
- const enum sc_type scs[] = { SC_ENCPOISON, SC_ASPERSIO, SC_FIREWEAPON, SC_WATERWEAPON, SC_WINDWEAPON, SC_EARTHWEAPON, SC_SHADOWWEAPON, SC_GHOSTWEAPON, SC_ENCHANTARMS, SC_EXEEDBREAK };
+ const enum sc_type scs[] = { SC_ENCHANTPOISON, SC_ASPERSIO, SC_PROPERTYFIRE, SC_PROPERTYWATER, SC_PROPERTYWIND, SC_PROPERTYGROUND, SC_PROPERTYDARK, SC_PROPERTYTELEKINESIS, SC_ENCHANTARMS, SC_EXEEDBREAK };
int i;
nullpo_ret(bl);
nullpo_ret(sc= status_get_sc(bl));
@@ -14878,7 +14885,7 @@ bool skill_check_cloaking(struct block_list *bl, struct status_change_entry *sce
|| (bl->type != BL_PC && battle_config.monster_cloak_check_type&1) )
{ //Check for walls.
int i;
- ARR_FIND( 0, 8, i, map_getcell(bl->m, bl->x+dx[i], bl->y+dy[i], CELL_CHKNOPASS) != 0 );
+ ARR_FIND( 0, 8, i, iMap->getcell(bl->m, bl->x+dx[i], bl->y+dy[i], CELL_CHKNOPASS) != 0 );
if( i == 8 )
wall = false;
}
@@ -14909,7 +14916,7 @@ bool skill_check_camouflage(struct block_list *bl, struct status_change_entry *s
if( bl->type == BL_PC ) { //Check for walls.
int i;
- ARR_FIND( 0, 8, i, map_getcell(bl->m, bl->x+dx[i], bl->y+dy[i], CELL_CHKNOPASS) != 0 );
+ ARR_FIND( 0, 8, i, iMap->getcell(bl->m, bl->x+dx[i], bl->y+dy[i], CELL_CHKNOPASS) != 0 );
if( i == 8 )
wall = false;
}
@@ -14942,7 +14949,7 @@ struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int
if(!unit->alive)
group->alive_count++;
- unit->bl.id=map_get_new_object_id();
+ unit->bl.id=iMap->get_new_object_id();
unit->bl.type=BL_SKILL;
unit->bl.m=group->map;
unit->bl.x=x;
@@ -14953,13 +14960,13 @@ struct skill_unit *skill_initunit (struct skill_unit_group *group, int idx, int
unit->val2=val2;
idb_put(skillunit_db, unit->bl.id, unit);
- map_addiddb(&unit->bl);
- map_addblock(&unit->bl);
+ iMap->addiddb(&unit->bl);
+ iMap->addblock(&unit->bl);
// perform oninit actions
switch (group->skill_id) {
case WZ_ICEWALL:
- map_setgatcell(unit->bl.m,unit->bl.x,unit->bl.y,5);
+ iMap->setgatcell(unit->bl.m,unit->bl.x,unit->bl.y,5);
clif->changemapcell(0,unit->bl.m,unit->bl.x,unit->bl.y,5,AREA);
skill->unitsetmapcell(unit,WZ_ICEWALL,group->skill_lv,CELL_ICEWALL,true);
map[unit->bl.m].icewall_num++;
@@ -15002,18 +15009,18 @@ int skill_delunit (struct skill_unit* unit) {
// invoke onout event
if( !unit->range )
- map_foreachincell(skill->unit_effect,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,gettick(),4);
+ iMap->foreachincell(skill->unit_effect,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,iTimer->gettick(),4);
// perform ondelete actions
switch (group->skill_id) {
case HT_ANKLESNARE: {
- struct block_list* target = map_id2bl(group->val2);
+ struct block_list* target = iMap->id2bl(group->val2);
if( target )
- status_change_end(target, SC_ANKLE, INVALID_TIMER);
+ status_change_end(target, SC_ANKLESNARE, INVALID_TIMER);
}
break;
case WZ_ICEWALL:
- map_setgatcell(unit->bl.m,unit->bl.x,unit->bl.y,unit->val2);
+ iMap->setgatcell(unit->bl.m,unit->bl.x,unit->bl.y,unit->val2);
clif->changemapcell(0,unit->bl.m,unit->bl.x,unit->bl.y,unit->val2,ALL_SAMEMAP); // hack to avoid clientside cell bug
skill->unitsetmapcell(unit,WZ_ICEWALL,group->skill_lv,CELL_ICEWALL,false);
map[unit->bl.m].icewall_num--;
@@ -15025,7 +15032,7 @@ int skill_delunit (struct skill_unit* unit) {
skill->unitsetmapcell(unit,HP_BASILICA,group->skill_lv,CELL_BASILICA,false);
break;
case RA_ELECTRICSHOCKER: {
- struct block_list* target = map_id2bl(group->val2);
+ struct block_list* target = iMap->id2bl(group->val2);
if( target )
status_change_end(target, SC_ELECTRICSHOCKER, INVALID_TIMER);
}
@@ -15035,7 +15042,7 @@ int skill_delunit (struct skill_unit* unit) {
break;
case SC_MANHOLE: // Note : Removing the unit don't remove the status (official info)
if( group->val2 ) { // Someone Traped
- struct status_change *tsc = status_get_sc( map_id2bl(group->val2));
+ struct status_change *tsc = status_get_sc( iMap->id2bl(group->val2));
if( tsc && tsc->data[SC__MANHOLE] )
tsc->data[SC__MANHOLE]->val4 = 0; // Remove the Unit ID
}
@@ -15045,8 +15052,8 @@ int skill_delunit (struct skill_unit* unit) {
clif->skill_delunit(unit);
unit->group=NULL;
- map_delblock(&unit->bl); // don't free yet
- map_deliddb(&unit->bl);
+ iMap->delblock(&unit->bl); // don't free yet
+ iMap->deliddb(&unit->bl);
idb_remove(skillunit_db, unit->bl.id);
if(--group->alive_count==0)
skill->del_unitgroup(group,ALC_MARK);
@@ -15104,7 +15111,7 @@ struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count,
if(i == MAX_SKILLUNITGROUP) {
// array is full, make room by discarding oldest group
int j=0;
- unsigned maxdiff=0,x,tick=gettick();
+ unsigned maxdiff=0,x,tick=iTimer->gettick();
for(i=0;i<MAX_SKILLUNITGROUP && ud->skillunit[i];i++)
if((x=DIFF_TICK(tick,ud->skillunit[i]->tick))>maxdiff){
maxdiff=x;
@@ -15133,7 +15140,7 @@ struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count,
group->map = src->m;
group->limit = limit;
group->interval = interval;
- group->tick = gettick();
+ group->tick = iTimer->gettick();
group->valstr = NULL;
ud->skillunit[i] = group;
@@ -15160,7 +15167,7 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin
return 0;
}
- src=map_id2bl(group->src_id);
+ src=iMap->id2bl(group->src_id);
ud = unit_bl2ud(src);
if(!src || !ud) {
ShowError("skill_delunitgroup: Group's source not found! (src_id: %d skill_id: %d)\n", group->src_id, group->skill_id);
@@ -15262,7 +15269,7 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin
}
idb_remove(group_db, group->group_id);
- map_freeblock(&group->unit->bl); // schedules deallocation of whole array (HACK)
+ iMap->freeblock(&group->unit->bl); // schedules deallocation of whole array (HACK)
group->unit=NULL;
group->group_id=0;
group->unit_count=0;
@@ -15326,7 +15333,7 @@ struct skill_unit_group_tickset *skill_unitgrouptickset_search (struct block_lis
}
if (j == -1) {
- ShowWarning ("skill_unitgrouptickset_search: tickset is full\n");
+ ShowWarning ("skill_unitgrouptickset_search: tickset is full. ( failed for skill '%s' on unit %d )\n",skill->get_name(group->skill_id),bl->type);
j = id % MAX_SKILLUNITGROUPTICKSET;
}
@@ -15348,7 +15355,7 @@ int skill_unit_timer_sub_onplace (struct block_list* bl, va_list ap) {
nullpo_ret(group);
- if( !(skill->get_inf2(group->skill_id)&(INF2_SONG_DANCE|INF2_TRAP|INF2_NOLP)) && map_getcell(bl->m, bl->x, bl->y, CELL_CHKLANDPROTECTOR) )
+ if( !(skill->get_inf2(group->skill_id)&(INF2_SONG_DANCE|INF2_TRAP|INF2_NOLP)) && iMap->getcell(bl->m, bl->x, bl->y, CELL_CHKLANDPROTECTOR) )
return 0; //AoE skills are ineffective. [Skotlex]
if( battle->check_target(&unit->bl,bl,group->target_flag) <= 0 )
@@ -15421,13 +15428,13 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) {
{
struct block_list* src;
- if( unit->val1 > 0 && (src = map_id2bl(group->src_id)) != NULL && src->type == BL_PC )
+ if( unit->val1 > 0 && (src = iMap->id2bl(group->src_id)) != NULL && src->type == BL_PC )
{ // revert unit back into a trap
struct item item_tmp;
memset(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid = group->item_id?group->item_id:ITEMID_TRAP;
item_tmp.identify = 1;
- map_addflooritem(&item_tmp,1,bl->m,bl->x,bl->y,0,0,0,0);
+ iMap->addflooritem(&item_tmp,1,bl->m,bl->x,bl->y,0,0,0,0);
}
skill->delunit(unit);
}
@@ -15441,23 +15448,23 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) {
group->limit = skill->get_time(group->skill_id,group->skill_lv);
unit->limit = skill->get_time(group->skill_id,group->skill_lv);
// apply effect to all units standing on it
- map_foreachincell(skill->unit_effect,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,gettick(),1);
+ iMap->foreachincell(skill->unit_effect,unit->bl.m,unit->bl.x,unit->bl.y,group->bl_flag,&unit->bl,iTimer->gettick(),1);
break;
case UNT_CALLFAMILY:
{
struct map_session_data *sd = NULL;
if(group->val1) {
- sd = map_charid2sd(group->val1);
+ sd = iMap->charid2sd(group->val1);
group->val1 = 0;
if (sd && !map[sd->bl.m].flag.nowarp)
- pc_setpos(sd,map_id2index(unit->bl.m),unit->bl.x,unit->bl.y,CLR_TELEPORT);
+ pc->setpos(sd,map_id2index(unit->bl.m),unit->bl.x,unit->bl.y,CLR_TELEPORT);
}
if(group->val2) {
- sd = map_charid2sd(group->val2);
+ sd = iMap->charid2sd(group->val2);
group->val2 = 0;
if (sd && !map[sd->bl.m].flag.nowarp)
- pc_setpos(sd,map_id2index(unit->bl.m),unit->bl.x,unit->bl.y,CLR_TELEPORT);
+ pc->setpos(sd,map_id2index(unit->bl.m),unit->bl.x,unit->bl.y,CLR_TELEPORT);
}
skill->delunit(unit);
}
@@ -15469,23 +15476,23 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) {
break;
}
clif->changetraplook(bl,UNT_USED_TRAPS);
- map_foreachinrange(skill->trap_splash, bl, skill->get_splash(group->skill_id, group->skill_lv), group->bl_flag, bl, tick);
+ iMap->foreachinrange(skill->trap_splash, bl, skill->get_splash(group->skill_id, group->skill_lv), group->bl_flag, bl, tick);
group->limit = DIFF_TICK(tick,group->tick)+1000;
unit->limit = DIFF_TICK(tick,group->tick)+1000;
group->unit_id = UNT_USED_TRAPS;
break;
case UNT_FEINTBOMB: {
- struct block_list *src = map_id2bl(group->src_id);
+ struct block_list *src = iMap->id2bl(group->src_id);
if( src )
- map_foreachinrange(skill->area_sub, &group->unit->bl, unit->range, splash_target(src), src, SC_FEINTBOMB, group->skill_lv, tick, BCT_ENEMY|SD_ANIMATION|1, skill->castend_damage_id);
+ iMap->foreachinrange(skill->area_sub, &group->unit->bl, unit->range, splash_target(src), src, SC_FEINTBOMB, group->skill_lv, tick, BCT_ENEMY|SD_ANIMATION|1, skill->castend_damage_id);
skill->delunit(unit);
break;
}
case UNT_BANDING:
{
- struct block_list *src = map_id2bl(group->src_id);
+ struct block_list *src = iMap->id2bl(group->src_id);
struct status_change *sc;
if( !src || (sc = status_get_sc(src)) == NULL || !sc->data[SC_BANDING] )
{
@@ -15532,7 +15539,7 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) {
case UNT_REVERBERATION:
if( unit->val1 <= 0 ){
clif->changetraplook(bl,UNT_USED_TRAPS);
- map_foreachinrange(skill->trap_splash, bl, skill->get_splash(group->skill_id, group->skill_lv), group->bl_flag, bl, tick);
+ iMap->foreachinrange(skill->trap_splash, bl, skill->get_splash(group->skill_id, group->skill_lv), group->bl_flag, bl, tick);
group->limit = DIFF_TICK(tick,group->tick)+1000;
unit->limit = DIFF_TICK(tick,group->tick)+1000;
group->unit_id = UNT_USED_TRAPS;
@@ -15556,9 +15563,9 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) {
if( unit->range >= 0 && group->interval != -1 )
{
if( battle_config.skill_wall_check )
- map_foreachinshootrange(skill->unit_timer_sub_onplace, bl, unit->range, group->bl_flag, bl,tick);
+ iMap->foreachinshootrange(skill->unit_timer_sub_onplace, bl, unit->range, group->bl_flag, bl,tick);
else
- map_foreachinrange(skill->unit_timer_sub_onplace, bl, unit->range, group->bl_flag, bl,tick);
+ iMap->foreachinrange(skill->unit_timer_sub_onplace, bl, unit->range, group->bl_flag, bl,tick);
if(unit->range == -1) //Unit disabled, but it should not be deleted yet.
group->unit_id = UNT_USED_TRAPS;
@@ -15580,11 +15587,11 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) {
* Executes on all skill units every SKILLUNITTIMER_INTERVAL miliseconds.
*------------------------------------------*/
int skill_unit_timer(int tid, unsigned int tick, int id, intptr_t data) {
- map_freeblock_lock();
+ iMap->freeblock_lock();
skillunit_db->foreach(skillunit_db, skill->unit_timer_sub, tick);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
@@ -15700,7 +15707,7 @@ int skill_unit_move (struct block_list *bl, unsigned int tick, int flag) {
memset(skill_unit_temp, 0, sizeof(skill_unit_temp));
}
- map_foreachincell(skill->unit_move_sub,bl->m,bl->x,bl->y,BL_SKILL,bl,tick,flag);
+ iMap->foreachincell(skill->unit_move_sub,bl->m,bl->x,bl->y,BL_SKILL,bl,tick,flag);
if( flag&2 && flag&1 ) { //Onplace, check any skill units you have left.
int i;
@@ -15718,7 +15725,7 @@ int skill_unit_move (struct block_list *bl, unsigned int tick, int flag) {
int skill_unit_move_unit_group (struct skill_unit_group *group, int16 m, int16 dx, int16 dy)
{
int i,j;
- unsigned int tick = gettick();
+ unsigned int tick = iTimer->gettick();
int *m_flag;
struct skill_unit *unit1;
struct skill_unit *unit2;
@@ -15766,14 +15773,14 @@ int skill_unit_move_unit_group (struct skill_unit_group *group, int16 m, int16 d
if (!(m_flag[i]&0x2)) {
if (group->state.song_dance&0x1) //Cancel dissonance effect.
skill->dance_overlap(unit1, 0);
- map_foreachincell(skill->unit_effect,unit1->bl.m,unit1->bl.x,unit1->bl.y,group->bl_flag,&unit1->bl,tick,4);
+ iMap->foreachincell(skill->unit_effect,unit1->bl.m,unit1->bl.x,unit1->bl.y,group->bl_flag,&unit1->bl,tick,4);
}
//Move Cell using "smart" criteria (avoid useless moving around)
switch(m_flag[i])
{
case 0:
//Cell moves independently, safely move it.
- map_moveblock(&unit1->bl, unit1->bl.x+dx, unit1->bl.y+dy, tick);
+ iMap->moveblock(&unit1->bl, unit1->bl.x+dx, unit1->bl.y+dy, tick);
break;
case 1:
//Cell moves unto another cell, look for a replacement cell that won't collide
@@ -15784,7 +15791,7 @@ int skill_unit_move_unit_group (struct skill_unit_group *group, int16 m, int16 d
continue;
//Move to where this cell would had moved.
unit2 = &group->unit[j];
- map_moveblock(&unit1->bl, unit2->bl.x+dx, unit2->bl.y+dy, tick);
+ iMap->moveblock(&unit1->bl, unit2->bl.x+dx, unit2->bl.y+dy, tick);
j++; //Skip this cell as we have used it.
break;
}
@@ -15797,7 +15804,7 @@ int skill_unit_move_unit_group (struct skill_unit_group *group, int16 m, int16 d
if (group->state.song_dance&0x1) //Check for dissonance effect.
skill->dance_overlap(unit1, 1);
clif->skill_setunit(unit1);
- map_foreachincell(skill->unit_effect,unit1->bl.m,unit1->bl.x,unit1->bl.y,group->bl_flag,&unit1->bl,tick,1);
+ iMap->foreachincell(skill->unit_effect,unit1->bl.m,unit1->bl.x,unit1->bl.y,group->bl_flag,&unit1->bl,tick,1);
}
}
aFree(m_flag);
@@ -15819,7 +15826,7 @@ int skill_can_produce_mix (struct map_session_data *sd, int nameid, int trigger,
for(i=0;i<MAX_SKILL_PRODUCE_DB;i++){
if(skill_produce_db[i].nameid == nameid ){
if((j=skill_produce_db[i].req_skill)>0 &&
- pc_checkskill(sd,j) < skill_produce_db[i].req_skill_lv)
+ pc->checkskill(sd,j) < skill_produce_db[i].req_skill_lv)
continue; // must iterate again to check other skills that produce it. [malufett]
if( j > 0 && sd->menuskill_id > 0 && sd->menuskill_id != j )
continue; // special case
@@ -15830,7 +15837,7 @@ int skill_can_produce_mix (struct map_session_data *sd, int nameid, int trigger,
if( i >= MAX_SKILL_PRODUCE_DB )
return 0;
- if( pc_checkadditem(sd, nameid, qty) == ADDITEM_OVERAMOUNT )
+ if( pc->checkadditem(sd, nameid, qty) == ADDITEM_OVERAMOUNT )
{// cannot carry the produced stuff
return 0;
}
@@ -15853,7 +15860,7 @@ int skill_can_produce_mix (struct map_session_data *sd, int nameid, int trigger,
if( (id=skill_produce_db[i].mat_id[j]) <= 0 )
continue;
if(skill_produce_db[i].mat_amount[j] <= 0) {
- if(pc_search_inventory(sd,id) < 0)
+ if(pc->search_inventory(sd,id) < 0)
return 0;
}
else {
@@ -15905,23 +15912,23 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid,
int j;
if( slot[i]<=0 )
continue;
- j = pc_search_inventory(sd,slot[i]);
+ j = pc->search_inventory(sd,slot[i]);
if(j < 0)
continue;
if(slot[i]==1000){ /* Star Crumb */
- pc_delitem(sd,j,1,1,0,LOG_TYPE_PRODUCE);
+ pc->delitem(sd,j,1,1,0,LOG_TYPE_PRODUCE);
sc++;
}
if(slot[i]>=994 && slot[i]<=997 && ele==0){ /* Flame Heart . . . Great Nature */
static const int ele_table[4]={3,1,4,2};
- pc_delitem(sd,j,1,1,0,LOG_TYPE_PRODUCE);
+ pc->delitem(sd,j,1,1,0,LOG_TYPE_PRODUCE);
ele=ele_table[slot[i]-994];
}
}
if( skill_id == RK_RUNEMASTERY ) {
- int temp_qty, skill_lv = pc_checkskill(sd,skill_id);
- data = itemdb_search(nameid);
+ int temp_qty, skill_lv = pc->checkskill(sd,skill_id);
+ data = itemdb->search(nameid);
if( skill_lv == 10 ) temp_qty = 1 + rnd()%3;
else if( skill_lv > 5 ) temp_qty = 1 + rnd()%2;
@@ -15955,12 +15962,12 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid,
x=( skill_id == RK_RUNEMASTERY ? 1 : qty)*skill_produce_db[idx].mat_amount[i];
do{
int y=0;
- j = pc_search_inventory(sd,id);
+ j = pc->search_inventory(sd,id);
if(j >= 0){
y = sd->status.inventory[j].amount;
if(y>x)y=x;
- pc_delitem(sd,j,y,0,0,LOG_TYPE_PRODUCE);
+ pc->delitem(sd,j,y,0,0,LOG_TYPE_PRODUCE);
} else
ShowError("skill_produce_mix: material item error\n");
@@ -15976,7 +15983,7 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid,
case BS_STEEL:
case BS_ENCHANTEDSTONE:
// Ores & Metals Refining - skill bonuses are straight from kRO website [DracoRPG]
- i = pc_checkskill(sd,skill_id);
+ i = pc->checkskill(sd,skill_id);
make_per = sd->status.job_level*20 + status->dex*10 + status->luk*10; //Base chance
switch(nameid){
case 998: // Iron
@@ -16007,8 +16014,8 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid,
case AM_TWILIGHT1:
case AM_TWILIGHT2:
case AM_TWILIGHT3:
- make_per = pc_checkskill(sd,AM_LEARNINGPOTION)*50
- + pc_checkskill(sd,AM_PHARMACY)*300 + sd->status.job_level*20
+ make_per = pc->checkskill(sd,AM_LEARNINGPOTION)*50
+ + pc->checkskill(sd,AM_PHARMACY)*300 + sd->status.job_level*20
+ (status->int_/2)*10 + status->dex*10+status->luk*10;
if(homun_alive(sd->hd)) {//Player got a homun
int skill;
@@ -16056,40 +16063,39 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid,
**/
case RK_RUNEMASTERY:
{
- int A = 100 * (51 + 2 * pc_checkskill(sd, skill_id));
- int B = 100 * status->dex / 30 + 10 * (status->luk + sd->status.job_level);
+ int A = 5100 + 200 * pc->checkskill(sd, skill_id);
+ int B = 10 * status->dex / 3 + (status->luk + sd->status.job_level);
int C = 100 * cap_value(sd->itemid,0,100); //itemid depend on makerune()
- int D = 0;
+ int D = 2500;
switch (nameid) { //rune rank it_diff 9 craftable rune
- case ITEMID_BERKANA:
- D = -2000;
- break; //Rank S
- case ITEMID_NAUTHIZ:
- case ITEMID_URUZ:
- D = -1500;
- break; //Rank A
- case ITEMID_ISA:
- case ITEMID_WYRD:
- D = -1000;
- break; //Rank B
case ITEMID_RAIDO:
case ITEMID_THURISAZ:
case ITEMID_HAGALAZ:
case ITEMID_OTHILA:
- D = -500;
- break; //Rank C
- default: D = -1500;
- break; //not specified =-15%
+ D -= 500; //Rank C
+ case ITEMID_ISA:
+ case ITEMID_WYRD:
+ D -= 500; //Rank B
+ case ITEMID_NAUTHIZ:
+ case ITEMID_URUZ:
+ D -= 500; //Rank A
+ case ITEMID_BERKANA:
+ D -= 500; //Rank S
}
- make_per = A + B + C + D;
+ make_per = A + B + C - D;
break;
}
/**
* Guilotine Cross
**/
case GC_CREATENEWPOISON:
- make_per = 3000 + 500 * pc_checkskill(sd,GC_RESEARCHNEWPOISON);
- qty = 1+rnd()%pc_checkskill(sd,GC_RESEARCHNEWPOISON);
+ {
+ const int min[] = {2, 2, 3, 3, 4, 4, 5, 5, 6, 6};
+ const int max[] = {4, 5, 5, 6, 6, 7, 7, 8, 8, 9};
+ uint16 lv = pc->checkskill(sd,GC_RESEARCHNEWPOISON);
+ make_per = 3000 + 500 * lv ;
+ qty = min[lv] + rand()%(max[lv] - min[lv]);
+ }
break;
case GN_CHANGEMATERIAL:
for(i=0; i<MAX_SKILL_PRODUCE_DB; i++)
@@ -16105,7 +16111,7 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid,
difficulty = (620 - 20 * skill_lv);// (620 - 20 * Skill Level)
make_per = status->int_ + status->dex/2 + status->luk + sd->status.job_level + (30+rnd()%120) + // (Caster?s INT) + (Caster?s DEX / 2) + (Caster?s LUK) + (Caster?s Job Level) + Random number between (30 ~ 150) +
- (sd->status.base_level-100) + pc_checkskill(sd, AM_LEARNINGPOTION) + pc_checkskill(sd, CR_FULLPROTECTION)*(4+rnd()%6); // (Caster?s Base Level - 100) + (Potion Research x 5) + (Full Chemical Protection Skill Level) x (Random number between 4 ~ 10)
+ (sd->status.base_level-100) + pc->checkskill(sd, AM_LEARNINGPOTION) + pc->checkskill(sd, CR_FULLPROTECTION)*(4+rnd()%6); // (Caster?s Base Level - 100) + (Potion Research x 5) + (Full Chemical Protection Skill Level) x (Random number between 4 ~ 10)
switch(nameid){// difficulty factor
case 12422: case 12425:
@@ -16207,13 +16213,13 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid,
}
} else { // Weapon Forging - skill bonuses are straight from kRO website, other things from a jRO calculator [DracoRPG]
make_per = 5000 + sd->status.job_level*20 + status->dex*10 + status->luk*10; // Base
- make_per += pc_checkskill(sd,skill_id)*500; // Smithing skills bonus: +5/+10/+15
- make_per += pc_checkskill(sd,BS_WEAPONRESEARCH)*100 +((wlv >= 3)? pc_checkskill(sd,BS_ORIDEOCON)*100:0); // Weaponry Research bonus: +1/+2/+3/+4/+5/+6/+7/+8/+9/+10, Oridecon Research bonus (custom): +1/+2/+3/+4/+5
+ make_per += pc->checkskill(sd,skill_id)*500; // Smithing skills bonus: +5/+10/+15
+ make_per += pc->checkskill(sd,BS_WEAPONRESEARCH)*100 +((wlv >= 3)? pc->checkskill(sd,BS_ORIDEOCON)*100:0); // Weaponry Research bonus: +1/+2/+3/+4/+5/+6/+7/+8/+9/+10, Oridecon Research bonus (custom): +1/+2/+3/+4/+5
make_per -= (ele?2000:0) + sc*1500 + (wlv>1?wlv*1000:0); // Element Stone: -20%, Star Crumb: -15% each, Weapon level malus: -0/-20/-30
- if(pc_search_inventory(sd,989) > 0) make_per+= 1000; // Emperium Anvil: +10
- else if(pc_search_inventory(sd,988) > 0) make_per+= 500; // Golden Anvil: +5
- else if(pc_search_inventory(sd,987) > 0) make_per+= 300; // Oridecon Anvil: +3
- else if(pc_search_inventory(sd,986) > 0) make_per+= 0; // Anvil: +0?
+ if(pc->search_inventory(sd,989) > 0) make_per+= 1000; // Emperium Anvil: +10
+ else if(pc->search_inventory(sd,988) > 0) make_per+= 500; // Golden Anvil: +5
+ else if(pc->search_inventory(sd,987) > 0) make_per+= 300; // Oridecon Anvil: +3
+ else if(pc->search_inventory(sd,986) > 0) make_per+= 0; // Anvil: +0?
if(battle_config.wp_rate != 100)
make_per = make_per * battle_config.wp_rate / 100;
}
@@ -16283,7 +16289,7 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid,
clif->produce_effect(sd,0,nameid);
clif->misceffect(&sd->bl,3);
if(itemdb_wlv(nameid) >= 3 && ((ele? 1 : 0) + sc) >= 3) // Fame point system [DracoRPG]
- pc_addfame(sd,10); // Success to forge a lv3 weapon with 3 additional ingredients = +10 fame point
+ pc->addfame(sd,10); // Success to forge a lv3 weapon with 3 additional ingredients = +10 fame point
} else {
int fame = 0;
tmp_item.amount = 0;
@@ -16323,7 +16329,7 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid,
}
if (fame)
- pc_addfame(sd,fame);
+ pc->addfame(sd,fame);
//Visual effects and the like.
switch (skill_id) {
case AM_PHARMACY:
@@ -16362,9 +16368,9 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid,
for(j=0; j<5; j++){
if( rnd()%1000 < skill_changematerial_db[i].qty_rate[j] ){
tmp_item.amount = qty * skill_changematerial_db[i].qty[j];
- if((flag = pc_additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE))) {
+ if((flag = pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE))) {
clif->additem(sd,0,0,flag);
- map_addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ iMap->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
k++;
}
@@ -16376,9 +16382,9 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid,
return 1;
}
} else if (tmp_item.amount) { //Success
- if((flag = pc_additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE))) {
+ if((flag = pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE))) {
clif->additem(sd,0,0,flag);
- map_addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ iMap->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
if( skill_id == GN_MIX_COOKING || skill_id == GN_MAKEBOMB || skill_id == GN_S_PHARMACY )
clif->msg_skill(sd,skill_id,0x627);
@@ -16428,9 +16434,9 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid,
tmp_item.nameid = compensation[i];
tmp_item.amount = qty;
tmp_item.identify = 1;
- if( pc_additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE) ) {
+ if( pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE) ) {
clif->additem(sd,0,0,flag);
- map_addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ iMap->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
clif->msg_skill(sd,skill_id,0x628);
}
@@ -16468,10 +16474,10 @@ int skill_arrow_create (struct map_session_data *sd, int nameid)
break;
}
- if(index < 0 || (j = pc_search_inventory(sd,nameid)) < 0)
+ if(index < 0 || (j = pc->search_inventory(sd,nameid)) < 0)
return 1;
- pc_delitem(sd,j,1,0,0,LOG_TYPE_PRODUCE);
+ pc->delitem(sd,j,1,0,0,LOG_TYPE_PRODUCE);
for(i=0;i<MAX_ARROW_RESOURCE;i++) {
memset(&tmp_item,0,sizeof(tmp_item));
tmp_item.identify = 1;
@@ -16485,9 +16491,9 @@ int skill_arrow_create (struct map_session_data *sd, int nameid)
}
if(tmp_item.nameid <= 0 || tmp_item.amount <= 0)
continue;
- if((flag = pc_additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE))) {
+ if((flag = pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_PRODUCE))) {
clif->additem(sd,0,0,flag);
- map_addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ iMap->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
}
@@ -16497,7 +16503,7 @@ int skill_poisoningweapon( struct map_session_data *sd, int nameid) {
sc_type type;
int chance, i;
nullpo_ret(sd);
- if( nameid <= 0 || (i = pc_search_inventory(sd,nameid)) < 0 || pc_delitem(sd,i,1,0,0,LOG_TYPE_CONSUME) ) {
+ if( nameid <= 0 || (i = pc->search_inventory(sd,nameid)) < 0 || pc->delitem(sd,i,1,0,0,LOG_TYPE_CONSUME) ) {
clif->skill_fail(sd,GC_POISONINGWEAPON,USESKILL_FAIL_LEVEL,0);
return 0;
}
@@ -16517,7 +16523,7 @@ int skill_poisoningweapon( struct map_session_data *sd, int nameid) {
}
chance = 2 + 2 * sd->menuskill_val; // 2 + 2 * skill_lv
- sc_start4(&sd->bl, SC_POISONINGWEAPON, 100, pc_checkskill(sd, GC_RESEARCHNEWPOISON), //in Aegis it store the level of GC_RESEARCHNEWPOISON in val1
+ sc_start4(&sd->bl, SC_POISONINGWEAPON, 100, pc->checkskill(sd, GC_RESEARCHNEWPOISON), //in Aegis it store the level of GC_RESEARCHNEWPOISON in val1
type, chance, 0, skill->get_time(GC_POISONINGWEAPON, sd->menuskill_val));
return 0;
@@ -16553,14 +16559,14 @@ int skill_magicdecoy(struct map_session_data *sd, int nameid) {
nullpo_ret(sd);
skill_id = sd->menuskill_val;
- if( nameid <= 0 || !itemdb_is_element(nameid) || (i = pc_search_inventory(sd,nameid)) < 0 || !skill_id || pc_delitem(sd,i,1,0,0,LOG_TYPE_CONSUME) )
+ if( nameid <= 0 || !itemdb_is_element(nameid) || (i = pc->search_inventory(sd,nameid)) < 0 || !skill_id || pc->delitem(sd,i,1,0,0,LOG_TYPE_CONSUME) )
{
clif->skill_fail(sd,NC_MAGICDECOY,USESKILL_FAIL_LEVEL,0);
return 0;
}
// Spawn Position
- pc_delitem(sd,i,1,0,0,LOG_TYPE_CONSUME);
+ pc->delitem(sd,i,1,0,0,LOG_TYPE_CONSUME);
x = sd->sc.comet_x;
y = sd->sc.comet_y;
sd->sc.comet_x = sd->sc.comet_y = 0;
@@ -16574,8 +16580,8 @@ int skill_magicdecoy(struct map_session_data *sd, int nameid) {
md->master_id = sd->bl.id;
md->special_state.ai = AI_FLORA;
if( md->deletetimer != INVALID_TIMER )
- delete_timer(md->deletetimer, mob_timer_delete);
- md->deletetimer = add_timer (gettick() + skill->get_time(NC_MAGICDECOY,skill_id), mob_timer_delete, md->bl.id, 0);
+ iTimer->delete_timer(md->deletetimer, mob_timer_delete);
+ md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(NC_MAGICDECOY,skill_id), mob_timer_delete, md->bl.id, 0);
mob_spawn(md);
md->status.matk_min = md->status.matk_max = 250 + (50 * skill_id);
}
@@ -16593,8 +16599,8 @@ int skill_spellbook (struct map_session_data *sd, int nameid) {
sc = status_get_sc(&sd->bl);
status_change_end(&sd->bl, SC_STOP, INVALID_TIMER);
- for(i=SC_SPELLBOOK1; i <= SC_MAXSPELLBOOK; i++) if( sc && !sc->data[i] ) break;
- if( i > SC_MAXSPELLBOOK )
+ for(i=SC_SPELLBOOK1; i <= SC_SPELLBOOK7; i++) if( sc && !sc->data[i] ) break;
+ if( i > SC_SPELLBOOK7 )
{
clif->skill_fail(sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_READING, 0);
return 0;
@@ -16603,14 +16609,14 @@ int skill_spellbook (struct map_session_data *sd, int nameid) {
ARR_FIND(0,MAX_SKILL_SPELLBOOK_DB,i,skill_spellbook_db[i].nameid == nameid); // Search for information of this item
if( i == MAX_SKILL_SPELLBOOK_DB ) return 0;
- if( !pc_checkskill(sd, (skill_id = skill_spellbook_db[i].skill_id)) )
+ if( !pc->checkskill(sd, (skill_id = skill_spellbook_db[i].skill_id)) )
{ // User don't know the skill
- sc_start(&sd->bl, SC_SLEEP, 100, 1, skill->get_time(WL_READING_SB, pc_checkskill(sd,WL_READING_SB)));
+ sc_start(&sd->bl, SC_SLEEP, 100, 1, skill->get_time(WL_READING_SB, pc->checkskill(sd,WL_READING_SB)));
clif->skill_fail(sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_DIFFICULT_SLEEP, 0);
return 0;
}
- max_preserve = 4 * pc_checkskill(sd, WL_FREEZE_SP) + status_get_int(&sd->bl) / 10 + sd->status.base_level / 10;
+ max_preserve = 4 * pc->checkskill(sd, WL_FREEZE_SP) + (status_get_int(&sd->bl) + sd->status.base_level) / 10;
point = skill_spellbook_db[i].point;
if( sc && sc->data[SC_READING_SB] ) {
@@ -16618,16 +16624,16 @@ int skill_spellbook (struct map_session_data *sd, int nameid) {
clif->skill_fail(sd, WL_READING_SB, USESKILL_FAIL_SPELLBOOK_PRESERVATION_POINT, 0);
return 0;
}
- for(i = SC_MAXSPELLBOOK; i >= SC_SPELLBOOK1; i--){ // This is how official saves spellbook. [malufett]
+ for(i = SC_SPELLBOOK7; i >= SC_SPELLBOOK1; i--){ // This is how official saves spellbook. [malufett]
if( !sc->data[i] ){
sc->data[SC_READING_SB]->val2 += point; // increase points
- sc_start4(&sd->bl, (sc_type)i, 100, skill_id, pc_checkskill(sd,skill_id), point, 0, INVALID_TIMER);
+ sc_start4(&sd->bl, (sc_type)i, 100, skill_id, pc->checkskill(sd,skill_id), point, 0, INVALID_TIMER);
break;
}
}
}else{
sc_start2(&sd->bl, SC_READING_SB, 100, 0, point, INVALID_TIMER);
- sc_start4(&sd->bl, SC_MAXSPELLBOOK, 100, skill_id, pc_checkskill(sd,skill_id), point, 0, INVALID_TIMER);
+ sc_start4(&sd->bl, SC_SPELLBOOK7, 100, skill_id, pc->checkskill(sd,skill_id), point, 0, INVALID_TIMER);
}
return 1;
@@ -16696,7 +16702,7 @@ int skill_elementalanalysis(struct map_session_data* sd, int n, uint16 skill_lv,
return 1;
}
- if( pc_delitem(sd,idx,del_amount,0,1,LOG_TYPE_CONSUME) ) {
+ if( pc->delitem(sd,idx,del_amount,0,1,LOG_TYPE_CONSUME) ) {
clif->skill_fail(sd,SO_EL_ANALYSIS,USESKILL_FAIL_LEVEL,0);
return 1;
}
@@ -16713,9 +16719,9 @@ int skill_elementalanalysis(struct map_session_data* sd, int n, uint16 skill_lv,
tmp_item.identify = 1;
if( tmp_item.amount ) {
- if( (flag = pc_additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_CONSUME)) ) {
+ if( (flag = pc->additem(sd,&tmp_item,tmp_item.amount,LOG_TYPE_CONSUME)) ) {
clif->additem(sd,0,0,flag);
- map_addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ iMap->addflooritem(&tmp_item,tmp_item.amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
}
@@ -16793,7 +16799,7 @@ int skill_destroy_trap( struct block_list *bl, va_list ap ) {
case UNT_CLUSTERBOMB:
case UNT_FIRINGTRAP:
case UNT_ICEBOUNDTRAP:
- map_foreachinrange(skill->trap_splash,&su->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &su->bl,tick);
+ iMap->foreachinrange(skill->trap_splash,&su->bl, skill->get_splash(sg->skill_id, sg->skill_lv), sg->bl_flag, &su->bl,tick);
break;
}
// Traps aren't recovered.
@@ -16805,7 +16811,7 @@ int skill_destroy_trap( struct block_list *bl, va_list ap ) {
*
*------------------------------------------*/
int skill_blockpc_end(int tid, unsigned int tick, int id, intptr_t data) {
- struct map_session_data *sd = map_id2sd(id);
+ struct map_session_data *sd = iMap->id2sd(id);
struct skill_cd * cd = NULL;
if (data <= 0 || data >= MAX_SKILL)
@@ -16863,7 +16869,7 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick,
}
if( battle_config.display_status_timers )
- clif->skill_cooldown(sd, idx, tick);
+ clif->skill_cooldown(sd, skill_id, tick);
if( !load ) {// not being loaded initially so ensure the skill delay is recorded
if( !(cd = idb_get(skillcd_db,sd->status.char_id)) ) {// create a new skill cooldown object for map storage
@@ -16878,12 +16884,12 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick,
cd->cursor++;
}
- sd->blockskill[idx] = 0x1|(0xFE&add_timer(gettick()+tick,skill->blockpc_end,sd->bl.id,idx));
+ sd->blockskill[idx] = 0x1|(0xFE&iTimer->add_timer(iTimer->gettick()+tick,skill->blockpc_end,sd->bl.id,idx));
return 0;
}
int skill_blockhomun_end(int tid, unsigned int tick, int id, intptr_t data) { //[orn]
- struct homun_data *hd = (TBL_HOM*) map_id2bl(id);
+ struct homun_data *hd = (TBL_HOM*) iMap->id2bl(id);
if (data <= 0 || data >= MAX_SKILL)
return 0;
if (hd) hd->blockskill[data] = 0;
@@ -16904,11 +16910,11 @@ int skill_blockhomun_start(struct homun_data *hd, uint16 skill_id, int tick) { /
return -1;
}
hd->blockskill[idx] = 1;
- return add_timer(gettick() + tick, skill->blockhomun_end, hd->bl.id, idx);
+ return iTimer->add_timer(iTimer->gettick() + tick, skill->blockhomun_end, hd->bl.id, idx);
}
int skill_blockmerc_end(int tid, unsigned int tick, int id, intptr_t data) {//[orn]
- struct mercenary_data *md = (TBL_MER*)map_id2bl(id);
+ struct mercenary_data *md = (TBL_MER*)iMap->id2bl(id);
if( data <= 0 || data >= MAX_SKILL )
return 0;
if( md ) md->blockskill[data] = 0;
@@ -16929,7 +16935,7 @@ int skill_blockmerc_start(struct mercenary_data *md, uint16 skill_id, int tick)
return -1;
}
md->blockskill[idx] = 1;
- return add_timer(gettick() + tick, skill->blockmerc_end, md->bl.id, idx);
+ return iTimer->add_timer(iTimer->gettick() + tick, skill->blockmerc_end, md->bl.id, idx);
}
/**
* Adds a new skill unit entry for this player to recast after map load
@@ -17338,7 +17344,7 @@ int skill_block_check(struct block_list *bl, sc_type type , uint16 skill_id) {
return 1; // Can't do it.
}
break;
- case SC_KAGEHUMI:
+ case SC_KG_KAGEHUMI:
switch(skill_id) {
case TF_HIDING: case AS_CLOAKING: case GC_CLOAKINGEXCEED: case SC_SHADOWFORM:
case MI_HARMONIZE: case CG_MARIONETTE: case AL_TELEPORT: case TF_BACKSLIDING:
@@ -17581,6 +17587,7 @@ bool skill_parse_row_unitdb(char* split[], int columns, int current) {
else if( strcmpi(split[6],"all")==0 ) skill_db[idx].unit_target = BCT_ALL;
else if( strcmpi(split[6],"enemy")==0 ) skill_db[idx].unit_target = BCT_ENEMY;
else if( strcmpi(split[6],"self")==0 ) skill_db[idx].unit_target = BCT_SELF;
+ else if( strcmpi(split[6],"sameguild")==0 ) skill_db[idx].unit_target = BCT_GUILD|BCT_SAMEGUILD;
else if( strcmpi(split[6],"noone")==0 ) skill_db[idx].unit_target = BCT_NOONE;
else skill_db[idx].unit_target = strtol(split[6],NULL,16);
@@ -17796,27 +17803,27 @@ void skill_readdb(void) {
safestrncpy(skill_db[0].name, "UNKNOWN_SKILL", sizeof(skill_db[0].name));
safestrncpy(skill_db[0].desc, "Unknown Skill", sizeof(skill_db[0].desc));
- sv->readdb(db_path, DBPATH"skill_db.txt" , ',', 17, 17, MAX_SKILL_DB, skill->parse_row_skilldb);
- sv->readdb(db_path, DBPATH"skill_require_db.txt" , ',', 32, 32, MAX_SKILL_DB, skill->parse_row_requiredb);
+ sv->readdb(iMap->db_path, DBPATH"skill_db.txt" , ',', 17, 17, MAX_SKILL_DB, skill->parse_row_skilldb);
+ sv->readdb(iMap->db_path, DBPATH"skill_require_db.txt" , ',', 32, 32, MAX_SKILL_DB, skill->parse_row_requiredb);
#ifdef RENEWAL_CAST
- sv->readdb(db_path, "re/skill_cast_db.txt" , ',', 8, 8, MAX_SKILL_DB, skill->parse_row_castdb);
+ sv->readdb(iMap->db_path, "re/skill_cast_db.txt" , ',', 8, 8, MAX_SKILL_DB, skill->parse_row_castdb);
#else
- sv->readdb(db_path, "pre-re/skill_cast_db.txt" , ',', 7, 7, MAX_SKILL_DB, skill->parse_row_castdb);
+ sv->readdb(iMap->db_path, "pre-re/skill_cast_db.txt" , ',', 7, 7, MAX_SKILL_DB, skill->parse_row_castdb);
#endif
- sv->readdb(db_path, DBPATH"skill_castnodex_db.txt", ',', 2, 3, MAX_SKILL_DB, skill->parse_row_castnodexdb);
- sv->readdb(db_path, DBPATH"skill_unit_db.txt" , ',', 8, 8, MAX_SKILL_DB, skill->parse_row_unitdb);
+ sv->readdb(iMap->db_path, DBPATH"skill_castnodex_db.txt", ',', 2, 3, MAX_SKILL_DB, skill->parse_row_castnodexdb);
+ sv->readdb(iMap->db_path, DBPATH"skill_unit_db.txt" , ',', 8, 8, MAX_SKILL_DB, skill->parse_row_unitdb);
skill->init_unit_layout();
- sv->readdb(db_path, "produce_db.txt" , ',', 4, 4+2*MAX_PRODUCE_RESOURCE, MAX_SKILL_PRODUCE_DB, skill->parse_row_producedb);
- sv->readdb(db_path, "create_arrow_db.txt" , ',', 1+2, 1+2*MAX_ARROW_RESOURCE, MAX_SKILL_ARROW_DB, skill->parse_row_createarrowdb);
- sv->readdb(db_path, "abra_db.txt" , ',', 4, 4, MAX_SKILL_ABRA_DB, skill->parse_row_abradb);
+ sv->readdb(iMap->db_path, "produce_db.txt" , ',', 4, 4+2*MAX_PRODUCE_RESOURCE, MAX_SKILL_PRODUCE_DB, skill->parse_row_producedb);
+ sv->readdb(iMap->db_path, "create_arrow_db.txt" , ',', 1+2, 1+2*MAX_ARROW_RESOURCE, MAX_SKILL_ARROW_DB, skill->parse_row_createarrowdb);
+ sv->readdb(iMap->db_path, "abra_db.txt" , ',', 4, 4, MAX_SKILL_ABRA_DB, skill->parse_row_abradb);
//Warlock
- sv->readdb(db_path, "spellbook_db.txt" , ',', 3, 3, MAX_SKILL_SPELLBOOK_DB, skill->parse_row_spellbookdb);
+ sv->readdb(iMap->db_path, "spellbook_db.txt" , ',', 3, 3, MAX_SKILL_SPELLBOOK_DB, skill->parse_row_spellbookdb);
//Guillotine Cross
- sv->readdb(db_path, "magicmushroom_db.txt" , ',', 1, 1, MAX_SKILL_MAGICMUSHROOM_DB, skill->parse_row_magicmushroomdb);
- sv->readdb(db_path, "skill_reproduce_db.txt", ',', 1, 1, MAX_SKILL_DB, skill->parse_row_reproducedb);
- sv->readdb(db_path, "skill_improvise_db.txt" , ',', 2, 2, MAX_SKILL_IMPROVISE_DB, skill->parse_row_improvisedb);
- sv->readdb(db_path, "skill_changematerial_db.txt" , ',', 4, 4+2*5, MAX_SKILL_PRODUCE_DB, skill->parse_row_changematerialdb);
+ sv->readdb(iMap->db_path, "magicmushroom_db.txt" , ',', 1, 1, MAX_SKILL_MAGICMUSHROOM_DB, skill->parse_row_magicmushroomdb);
+ sv->readdb(iMap->db_path, "skill_reproduce_db.txt", ',', 1, 1, MAX_SKILL_DB, skill->parse_row_reproducedb);
+ sv->readdb(iMap->db_path, "skill_improvise_db.txt" , ',', 2, 2, MAX_SKILL_IMPROVISE_DB, skill->parse_row_improvisedb);
+ sv->readdb(iMap->db_path, "skill_changematerial_db.txt" , ',', 4, 4+2*5, MAX_SKILL_PRODUCE_DB, skill->parse_row_changematerialdb);
}
void skill_reload (void) {
@@ -17851,7 +17858,7 @@ void skill_reload (void) {
*
*------------------------------------------*/
int do_init_skill (void) {
- skilldb_name2id = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, 0);
+ skilldb_name2id = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, MAX_SKILL_NAME_LENGTH);
skill->read_db();
group_db = idb_alloc(DB_OPT_BASE);
@@ -17861,13 +17868,13 @@ int do_init_skill (void) {
skill_unit_ers = ers_new(sizeof(struct skill_unit_group),"skill.c::skill_unit_ers",ERS_OPT_NONE);
skill_timer_ers = ers_new(sizeof(struct skill_timerskill),"skill.c::skill_timer_ers",ERS_OPT_NONE);
- add_timer_func_list(skill->unit_timer,"skill_unit_timer");
- add_timer_func_list(skill->castend_id,"skill_castend_id");
- add_timer_func_list(skill->castend_pos,"skill_castend_pos");
- add_timer_func_list(skill->timerskill,"skill_timerskill");
- add_timer_func_list(skill->blockpc_end, "skill_blockpc_end");
+ iTimer->add_timer_func_list(skill->unit_timer,"skill_unit_timer");
+ iTimer->add_timer_func_list(skill->castend_id,"skill_castend_id");
+ iTimer->add_timer_func_list(skill->castend_pos,"skill_castend_pos");
+ iTimer->add_timer_func_list(skill->timerskill,"skill_timerskill");
+ iTimer->add_timer_func_list(skill->blockpc_end, "skill_blockpc_end");
- add_timer_interval(gettick()+SKILLUNITTIMER_INTERVAL,skill->unit_timer,0,0,SKILLUNITTIMER_INTERVAL);
+ iTimer->add_timer_interval(iTimer->gettick()+SKILLUNITTIMER_INTERVAL,skill->unit_timer,0,0,SKILLUNITTIMER_INTERVAL);
return 0;
}
@@ -17967,6 +17974,7 @@ void skill_defaults(void) {
skill->delay_fix = skill_delay_fix;
skill->check_condition_castbegin = skill_check_condition_castbegin;
skill->check_condition_castend = skill_check_condition_castend;
+ skill->check_condition_char_sub = skill_check_condition_char_sub;
skill->get_requirement = skill_get_requirement;
skill->check_pc_partner = skill_check_pc_partner;
skill->consume_requirement = skill_consume_requirement;
diff --git a/src/map/skill.h b/src/map/skill.h
index c585bbb3a..921a682a2 100644
--- a/src/map/skill.h
+++ b/src/map/skill.h
@@ -37,6 +37,7 @@ struct square;
#define MAX_SKILLUNITGROUP 25
#define MAX_SKILL_ITEM_REQUIRE 10
#define MAX_SKILLUNITGROUPTICKSET 25
+#define MAX_SKILL_NAME_LENGTH 30
// (Epoque:) To-do: replace this macro with some sort of skill tree check (rather than hard-coded skill names)
#define skill_ischangesex(id) ( \
@@ -1281,7 +1282,26 @@ enum e_skill {
ECL_SADAGUI,
ECL_SEQUOIADUST,
ECLAGE_RECALL,
-
+
+ GC_DARKCROW = 5001,
+ RA_UNLIMIT,
+ GN_ILLUSIONDOPING,
+ RK_DRAGONBREATH_WATER,
+ RK_LUXANIMA,
+ NC_MAGMA_ERUPTION,
+ WM_FRIGG_SONG,
+ SO_ELEMENTAL_SHIELD,
+ SR_FLASHCOMBO,
+ SC_ESCAPE,
+ AB_OFFERTORIUM,
+ WL_TELEKINESIS_INTENSE,
+ LG_KINGS_GRACE,
+ ALL_FULL_THROTTLE,
+ SR_FLASHCOMBO_ATK_STEP1,
+ SR_FLASHCOMBO_ATK_STEP2,
+ SR_FLASHCOMBO_ATK_STEP3,
+ SR_FLASHCOMBO_ATK_STEP4,
+
HLIF_HEAL = 8001,
HLIF_AVOID,
HLIF_BRAIN,
@@ -1541,6 +1561,10 @@ enum {
UNT_ZENKAI_WIND,
UNT_MAKIBISHI,
UNT_VENOMFOG,
+ UNT_ICEMINE,
+ UNT_FLAMECROSS,
+ UNT_HELLBURNING,
+ UNT_MAGMA_ERUPTION,
/**
* Guild Auras
@@ -1576,7 +1600,7 @@ struct skill_condition {
// Database skills
struct s_skill_db {
unsigned short nameid;
- char name[NAME_LENGTH];
+ char name[MAX_SKILL_NAME_LENGTH];
char desc[40];
int range[MAX_SKILL_LEVEL],hit,inf,element[MAX_SKILL_LEVEL],nk,splash[MAX_SKILL_LEVEL],max;
int num[MAX_SKILL_LEVEL];
diff --git a/src/map/status.c b/src/map/status.c
index b7e906910..fdee5b954 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -69,6 +69,7 @@ static struct {
static int atkmods[3][MAX_WEAPON_TYPE]; //ATK weapon modification for size (size_fix.txt)
static char job_bonus[CLASS_COUNT][MAX_LEVEL];
+static sc_conf_type sc_conf[SC_MAX];
static struct eri *sc_data_ers; //For sc_data entries
static struct status_data dummy_status;
@@ -189,7 +190,7 @@ void initChangeTables(void) {
set_sc( NPC_SILENCEATTACK , SC_SILENCE , SI_BLANK , SCB_NONE );
set_sc( NPC_WIDECONFUSE , SC_CONFUSION , SI_BLANK , SCB_NONE );
set_sc( NPC_BLINDATTACK , SC_BLIND , SI_BLANK , SCB_HIT|SCB_FLEE );
- set_sc( NPC_BLEEDING , SC_BLEEDING , SI_BLEEDING , SCB_REGEN );
+ set_sc( NPC_BLEEDING , SC_BLOODING , SI_BLOODING , SCB_REGEN );
set_sc( NPC_POISON , SC_DPOISON , SI_BLANK , SCB_DEF2|SCB_REGEN );
//The main status definitions
@@ -203,12 +204,12 @@ void initChangeTables(void) {
add_sc( MG_STONECURSE , SC_STONE );
add_sc( AL_RUWACH , SC_RUWACH );
add_sc( AL_PNEUMA , SC_PNEUMA );
- set_sc( AL_INCAGI , SC_INCREASEAGI , SI_INCREASEAGI , SCB_AGI|SCB_SPEED );
- set_sc( AL_DECAGI , SC_DECREASEAGI , SI_DECREASEAGI , SCB_AGI|SCB_SPEED );
- set_sc( AL_CRUCIS , SC_SIGNUMCRUCIS , SI_SIGNUMCRUCIS , SCB_DEF );
+ set_sc( AL_INCAGI , SC_INC_AGI , SI_INC_AGI , SCB_AGI|SCB_SPEED );
+ set_sc( AL_DECAGI , SC_DEC_AGI , SI_DEC_AGI , SCB_AGI|SCB_SPEED );
+ set_sc( AL_CRUCIS , SC_CRUCIS , SI_CRUCIS , SCB_DEF );
set_sc( AL_ANGELUS , SC_ANGELUS , SI_ANGELUS , SCB_DEF2 );
set_sc( AL_BLESSING , SC_BLESSING , SI_BLESSING , SCB_STR|SCB_INT|SCB_DEX );
- set_sc( AC_CONCENTRATION , SC_CONCENTRATE , SI_CONCENTRATE , SCB_AGI|SCB_DEX );
+ set_sc( AC_CONCENTRATION , SC_CONCENTRATION , SI_CONCENTRATION , SCB_AGI|SCB_DEX );
set_sc( TF_HIDING , SC_HIDING , SI_HIDING , SCB_SPEED );
add_sc( TF_POISON , SC_POISON );
set_sc( KN_TWOHANDQUICKEN , SC_TWOHANDQUICKEN , SI_TWOHANDQUICKEN , SCB_ASPD );
@@ -222,44 +223,44 @@ void initChangeTables(void) {
set_sc( PR_MAGNIFICAT , SC_MAGNIFICAT , SI_MAGNIFICAT , SCB_REGEN );
set_sc( PR_GLORIA , SC_GLORIA , SI_GLORIA , SCB_LUK );
add_sc( PR_LEXDIVINA , SC_SILENCE );
- set_sc( PR_LEXAETERNA , SC_AETERNA , SI_AETERNA , SCB_NONE );
+ set_sc( PR_LEXAETERNA , SC_LEXAETERNA , SI_LEXAETERNA , SCB_NONE );
add_sc( WZ_METEOR , SC_STUN );
add_sc( WZ_VERMILION , SC_BLIND );
add_sc( WZ_FROSTNOVA , SC_FREEZE );
add_sc( WZ_STORMGUST , SC_FREEZE );
- set_sc( WZ_QUAGMIRE , SC_QUAGMIRE , SI_QUAGMIRE , SCB_AGI|SCB_DEX|SCB_ASPD|SCB_SPEED );
- set_sc( BS_ADRENALINE , SC_ADRENALINE , SI_ADRENALINE , SCB_ASPD );
- set_sc( BS_WEAPONPERFECT , SC_WEAPONPERFECTION, SI_WEAPONPERFECTION, SCB_NONE );
- set_sc( BS_OVERTHRUST , SC_OVERTHRUST , SI_OVERTHRUST , SCB_NONE );
- set_sc( BS_MAXIMIZE , SC_MAXIMIZEPOWER , SI_MAXIMIZEPOWER , SCB_REGEN );
- add_sc( HT_LANDMINE , SC_STUN );
- add_sc( HT_ANKLESNARE , SC_ANKLE );
+ set_sc( WZ_QUAGMIRE , SC_QUAGMIRE , SI_QUAGMIRE , SCB_AGI|SCB_DEX|SCB_ASPD|SCB_SPEED );
+ set_sc( BS_ADRENALINE , SC_ADRENALINE , SI_ADRENALINE , SCB_ASPD );
+ set_sc( BS_WEAPONPERFECT , SC_WEAPONPERFECT , SI_WEAPONPERFECT, SCB_NONE );
+ set_sc( BS_OVERTHRUST , SC_OVERTHRUST , SI_OVERTHRUST , SCB_NONE );
+ set_sc( BS_MAXIMIZE , SC_MAXIMIZEPOWER , SI_MAXIMIZE , SCB_REGEN );
+ add_sc( HT_LANDMINE , SC_STUN );
+ set_sc( HT_ANKLESNARE , SC_ANKLESNARE , SI_ANKLESNARE , SCB_NONE );
add_sc( HT_SANDMAN , SC_SLEEP );
add_sc( HT_FLASHER , SC_BLIND );
add_sc( HT_FREEZINGTRAP , SC_FREEZE );
- set_sc( AS_CLOAKING , SC_CLOAKING , SI_CLOAKING , SCB_CRI|SCB_SPEED );
+ set_sc( AS_CLOAKING , SC_CLOAKING , SI_CLOAKING , SCB_CRI|SCB_SPEED );
add_sc( AS_SONICBLOW , SC_STUN );
- set_sc( AS_ENCHANTPOISON , SC_ENCPOISON , SI_ENCPOISON , SCB_ATK_ELE );
- set_sc( AS_POISONREACT , SC_POISONREACT , SI_POISONREACT , SCB_NONE );
+ set_sc( AS_ENCHANTPOISON , SC_ENCHANTPOISON , SI_ENCHANTPOISON, SCB_ATK_ELE );
+ set_sc( AS_POISONREACT , SC_POISONREACT , SI_POISONREACT , SCB_NONE );
add_sc( AS_VENOMDUST , SC_POISON );
add_sc( AS_SPLASHER , SC_SPLASHER );
- set_sc( NV_TRICKDEAD , SC_TRICKDEAD , SI_TRICKDEAD , SCB_REGEN );
- set_sc( SM_AUTOBERSERK , SC_AUTOBERSERK , SI_AUTOBERSERK , SCB_NONE );
+ set_sc( NV_TRICKDEAD , SC_TRICKDEAD , SI_TRICKDEAD , SCB_REGEN );
+ set_sc( SM_AUTOBERSERK , SC_AUTOBERSERK , SI_AUTOBERSERK , SCB_NONE );
add_sc( TF_SPRINKLESAND , SC_BLIND );
add_sc( TF_THROWSTONE , SC_STUN );
- set_sc( MC_LOUD , SC_LOUD , SI_LOUD , SCB_STR );
- set_sc( MG_ENERGYCOAT , SC_ENERGYCOAT , SI_ENERGYCOAT , SCB_NONE );
- set_sc( NPC_EMOTION , SC_MODECHANGE , SI_BLANK , SCB_MODE );
- add_sc( NPC_EMOTION_ON , SC_MODECHANGE );
- set_sc( NPC_ATTRICHANGE , SC_ELEMENTALCHANGE , SI_ARMOR_PROPERTY , SCB_DEF_ELE );
- add_sc( NPC_CHANGEWATER , SC_ELEMENTALCHANGE );
- add_sc( NPC_CHANGEGROUND , SC_ELEMENTALCHANGE );
- add_sc( NPC_CHANGEFIRE , SC_ELEMENTALCHANGE );
- add_sc( NPC_CHANGEWIND , SC_ELEMENTALCHANGE );
- add_sc( NPC_CHANGEPOISON , SC_ELEMENTALCHANGE );
- add_sc( NPC_CHANGEHOLY , SC_ELEMENTALCHANGE );
- add_sc( NPC_CHANGEDARKNESS , SC_ELEMENTALCHANGE );
- add_sc( NPC_CHANGETELEKINESIS, SC_ELEMENTALCHANGE );
+ set_sc( MC_LOUD , SC_SHOUT , SI_SHOUT , SCB_STR );
+ set_sc( MG_ENERGYCOAT , SC_ENERGYCOAT , SI_ENERGYCOAT , SCB_NONE );
+ set_sc( NPC_EMOTION , SC_MODECHANGE , SI_BLANK , SCB_MODE );
+ add_sc( NPC_EMOTION_ON , SC_MODECHANGE );
+ set_sc( NPC_ATTRICHANGE , SC_ARMOR_PROPERTY , SI_ARMOR_PROPERTY , SCB_DEF_ELE );
+ add_sc( NPC_CHANGEWATER , SC_ARMOR_PROPERTY );
+ add_sc( NPC_CHANGEGROUND , SC_ARMOR_PROPERTY );
+ add_sc( NPC_CHANGEFIRE , SC_ARMOR_PROPERTY );
+ add_sc( NPC_CHANGEWIND , SC_ARMOR_PROPERTY );
+ add_sc( NPC_CHANGEPOISON , SC_ARMOR_PROPERTY );
+ add_sc( NPC_CHANGEHOLY , SC_ARMOR_PROPERTY );
+ add_sc( NPC_CHANGEDARKNESS , SC_ARMOR_PROPERTY );
+ add_sc( NPC_CHANGETELEKINESIS, SC_ARMOR_PROPERTY );
add_sc( NPC_POISON , SC_POISON );
add_sc( NPC_BLINDATTACK , SC_BLIND );
add_sc( NPC_SILENCEATTACK , SC_SILENCE );
@@ -273,25 +274,25 @@ void initChangeTables(void) {
set_sc( NPC_BARRIER , SC_BARRIER , SI_BLANK , SCB_MDEF|SCB_DEF );
add_sc( NPC_DEFENDER , SC_ARMOR );
add_sc( NPC_LICK , SC_STUN );
- set_sc( NPC_HALLUCINATION , SC_HALLUCINATION , SI_HALLUCINATION , SCB_NONE );
+ set_sc( NPC_HALLUCINATION , SC_ILLUSION , SI_ILLUSION , SCB_NONE );
add_sc( NPC_REBIRTH , SC_REBIRTH );
add_sc( RG_RAID , SC_STUN );
#ifdef RENEWAL
add_sc( RG_RAID , SC_RAID );
add_sc( RG_BACKSTAP , SC_STUN );
#endif
- set_sc( RG_STRIPWEAPON , SC_STRIPWEAPON , SI_STRIPWEAPON , SCB_WATK );
- set_sc( RG_STRIPSHIELD , SC_STRIPSHIELD , SI_STRIPSHIELD , SCB_DEF );
- set_sc( RG_STRIPARMOR , SC_STRIPARMOR , SI_STRIPARMOR , SCB_VIT );
- set_sc( RG_STRIPHELM , SC_STRIPHELM , SI_STRIPHELM , SCB_INT );
- add_sc( AM_ACIDTERROR , SC_BLEEDING );
- set_sc( AM_CP_WEAPON , SC_CP_WEAPON , SI_CP_WEAPON , SCB_NONE );
- set_sc( AM_CP_SHIELD , SC_CP_SHIELD , SI_CP_SHIELD , SCB_NONE );
- set_sc( AM_CP_ARMOR , SC_CP_ARMOR , SI_CP_ARMOR , SCB_NONE );
- set_sc( AM_CP_HELM , SC_CP_HELM , SI_CP_HELM , SCB_NONE );
- set_sc( CR_AUTOGUARD , SC_AUTOGUARD , SI_AUTOGUARD , SCB_NONE );
+ set_sc( RG_STRIPWEAPON , SC_NOEQUIPWEAPON , SI_NOEQUIPWEAPON , SCB_WATK );
+ set_sc( RG_STRIPSHIELD , SC_NOEQUIPSHIELD , SI_NOEQUIPSHIELD , SCB_DEF );
+ set_sc( RG_STRIPARMOR , SC_NOEQUIPARMOR , SI_NOEQUIPARMOR , SCB_VIT );
+ set_sc( RG_STRIPHELM , SC_NOEQUIPHELM , SI_NOEQUIPHELM , SCB_INT );
+ add_sc( AM_ACIDTERROR , SC_BLOODING );
+ set_sc( AM_CP_WEAPON , SC_PROTECTWEAPON , SI_PROTECTWEAPON , SCB_NONE );
+ set_sc( AM_CP_SHIELD , SC_PROTECTSHIELD , SI_PROTECTSHIELD , SCB_NONE );
+ set_sc( AM_CP_ARMOR , SC_PROTECTARMOR , SI_PROTECTARMOR , SCB_NONE );
+ set_sc( AM_CP_HELM , SC_PROTECTHELM , SI_PROTECTHELM , SCB_NONE );
+ set_sc( CR_AUTOGUARD , SC_AUTOGUARD , SI_AUTOGUARD , SCB_NONE );
add_sc( CR_SHIELDCHARGE , SC_STUN );
- set_sc( CR_REFLECTSHIELD , SC_REFLECTSHIELD , SI_REFLECTSHIELD , SCB_NONE );
+ set_sc( CR_REFLECTSHIELD , SC_REFLECTSHIELD , SI_REFLECTSHIELD , SCB_NONE );
add_sc( CR_HOLYCROSS , SC_BLIND );
add_sc( CR_GRANDCROSS , SC_BLIND );
add_sc( CR_DEVOTION , SC_DEVOTION );
@@ -304,17 +305,17 @@ void initChangeTables(void) {
set_sc( MO_EXPLOSIONSPIRITS , SC_EXPLOSIONSPIRITS, SI_EXPLOSIONSPIRITS, SCB_CRI|SCB_REGEN );
set_sc( MO_EXTREMITYFIST , SC_EXTREMITYFIST , SI_BLANK , SCB_REGEN );
#ifdef RENEWAL
- set_sc( MO_EXTREMITYFIST , SC_EXTREMITYFIST2 , SI_EXTREMITYFIST , SCB_NONE );
+ set_sc( MO_EXTREMITYFIST , SC_EXTREMITYFIST2 , SI_EXTREMITYFIST , SCB_NONE );
#endif
add_sc( SA_MAGICROD , SC_MAGICROD );
set_sc( SA_AUTOSPELL , SC_AUTOSPELL , SI_AUTOSPELL , SCB_NONE );
- set_sc( SA_FLAMELAUNCHER , SC_FIREWEAPON , SI_FIREWEAPON , SCB_ATK_ELE );
- set_sc( SA_FROSTWEAPON , SC_WATERWEAPON , SI_WATERWEAPON , SCB_ATK_ELE );
- set_sc( SA_LIGHTNINGLOADER , SC_WINDWEAPON , SI_WINDWEAPON , SCB_ATK_ELE );
- set_sc( SA_SEISMICWEAPON , SC_EARTHWEAPON , SI_EARTHWEAPON , SCB_ATK_ELE );
- set_sc( SA_VOLCANO , SC_VOLCANO , SI_LANDENDOW , SCB_WATK );
- set_sc( SA_DELUGE , SC_DELUGE , SI_LANDENDOW , SCB_MAXHP );
- set_sc( SA_VIOLENTGALE , SC_VIOLENTGALE , SI_LANDENDOW , SCB_FLEE );
+ set_sc( SA_FLAMELAUNCHER , SC_PROPERTYFIRE , SI_PROPERTYFIRE , SCB_ATK_ELE );
+ set_sc( SA_FROSTWEAPON , SC_PROPERTYWATER , SI_PROPERTYWATER , SCB_ATK_ELE );
+ set_sc( SA_LIGHTNINGLOADER , SC_PROPERTYWIND , SI_PROPERTYWIND , SCB_ATK_ELE );
+ set_sc( SA_SEISMICWEAPON , SC_PROPERTYGROUND , SI_PROPERTYGROUND , SCB_ATK_ELE );
+ set_sc( SA_VOLCANO , SC_VOLCANO , SI_GROUNDMAGIC , SCB_WATK );
+ set_sc( SA_DELUGE , SC_DELUGE , SI_GROUNDMAGIC , SCB_MAXHP );
+ set_sc( SA_VIOLENTGALE , SC_VIOLENTGALE , SI_GROUNDMAGIC , SCB_FLEE );
add_sc( SA_REVERSEORCISH , SC_ORCISH );
add_sc( SA_COMA , SC_COMA );
set_sc( BD_ENCORE , SC_DANCING , SI_BLANK , SCB_SPEED|SCB_REGEN );
@@ -334,19 +335,23 @@ void initChangeTables(void) {
set_sc( DC_HUMMING , SC_HUMMING , SI_BLANK , SCB_HIT );
set_sc( DC_DONTFORGETME , SC_DONTFORGETME , SI_BLANK , SCB_SPEED|SCB_ASPD );
set_sc( DC_FORTUNEKISS , SC_FORTUNE , SI_BLANK , SCB_CRI );
- set_sc( DC_SERVICEFORYOU , SC_SERVICE4U , SI_BLANK , SCB_ALL );
+ set_sc( DC_SERVICEFORYOU , SC_SERVICEFORYOU , SI_BLANK , SCB_ALL );
add_sc( NPC_DARKCROSS , SC_BLIND );
add_sc( NPC_GRANDDARKNESS , SC_BLIND );
set_sc( NPC_STOP , SC_STOP , SI_STOP , SCB_NONE );
set_sc( NPC_WEAPONBRAKER , SC_BROKENWEAPON , SI_BROKENWEAPON , SCB_NONE );
set_sc( NPC_ARMORBRAKE , SC_BROKENARMOR , SI_BROKENARMOR , SCB_NONE );
- set_sc( NPC_CHANGEUNDEAD , SC_CHANGEUNDEAD , SI_UNDEAD , SCB_DEF_ELE );
+ set_sc( NPC_CHANGEUNDEAD , SC_PROPERTYUNDEAD , SI_PROPERTYUNDEAD , SCB_DEF_ELE );
set_sc( NPC_POWERUP , SC_INCHITRATE , SI_BLANK , SCB_HIT );
set_sc( NPC_AGIUP , SC_INCFLEERATE , SI_BLANK , SCB_FLEE );
add_sc( NPC_INVISIBLE , SC_CLOAKING );
set_sc( LK_AURABLADE , SC_AURABLADE , SI_AURABLADE , SCB_NONE );
set_sc( LK_PARRYING , SC_PARRYING , SI_PARRYING , SCB_NONE );
- set_sc( LK_CONCENTRATION , SC_CONCENTRATION , SI_CONCENTRATION , SCB_BATK|SCB_WATK|SCB_HIT|SCB_DEF|SCB_DEF2|SCB_MDEF|SCB_DSPD );
+#ifndef RENEWAL
+ set_sc( LK_CONCENTRATION , SC_LKCONCENTRATION , SI_CONCENTRATION , SCB_BATK|SCB_WATK|SCB_HIT|SCB_DEF|SCB_DEF2);
+#else
+ set_sc( LK_CONCENTRATION , SC_LKCONCENTRATION , SI_CONCENTRATION , SCB_HIT|SCB_DEF);
+#endif
set_sc( LK_TENSIONRELAX , SC_TENSIONRELAX , SI_TENSIONRELAX , SCB_REGEN );
set_sc( LK_BERSERK , SC_BERSERK , SI_BERSERK , SCB_DEF|SCB_DEF2|SCB_MDEF|SCB_MDEF2|SCB_FLEE|SCB_SPEED|SCB_ASPD|SCB_MAXHP|SCB_REGEN );
set_sc( HP_ASSUMPTIO , SC_ASSUMPTIO , SI_ASSUMPTIO , SCB_NONE );
@@ -362,32 +367,32 @@ void initChangeTables(void) {
set_sc( WS_MELTDOWN , SC_MELTDOWN , SI_MELTDOWN , SCB_NONE );
set_sc( WS_CARTBOOST , SC_CARTBOOST , SI_CARTBOOST , SCB_SPEED );
set_sc( ST_CHASEWALK , SC_CHASEWALK , SI_BLANK , SCB_SPEED );
- set_sc( ST_REJECTSWORD , SC_REJECTSWORD , SI_REJECTSWORD , SCB_NONE );
+ set_sc( ST_REJECTSWORD , SC_SWORDREJECT , SI_SWORDREJECT , SCB_NONE );
add_sc( ST_REJECTSWORD , SC_AUTOCOUNTER );
- set_sc( CG_MARIONETTE , SC_MARIONETTE , SI_MARIONETTE , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK );
- set_sc( CG_MARIONETTE , SC_MARIONETTE2 , SI_MARIONETTE2 , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK );
+ set_sc( CG_MARIONETTE , SC_MARIONETTE_MASTER , SI_MARIONETTE_MASTER , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK );
+ set_sc( CG_MARIONETTE , SC_MARIONETTE , SI_MARIONETTE , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK );
add_sc( LK_SPIRALPIERCE , SC_STOP );
- add_sc( LK_HEADCRUSH , SC_BLEEDING );
+ add_sc( LK_HEADCRUSH , SC_BLOODING );
set_sc( LK_JOINTBEAT , SC_JOINTBEAT , SI_JOINTBEAT , SCB_BATK|SCB_DEF2|SCB_SPEED|SCB_ASPD );
add_sc( HW_NAPALMVULCAN , SC_CURSE );
set_sc( PF_MINDBREAKER , SC_MINDBREAKER , SI_BLANK , SCB_MATK|SCB_MDEF2 );
add_sc( PF_MEMORIZE , SC_MEMORIZE );
add_sc( PF_FOGWALL , SC_FOGWALL );
set_sc( PF_SPIDERWEB , SC_SPIDERWEB , SI_BLANK , SCB_FLEE );
- set_sc( WE_BABY , SC_BABY , SI_BABY , SCB_NONE );
+ set_sc( WE_BABY , SC_BABY , SI_PROTECTEXP , SCB_NONE );
set_sc( TK_RUN , SC_RUN , SI_RUN , SCB_SPEED|SCB_DSPD );
- set_sc( TK_RUN , SC_SPURT , SI_SPURT , SCB_STR );
- set_sc( TK_READYSTORM , SC_READYSTORM , SI_READYSTORM , SCB_NONE );
- set_sc( TK_READYDOWN , SC_READYDOWN , SI_READYDOWN , SCB_NONE );
+ set_sc( TK_RUN , SC_STRUP , SI_STRUP , SCB_STR );
+ set_sc( TK_READYSTORM , SC_STORMKICK_READY , SI_STORMKICK_ON , SCB_NONE );
+ set_sc( TK_READYDOWN , SC_DOWNKICK_READY , SI_DOWNKICK_ON , SCB_NONE );
add_sc( TK_DOWNKICK , SC_STUN );
- set_sc( TK_READYTURN , SC_READYTURN , SI_READYTURN , SCB_NONE );
- set_sc( TK_READYCOUNTER , SC_READYCOUNTER , SI_READYCOUNTER , SCB_NONE );
- set_sc( TK_DODGE , SC_DODGE , SI_DODGE , SCB_NONE );
+ set_sc( TK_READYTURN , SC_TURNKICK_READY , SI_TURNKICK_ON , SCB_NONE );
+ set_sc( TK_READYCOUNTER , SC_COUNTERKICK_READY , SI_COUNTER_ON , SCB_NONE );
+ set_sc( TK_DODGE , SC_DODGE_READY , SI_DODGE_ON , SCB_NONE );
set_sc( TK_SPTIME , SC_EARTHSCROLL , SI_EARTHSCROLL , SCB_NONE );
- add_sc( TK_SEVENWIND , SC_SEVENWIND );
- set_sc( TK_SEVENWIND , SC_GHOSTWEAPON , SI_GHOSTWEAPON , SCB_ATK_ELE );
- set_sc( TK_SEVENWIND , SC_SHADOWWEAPON , SI_SHADOWWEAPON , SCB_ATK_ELE );
- set_sc( SG_SUN_WARM , SC_WARM , SI_WARM , SCB_NONE );
+ add_sc( TK_SEVENWIND , SC_TK_SEVENWIND );
+ set_sc( TK_SEVENWIND , SC_PROPERTYTELEKINESIS , SI_PROPERTYTELEKINESIS , SCB_ATK_ELE );
+ set_sc( TK_SEVENWIND , SC_PROPERTYDARK , SI_PROPERTYDARK , SCB_ATK_ELE );
+ set_sc( SG_SUN_WARM , SC_WARM , SI_SG_SUN_WARM , SCB_NONE );
add_sc( SG_MOON_WARM , SC_WARM );
add_sc( SG_STAR_WARM , SC_WARM );
set_sc( SG_SUN_COMFORT , SC_SUN_COMFORT , SI_SUN_COMFORT , SCB_DEF2 );
@@ -405,39 +410,40 @@ void initChangeTables(void) {
set_sc( SL_SWOO , SC_SWOO , SI_BLANK , SCB_SPEED );
set_sc( SL_SKE , SC_SKE , SI_BLANK , SCB_BATK|SCB_WATK|SCB_DEF|SCB_DEF2 );
set_sc( SL_SKA , SC_SKA , SI_BLANK , SCB_DEF|SCB_MDEF|SCB_ASPD );
- set_sc( SL_SMA , SC_SMA , SI_SMA , SCB_NONE );
+ set_sc( SL_SMA , SC_SMA_READY , SI_SMA_READY , SCB_NONE );
set_sc( SM_SELFPROVOKE , SC_PROVOKE , SI_PROVOKE , SCB_DEF|SCB_DEF2|SCB_BATK|SCB_WATK );
set_sc( ST_PRESERVE , SC_PRESERVE , SI_PRESERVE , SCB_NONE );
- set_sc( PF_DOUBLECASTING , SC_DOUBLECAST , SI_DOUBLECAST , SCB_NONE );
+ set_sc( PF_DOUBLECASTING , SC_DOUBLECASTING , SI_DOUBLECASTING , SCB_NONE );
set_sc( HW_GRAVITATION , SC_GRAVITATION , SI_BLANK , SCB_ASPD );
add_sc( WS_CARTTERMINATION , SC_STUN );
- set_sc( WS_OVERTHRUSTMAX , SC_MAXOVERTHRUST , SI_MAXOVERTHRUST , SCB_NONE );
+ set_sc( WS_OVERTHRUSTMAX , SC_OVERTHRUSTMAX , SI_OVERTHRUSTMAX , SCB_NONE );
set_sc( CG_LONGINGFREEDOM , SC_LONGING , SI_BLANK , SCB_SPEED|SCB_ASPD );
add_sc( CG_HERMODE , SC_HERMODE );
+ set_sc( CG_TAROTCARD , SC_TAROTCARD , SI_TAROTCARD , SCB_NONE );
set_sc( ITEM_ENCHANTARMS , SC_ENCHANTARMS , SI_BLANK , SCB_ATK_ELE );
- set_sc( SL_HIGH , SC_SPIRIT , SI_SPIRIT , SCB_ALL );
- set_sc( KN_ONEHAND , SC_ONEHAND , SI_ONEHAND , SCB_ASPD );
+ set_sc( SL_HIGH , SC_SOULLINK , SI_SOULLINK , SCB_ALL );
+ set_sc( KN_ONEHAND , SC_ONEHANDQUICKEN , SI_ONEHANDQUICKEN , SCB_ASPD );
set_sc( GS_FLING , SC_FLING , SI_BLANK , SCB_DEF|SCB_DEF2 );
add_sc( GS_CRACKER , SC_STUN );
- add_sc( GS_DISARM , SC_STRIPWEAPON );
- add_sc( GS_PIERCINGSHOT , SC_BLEEDING );
- set_sc( GS_MADNESSCANCEL , SC_MADNESSCANCEL , SI_MADNESSCANCEL , SCB_BATK|SCB_ASPD );
- set_sc( GS_ADJUSTMENT , SC_ADJUSTMENT , SI_ADJUSTMENT , SCB_HIT|SCB_FLEE );
- set_sc( GS_INCREASING , SC_INCREASING , SI_ACCURACY , SCB_AGI|SCB_DEX|SCB_HIT );
- set_sc( GS_GATLINGFEVER , SC_GATLINGFEVER , SI_GATLINGFEVER , SCB_BATK|SCB_FLEE|SCB_SPEED|SCB_ASPD );
- set_sc( NJ_TATAMIGAESHI , SC_TATAMIGAESHI , SI_BLANK , SCB_NONE );
- set_sc( NJ_SUITON , SC_SUITON , SI_BLANK , SCB_AGI|SCB_SPEED );
+ add_sc( GS_DISARM , SC_NOEQUIPWEAPON );
+ add_sc( GS_PIERCINGSHOT , SC_BLOODING );
+ set_sc( GS_MADNESSCANCEL , SC_GS_MADNESSCANCEL , SI_GS_MADNESSCANCEL , SCB_BATK|SCB_ASPD );
+ set_sc( GS_ADJUSTMENT , SC_GS_ADJUSTMENT , SI_GS_ADJUSTMENT , SCB_HIT|SCB_FLEE );
+ set_sc( GS_INCREASING , SC_GS_ACCURACY , SI_GS_ACCURACY , SCB_AGI|SCB_DEX|SCB_HIT );
+ set_sc( GS_GATLINGFEVER , SC_GS_GATLINGFEVER , SI_GS_GATLINGFEVER , SCB_BATK|SCB_FLEE|SCB_SPEED|SCB_ASPD );
+ set_sc( NJ_TATAMIGAESHI , SC_NJ_TATAMIGAESHI , SI_BLANK , SCB_NONE );
+ set_sc( NJ_SUITON , SC_NJ_SUITON , SI_NJ_SUITON , SCB_AGI|SCB_SPEED );
add_sc( NJ_HYOUSYOURAKU , SC_FREEZE );
- set_sc( NJ_NEN , SC_NEN , SI_NEN , SCB_STR|SCB_INT );
- set_sc( NJ_UTSUSEMI , SC_UTSUSEMI , SI_UTSUSEMI , SCB_NONE );
- set_sc( NJ_BUNSINJYUTSU , SC_BUNSINJYUTSU , SI_BUNSINJYUTSU , SCB_DYE );
+ set_sc( NJ_NEN , SC_NJ_NEN , SI_NJ_NEN , SCB_STR|SCB_INT );
+ set_sc( NJ_UTSUSEMI , SC_NJ_UTSUSEMI , SI_NJ_UTSUSEMI , SCB_NONE );
+ set_sc( NJ_BUNSINJYUTSU , SC_NJ_BUNSINJYUTSU , SI_NJ_BUNSINJYUTSU , SCB_DYE );
add_sc( NPC_ICEBREATH , SC_FREEZE );
add_sc( NPC_ACIDBREATH , SC_POISON );
add_sc( NPC_HELLJUDGEMENT , SC_CURSE );
add_sc( NPC_WIDESILENCE , SC_SILENCE );
add_sc( NPC_WIDEFREEZE , SC_FREEZE );
- add_sc( NPC_WIDEBLEEDING , SC_BLEEDING );
+ add_sc( NPC_WIDEBLEEDING , SC_BLOODING );
add_sc( NPC_WIDESTONE , SC_STONE );
add_sc( NPC_WIDECONFUSE , SC_CONFUSION );
add_sc( NPC_WIDESLEEP , SC_SLEEP );
@@ -446,8 +452,8 @@ void initChangeTables(void) {
add_sc( NPC_MAGICMIRROR , SC_MAGICMIRROR );
set_sc( NPC_SLOWCAST , SC_SLOWCAST , SI_SLOWCAST , SCB_NONE );
set_sc( NPC_CRITICALWOUND , SC_CRITICALWOUND , SI_CRITICALWOUND , SCB_NONE );
- set_sc( NPC_STONESKIN , SC_ARMORCHANGE , SI_BLANK , SCB_DEF|SCB_MDEF );
- add_sc( NPC_ANTIMAGIC , SC_ARMORCHANGE );
+ set_sc( NPC_STONESKIN , SC_STONESKIN , SI_BLANK , SCB_DEF|SCB_MDEF );
+ add_sc( NPC_ANTIMAGIC , SC_STONESKIN );
add_sc( NPC_WIDECURSE , SC_CURSE );
add_sc( NPC_WIDESTUN , SC_STUN );
@@ -457,29 +463,29 @@ void initChangeTables(void) {
set_sc( NPC_INVINCIBLEOFF , SC_INVINCIBLEOFF , SI_BLANK , SCB_SPEED );
set_sc( CASH_BLESSING , SC_BLESSING , SI_BLESSING , SCB_STR|SCB_INT|SCB_DEX );
- set_sc( CASH_INCAGI , SC_INCREASEAGI , SI_INCREASEAGI , SCB_AGI|SCB_SPEED );
+ set_sc( CASH_INCAGI , SC_INC_AGI , SI_INC_AGI , SCB_AGI|SCB_SPEED );
set_sc( CASH_ASSUMPTIO , SC_ASSUMPTIO , SI_ASSUMPTIO , SCB_NONE );
set_sc( ALL_PARTYFLEE , SC_PARTYFLEE , SI_PARTYFLEE , SCB_NONE );
set_sc( ALL_ODINS_POWER , SC_ODINS_POWER , SI_ODINS_POWER , SCB_MATK|SCB_BATK|SCB_MDEF|SCB_DEF );
- set_sc( CR_SHRINK , SC_SHRINK , SI_SHRINK , SCB_NONE );
- set_sc( RG_CLOSECONFINE , SC_CLOSECONFINE2 , SI_CLOSECONFINE2 , SCB_NONE );
- set_sc( RG_CLOSECONFINE , SC_CLOSECONFINE , SI_CLOSECONFINE , SCB_FLEE );
- set_sc( WZ_SIGHTBLASTER , SC_SIGHTBLASTER , SI_SIGHTBLASTER , SCB_NONE );
- set_sc( DC_WINKCHARM , SC_WINKCHARM , SI_WINKCHARM , SCB_NONE );
+ set_sc( CR_SHRINK , SC_CR_SHRINK , SI_CR_SHRINK , SCB_NONE );
+ set_sc( RG_CLOSECONFINE , SC_RG_CCONFINE_S , SI_RG_CCONFINE_S , SCB_NONE );
+ set_sc( RG_CLOSECONFINE , SC_RG_CCONFINE_M , SI_RG_CCONFINE_M , SCB_FLEE );
+ set_sc( WZ_SIGHTBLASTER , SC_WZ_SIGHTBLASTER , SI_WZ_SIGHTBLASTER , SCB_NONE );
+ set_sc( DC_WINKCHARM , SC_DC_WINKCHARM , SI_DC_WINKCHARM , SCB_NONE );
add_sc( MO_BALKYOUNG , SC_STUN );
- add_sc( SA_ELEMENTWATER , SC_ELEMENTALCHANGE );
- add_sc( SA_ELEMENTFIRE , SC_ELEMENTALCHANGE );
- add_sc( SA_ELEMENTGROUND , SC_ELEMENTALCHANGE );
- add_sc( SA_ELEMENTWIND , SC_ELEMENTALCHANGE );
-
- set_sc( HLIF_AVOID , SC_AVOID , SI_BLANK , SCB_SPEED );
- set_sc( HLIF_CHANGE , SC_CHANGE , SI_BLANK , SCB_VIT|SCB_INT );
- set_sc( HFLI_FLEET , SC_FLEET , SI_BLANK , SCB_ASPD|SCB_BATK|SCB_WATK );
- set_sc( HFLI_SPEED , SC_SPEED , SI_BLANK , SCB_FLEE );
- set_sc( HAMI_DEFENCE , SC_DEFENCE , SI_BLANK , SCB_DEF );
- set_sc( HAMI_BLOODLUST , SC_BLOODLUST , SI_BLANK , SCB_BATK|SCB_WATK );
+ add_sc( SA_ELEMENTWATER , SC_ARMOR_PROPERTY );
+ add_sc( SA_ELEMENTFIRE , SC_ARMOR_PROPERTY );
+ add_sc( SA_ELEMENTGROUND , SC_ARMOR_PROPERTY );
+ add_sc( SA_ELEMENTWIND , SC_ARMOR_PROPERTY );
+
+ set_sc( HLIF_AVOID , SC_HLIF_AVOID , SI_BLANK , SCB_SPEED );
+ set_sc( HLIF_CHANGE , SC_HLIF_CHANGE , SI_BLANK , SCB_VIT|SCB_INT );
+ set_sc( HFLI_FLEET , SC_HLIF_FLEET , SI_BLANK , SCB_ASPD|SCB_BATK|SCB_WATK );
+ set_sc( HFLI_SPEED , SC_HLIF_SPEED , SI_BLANK , SCB_FLEE );
+ set_sc( HAMI_DEFENCE , SC_HAMI_DEFENCE , SI_BLANK , SCB_DEF );
+ set_sc( HAMI_BLOODLUST , SC_HAMI_BLOODLUST , SI_BLANK , SCB_BATK|SCB_WATK );
// Homunculus S
add_sc(MH_STAHL_HORN, SC_STUN);
@@ -489,25 +495,25 @@ void initChangeTables(void) {
add_sc(MH_ERASER_CUTTER, SC_ERASER_CUTTER);
set_sc(MH_OVERED_BOOST, SC_OVERED_BOOST, SI_BLANK, SCB_FLEE|SCB_ASPD);
add_sc(MH_LIGHT_OF_REGENE, SC_LIGHT_OF_REGENE);
- set_sc(MH_VOLCANIC_ASH, SC_ASH, SI_VOLCANIC_ASH, SCB_DEF|SCB_DEF2|SCB_HIT|SCB_BATK|SCB_FLEE);
+ set_sc(MH_VOLCANIC_ASH, SC_VOLCANIC_ASH, SI_VOLCANIC_ASH, SCB_DEF|SCB_DEF2|SCB_HIT|SCB_BATK|SCB_FLEE);
set_sc(MH_GRANITIC_ARMOR, SC_GRANITIC_ARMOR, SI_GRANITIC_ARMOR, SCB_NONE);
set_sc(MH_MAGMA_FLOW, SC_MAGMA_FLOW, SI_MAGMA_FLOW, SCB_NONE);
set_sc(MH_PYROCLASTIC, SC_PYROCLASTIC, SI_PYROCLASTIC, SCB_BATK|SCB_ATK_ELE);
add_sc(MH_LAVA_SLIDE, SC_BURNING);
- set_sc(MH_NEEDLE_OF_PARALYZE, SC_PARALYSIS, SI_NEEDLE_OF_PARALYZE, SCB_DEF2);
+ set_sc(MH_NEEDLE_OF_PARALYZE, SC_NEEDLE_OF_PARALYZE, SI_NEEDLE_OF_PARALYZE, SCB_DEF2);
add_sc(MH_POISON_MIST, SC_BLIND);
set_sc(MH_PAIN_KILLER, SC_PAIN_KILLER, SI_PAIN_KILLER, SCB_ASPD);
add_sc(MH_STYLE_CHANGE, SC_STYLE_CHANGE);
- set_sc( MH_TINDER_BREAKER , SC_CLOSECONFINE2 , SI_CLOSECONFINE2 , SCB_NONE );
- set_sc( MH_TINDER_BREAKER , SC_CLOSECONFINE , SI_CLOSECONFINE , SCB_FLEE );
+ set_sc( MH_TINDER_BREAKER , SC_RG_CCONFINE_S , SI_RG_CCONFINE_S , SCB_NONE );
+ set_sc( MH_TINDER_BREAKER , SC_RG_CCONFINE_M , SI_RG_CCONFINE_M , SCB_FLEE );
add_sc( MER_CRASH , SC_STUN );
set_sc( MER_PROVOKE , SC_PROVOKE , SI_PROVOKE , SCB_DEF|SCB_DEF2|SCB_BATK|SCB_WATK );
add_sc( MS_MAGNUM , SC_WATK_ELEMENT );
add_sc( MER_SIGHT , SC_SIGHT );
- set_sc( MER_DECAGI , SC_DECREASEAGI , SI_DECREASEAGI , SCB_AGI|SCB_SPEED );
+ set_sc( MER_DECAGI , SC_DEC_AGI , SI_DEC_AGI , SCB_AGI|SCB_SPEED );
set_sc( MER_MAGNIFICAT , SC_MAGNIFICAT , SI_MAGNIFICAT , SCB_REGEN );
add_sc( MER_LEXDIVINA , SC_SILENCE );
add_sc( MA_LANDMINE , SC_STUN );
@@ -520,19 +526,19 @@ void initChangeTables(void) {
set_sc( MS_PARRYING , SC_PARRYING , SI_PARRYING , SCB_NONE );
set_sc( MS_BERSERK , SC_BERSERK , SI_BERSERK , SCB_DEF|SCB_DEF2|SCB_MDEF|SCB_MDEF2|SCB_FLEE|SCB_SPEED|SCB_ASPD|SCB_MAXHP|SCB_REGEN );
add_sc( ML_SPIRALPIERCE , SC_STOP );
- set_sc( MER_QUICKEN , SC_MERC_QUICKEN , SI_BLANK , SCB_ASPD );
+ set_sc( MER_QUICKEN , SC_MER_QUICKEN , SI_BLANK , SCB_ASPD );
add_sc( ML_DEVOTION , SC_DEVOTION );
set_sc( MER_KYRIE , SC_KYRIE , SI_KYRIE , SCB_NONE );
set_sc( MER_BLESSING , SC_BLESSING , SI_BLESSING , SCB_STR|SCB_INT|SCB_DEX );
- set_sc( MER_INCAGI , SC_INCREASEAGI , SI_INCREASEAGI , SCB_AGI|SCB_SPEED );
+ set_sc( MER_INCAGI , SC_INC_AGI , SI_INC_AGI , SCB_AGI|SCB_SPEED );
set_sc( GD_LEADERSHIP , SC_LEADERSHIP , SI_BLANK , SCB_STR );
set_sc( GD_GLORYWOUNDS , SC_GLORYWOUNDS , SI_BLANK , SCB_VIT );
set_sc( GD_SOULCOLD , SC_SOULCOLD , SI_BLANK , SCB_AGI );
set_sc( GD_HAWKEYES , SC_HAWKEYES , SI_BLANK , SCB_DEX );
- set_sc( GD_BATTLEORDER , SC_BATTLEORDERS , SI_BLANK , SCB_STR|SCB_INT|SCB_DEX );
- set_sc( GD_REGENERATION , SC_REGENERATION , SI_BLANK , SCB_REGEN );
+ set_sc( GD_BATTLEORDER , SC_GDSKILL_BATTLEORDER , SI_BLANK , SCB_STR|SCB_INT|SCB_DEX );
+ set_sc( GD_REGENERATION , SC_GDSKILL_REGENERATION , SI_BLANK , SCB_REGEN );
/**
* Rune Knight
@@ -541,15 +547,16 @@ void initChangeTables(void) {
set_sc( RK_DRAGONHOWLING , SC_FEAR , SI_BLANK , SCB_FLEE|SCB_HIT );
set_sc( RK_DEATHBOUND , SC_DEATHBOUND , SI_DEATHBOUND , SCB_NONE );
set_sc( RK_WINDCUTTER , SC_FEAR , SI_BLANK , SCB_FLEE|SCB_HIT );
- add_sc( RK_DRAGONBREATH , SC_BURNING );
- set_sc( RK_MILLENNIUMSHIELD , SC_MILLENNIUMSHIELD , SI_REUSE_MILLENNIUMSHIELD , SCB_NONE );
+ set_sc( RK_DRAGONBREATH , SC_BURNING , SI_BLANK , SCB_MDEF );
+ set_sc( RK_MILLENNIUMSHIELD , SC_MILLENNIUMSHIELD , SI_BLANK , SCB_NONE );
set_sc( RK_REFRESH , SC_REFRESH , SI_REFRESH , SCB_NONE );
set_sc( RK_GIANTGROWTH , SC_GIANTGROWTH , SI_GIANTGROWTH , SCB_STR );
- set_sc( RK_STONEHARDSKIN , SC_STONEHARDSKIN , SI_STONEHARDSKIN , SCB_DEF|SCB_MDEF );
+ set_sc( RK_STONEHARDSKIN , SC_STONEHARDSKIN , SI_STONEHARDSKIN , SCB_NONE );
set_sc( RK_VITALITYACTIVATION, SC_VITALITYACTIVATION, SI_VITALITYACTIVATION, SCB_REGEN );
set_sc( RK_FIGHTINGSPIRIT , SC_FIGHTINGSPIRIT , SI_FIGHTINGSPIRIT , SCB_WATK|SCB_ASPD );
set_sc( RK_ABUNDANCE , SC_ABUNDANCE , SI_ABUNDANCE , SCB_NONE );
set_sc( RK_CRUSHSTRIKE , SC_CRUSHSTRIKE , SI_CRUSHSTRIKE , SCB_NONE );
+ add_sc( RK_DRAGONBREATH_WATER, SC_FROSTMISTY );
/**
* GC Guillotine Cross
**/
@@ -559,12 +566,13 @@ void initChangeTables(void) {
set_sc( GC_CLOAKINGEXCEED , SC_CLOAKINGEXCEED , SI_CLOAKINGEXCEED , SCB_SPEED );
set_sc( GC_HALLUCINATIONWALK , SC_HALLUCINATIONWALK, SI_HALLUCINATIONWALK, SCB_FLEE );
set_sc( GC_ROLLINGCUTTER , SC_ROLLINGCUTTER , SI_ROLLINGCUTTER , SCB_NONE );
+ set_sc_with_vfx( GC_DARKCROW , SC_DARKCROW , SI_DARKCROW , SCB_NONE );
/**
* Arch Bishop
**/
set_sc( AB_ADORAMUS , SC_ADORAMUS , SI_ADORAMUS , SCB_AGI|SCB_SPEED );
add_sc( AB_CLEMENTIA , SC_BLESSING );
- add_sc( AB_CANTO , SC_INCREASEAGI );
+ add_sc( AB_CANTO , SC_INC_AGI );
set_sc( AB_EPICLESIS , SC_EPICLESIS , SI_EPICLESIS , SCB_MAXHP );
add_sc( AB_PRAEFATIO , SC_KYRIE );
set_sc_with_vfx( AB_ORATIO , SC_ORATIO , SI_ORATIO , SCB_NONE );
@@ -574,14 +582,16 @@ void initChangeTables(void) {
set_sc( AB_EXPIATIO , SC_EXPIATIO , SI_EXPIATIO , SCB_ATK_ELE );
set_sc( AB_DUPLELIGHT , SC_DUPLELIGHT , SI_DUPLELIGHT , SCB_NONE );
set_sc( AB_SECRAMENT , SC_SECRAMENT , SI_SECRAMENT , SCB_NONE );
+ set_sc( AB_OFFERTORIUM , SC_OFFERTORIUM , SI_OFFERTORIUM , SCB_NONE );
/**
* Warlock
**/
add_sc( WL_WHITEIMPRISON , SC_WHITEIMPRISON );
- set_sc_with_vfx( WL_FROSTMISTY , SC_FREEZING , SI_FROSTMISTY , SCB_ASPD|SCB_SPEED|SCB_DEF|SCB_DEF2 );
- set_sc( WL_MARSHOFABYSS , SC_MARSHOFABYSS , SI_MARSHOFABYSS , SCB_SPEED|SCB_FLEE|SCB_DEF|SCB_MDEF );
+ set_sc_with_vfx( WL_FROSTMISTY , SC_FROSTMISTY , SI_FROSTMISTY , SCB_ASPD|SCB_SPEED|SCB_DEF );
+ set_sc( WL_MARSHOFABYSS , SC_MARSHOFABYSS , SI_MARSHOFABYSS , SCB_SPEED|SCB_FLEE|SCB_AGI|SCB_DEX );
set_sc(WL_RECOGNIZEDSPELL , SC_RECOGNIZEDSPELL , SI_RECOGNIZEDSPELL , SCB_MATK);
set_sc( WL_STASIS , SC_STASIS , SI_STASIS , SCB_NONE );
+ set_sc( WL_TELEKINESIS_INTENSE, SC_TELEKINESIS_INTENSE , SI_TELEKINESIS_INTENSE , SCB_MATK );
/**
* Ranger
**/
@@ -589,12 +599,13 @@ void initChangeTables(void) {
set_sc( RA_ELECTRICSHOCKER , SC_ELECTRICSHOCKER , SI_ELECTRICSHOCKER , SCB_NONE );
set_sc( RA_WUGDASH , SC_WUGDASH , SI_WUGDASH , SCB_SPEED );
set_sc( RA_CAMOUFLAGE , SC_CAMOUFLAGE , SI_CAMOUFLAGE , SCB_SPEED );
- add_sc( RA_MAGENTATRAP , SC_ELEMENTALCHANGE );
- add_sc( RA_COBALTTRAP , SC_ELEMENTALCHANGE );
- add_sc( RA_MAIZETRAP , SC_ELEMENTALCHANGE );
- add_sc( RA_VERDURETRAP , SC_ELEMENTALCHANGE );
- add_sc( RA_FIRINGTRAP , SC_BURNING );
- set_sc_with_vfx( RA_ICEBOUNDTRAP , SC_FREEZING , SI_FROSTMISTY , SCB_NONE );
+ add_sc( RA_MAGENTATRAP , SC_ARMOR_PROPERTY );
+ add_sc( RA_COBALTTRAP , SC_ARMOR_PROPERTY );
+ add_sc( RA_MAIZETRAP , SC_ARMOR_PROPERTY );
+ add_sc( RA_VERDURETRAP , SC_ARMOR_PROPERTY );
+ add_sc( RA_FIRINGTRAP , SC_BURNING );
+ add_sc( RA_ICEBOUNDTRAP , SC_FROSTMISTY );
+ set_sc( RA_UNLIMIT , SC_UNLIMIT , SI_UNLIMIT , SCB_NONE );
/**
* Mechanic
**/
@@ -609,7 +620,7 @@ void initChangeTables(void) {
/**
* Royal Guard
**/
- set_sc( LG_REFLECTDAMAGE , SC_REFLECTDAMAGE , SI_LG_REFLECTDAMAGE, SCB_NONE );
+ set_sc( LG_REFLECTDAMAGE , SC_LG_REFLECTDAMAGE , SI_LG_REFLECTDAMAGE, SCB_NONE );
set_sc( LG_FORCEOFVANGUARD , SC_FORCEOFVANGUARD , SI_FORCEOFVANGUARD , SCB_MAXHP|SCB_DEF );
set_sc( LG_EXEEDBREAK , SC_EXEEDBREAK , SI_EXEEDBREAK , SCB_NONE );
set_sc( LG_PRESTIGE , SC_PRESTIGE , SI_PRESTIGE , SCB_DEF );
@@ -619,6 +630,7 @@ void initChangeTables(void) {
set_sc( LG_INSPIRATION , SC_INSPIRATION , SI_INSPIRATION , SCB_MAXHP|SCB_WATK|SCB_HIT|SCB_VIT|SCB_AGI|SCB_STR|SCB_DEX|SCB_INT|SCB_LUK);
set_sc( LG_SHIELDSPELL , SC_SHIELDSPELL_DEF , SI_SHIELDSPELL_DEF , SCB_WATK );
set_sc( LG_SHIELDSPELL , SC_SHIELDSPELL_REF , SI_SHIELDSPELL_REF , SCB_DEF );
+ set_sc( LG_KINGS_GRACE , SC_KINGS_GRACE , SI_KINGS_GRACE , SCB_NONE );
/**
* Shadow Chaser
**/
@@ -634,7 +646,7 @@ void initChangeTables(void) {
set_sc( SC_LAZINESS , SC__LAZINESS , SI_LAZINESS , SCB_FLEE );
set_sc( SC_UNLUCKY , SC__UNLUCKY , SI_UNLUCKY , SCB_CRI|SCB_FLEE2 );
set_sc( SC_WEAKNESS , SC__WEAKNESS , SI_WEAKNESS , SCB_FLEE2|SCB_MAXHP );
- set_sc( SC_STRIPACCESSARY , SC__STRIPACCESSORY , SI_STRIPACCESSARY , SCB_DEX|SCB_INT|SCB_LUK );
+ set_sc( SC_STRIPACCESSARY , SC__STRIPACCESSARY , SI_STRIPACCESSARY , SCB_DEX|SCB_INT|SCB_LUK );
set_sc_with_vfx( SC_MANHOLE , SC__MANHOLE , SI_MANHOLE , SCB_NONE );
add_sc( SC_CHAOSPANIC , SC_CONFUSION );
set_sc_with_vfx( SC_BLOODYLUST , SC__BLOODYLUST , SI_BLOODYLUST , SCB_DEF | SCB_DEF2 | SCB_MDEF | SCB_MDEF2 | SCB_FLEE | SCB_SPEED | SCB_ASPD | SCB_MAXHP | SCB_REGEN );
@@ -647,30 +659,32 @@ void initChangeTables(void) {
set_sc_with_vfx( SR_CURSEDCIRCLE , SC_CURSEDCIRCLE_TARGET, SI_CURSEDCIRCLE_TARGET , SCB_NONE );
set_sc( SR_LIGHTNINGWALK , SC_LIGHTNINGWALK , SI_LIGHTNINGWALK , SCB_NONE );
set_sc( SR_RAISINGDRAGON , SC_RAISINGDRAGON , SI_RAISINGDRAGON , SCB_REGEN|SCB_MAXHP|SCB_MAXSP );
- set_sc( SR_GENTLETOUCH_ENERGYGAIN, SC_GT_ENERGYGAIN , SI_GENTLETOUCH_ENERGYGAIN, SCB_NONE );
- set_sc( SR_GENTLETOUCH_CHANGE , SC_GT_CHANGE , SI_GENTLETOUCH_CHANGE , SCB_ASPD|SCB_MDEF|SCB_MAXHP );
- set_sc( SR_GENTLETOUCH_REVITALIZE, SC_GT_REVITALIZE , SI_GENTLETOUCH_REVITALIZE, SCB_MAXHP|SCB_REGEN );
+ set_sc( SR_GENTLETOUCH_ENERGYGAIN, SC_GENTLETOUCH_ENERGYGAIN , SI_GENTLETOUCH_ENERGYGAIN, SCB_NONE );
+ set_sc( SR_GENTLETOUCH_CHANGE , SC_GENTLETOUCH_CHANGE , SI_GENTLETOUCH_CHANGE , SCB_ASPD|SCB_MDEF|SCB_MAXHP );
+ set_sc( SR_GENTLETOUCH_REVITALIZE, SC_GENTLETOUCH_REVITALIZE , SI_GENTLETOUCH_REVITALIZE, SCB_MAXHP|SCB_REGEN );
/**
* Wanderer / Minstrel
**/
- set_sc( WA_SWING_DANCE , SC_SWINGDANCE , SI_SWINGDANCE , SCB_SPEED|SCB_ASPD );
- set_sc( WA_SYMPHONY_OF_LOVER , SC_SYMPHONYOFLOVER , SI_SYMPHONYOFLOVERS , SCB_MDEF );
- set_sc( WA_MOONLIT_SERENADE , SC_MOONLITSERENADE , SI_MOONLITSERENADE , SCB_MATK );
- set_sc( MI_RUSH_WINDMILL , SC_RUSHWINDMILL , SI_RUSHWINDMILL , SCB_BATK );
- set_sc( MI_ECHOSONG , SC_ECHOSONG , SI_ECHOSONG , SCB_DEF2 );
- set_sc( MI_HARMONIZE , SC_HARMONIZE , SI_HARMONIZE , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK );
- set_sc_with_vfx( WM_POEMOFNETHERWORLD , SC_NETHERWORLD , SI_NETHERWORLD , SCB_NONE );
- set_sc_with_vfx( WM_VOICEOFSIREN , SC_VOICEOFSIREN , SI_VOICEOFSIREN , SCB_NONE );
- set_sc_with_vfx( WM_LULLABY_DEEPSLEEP , SC_DEEPSLEEP , SI_DEEPSLEEP , SCB_NONE );
- set_sc( WM_SIRCLEOFNATURE , SC_SIRCLEOFNATURE , SI_SIRCLEOFNATURE , SCB_NONE );
- set_sc( WM_GLOOMYDAY , SC_GLOOMYDAY , SI_GLOOMYDAY , SCB_FLEE|SCB_ASPD );
- set_sc( WM_SONG_OF_MANA , SC_SONGOFMANA , SI_SONGOFMANA , SCB_NONE );
- set_sc( WM_DANCE_WITH_WUG , SC_DANCEWITHWUG , SI_DANCEWITHWUG , SCB_ASPD );
- set_sc( WM_SATURDAY_NIGHT_FEVER , SC_SATURDAYNIGHTFEVER , SI_SATURDAYNIGHTFEVER , SCB_BATK|SCB_DEF|SCB_FLEE|SCB_REGEN );
- set_sc( WM_LERADS_DEW , SC_LERADSDEW , SI_LERADSDEW , SCB_MAXHP );
- set_sc( WM_MELODYOFSINK , SC_MELODYOFSINK , SI_MELODYOFSINK , SCB_BATK|SCB_MATK );
- set_sc( WM_BEYOND_OF_WARCRY , SC_BEYONDOFWARCRY , SI_WARCRYOFBEYOND , SCB_BATK|SCB_MATK );
- set_sc( WM_UNLIMITED_HUMMING_VOICE, SC_UNLIMITEDHUMMINGVOICE, SI_UNLIMITEDHUMMINGVOICE, SCB_NONE );
+ set_sc( WA_SWING_DANCE , SC_SWING , SI_SWINGDANCE , SCB_SPEED|SCB_ASPD );
+ set_sc( WA_SYMPHONY_OF_LOVER , SC_SYMPHONY_LOVE , SI_SYMPHONYOFLOVERS , SCB_MDEF );
+ set_sc( WA_MOONLIT_SERENADE , SC_MOONLIT_SERENADE , SI_MOONLITSERENADE , SCB_MATK );
+ set_sc( MI_RUSH_WINDMILL , SC_RUSH_WINDMILL , SI_RUSHWINDMILL , SCB_BATK );
+ set_sc( MI_ECHOSONG , SC_ECHOSONG , SI_ECHOSONG , SCB_DEF2 );
+ set_sc( MI_HARMONIZE , SC_HARMONIZE , SI_HARMONIZE , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK );
+ set_sc_with_vfx( WM_POEMOFNETHERWORLD , SC_NETHERWORLD , SI_NETHERWORLD , SCB_NONE );
+ set_sc_with_vfx( WM_VOICEOFSIREN , SC_SIREN , SI_SIREN , SCB_NONE );
+ set_sc_with_vfx( WM_LULLABY_DEEPSLEEP , SC_DEEP_SLEEP , SI_DEEPSLEEP , SCB_NONE );
+ set_sc( WM_SIRCLEOFNATURE , SC_SIRCLEOFNATURE , SI_SIRCLEOFNATURE , SCB_NONE );
+ set_sc( WM_GLOOMYDAY , SC_GLOOMYDAY , SI_GLOOMYDAY , SCB_FLEE|SCB_ASPD );
+ set_sc( WM_SONG_OF_MANA , SC_SONG_OF_MANA , SI_SONG_OF_MANA , SCB_NONE );
+ set_sc( WM_DANCE_WITH_WUG , SC_DANCE_WITH_WUG , SI_DANCEWITHWUG , SCB_ASPD );
+ set_sc( WM_SATURDAY_NIGHT_FEVER , SC_SATURDAY_NIGHT_FEVER , SI_SATURDAYNIGHTFEVER , SCB_BATK|SCB_DEF|SCB_FLEE|SCB_REGEN );
+ set_sc( WM_LERADS_DEW , SC_LERADS_DEW , SI_LERADSDEW , SCB_MAXHP );
+ set_sc( WM_MELODYOFSINK , SC_MELODYOFSINK , SI_MELODYOFSINK , SCB_BATK|SCB_MATK );
+ set_sc( WM_BEYOND_OF_WARCRY , SC_BEYOND_OF_WARCRY , SI_WARCRYOFBEYOND , SCB_BATK|SCB_MATK );
+ set_sc( WM_UNLIMITED_HUMMING_VOICE, SC_UNLIMITED_HUMMING_VOICE, SI_UNLIMITEDHUMMINGVOICE, SCB_NONE );
+ set_sc( WM_FRIGG_SONG , SC_FRIGG_SONG , SI_FRIGG_SONG , SCB_MAXHP );
+
/**
* Sorcerer
**/
@@ -682,7 +696,7 @@ void initChangeTables(void) {
set_sc( SO_STRIKING , SC_STRIKING , SI_STRIKING , SCB_WATK|SCB_CRI );
set_sc( SO_WARMER , SC_WARMER , SI_WARMER , SCB_NONE );
set_sc( SO_VACUUM_EXTREME , SC_VACUUM_EXTREME , SI_VACUUM_EXTREME , SCB_NONE );
- set_sc( SO_ARRULLO , SC_DEEPSLEEP , SI_DEEPSLEEP , SCB_NONE );
+ set_sc( SO_ARRULLO , SC_DEEP_SLEEP , SI_DEEPSLEEP , SCB_NONE );
set_sc( SO_FIRE_INSIGNIA , SC_FIRE_INSIGNIA , SI_FIRE_INSIGNIA , SCB_MATK | SCB_BATK | SCB_WATK | SCB_ATK_ELE | SCB_REGEN );
set_sc( SO_WATER_INSIGNIA , SC_WATER_INSIGNIA , SI_WATER_INSIGNIA , SCB_WATK | SCB_ATK_ELE | SCB_REGEN );
set_sc( SO_WIND_INSIGNIA , SC_WIND_INSIGNIA , SI_WIND_INSIGNIA , SCB_WATK | SCB_ATK_ELE | SCB_REGEN );
@@ -691,11 +705,11 @@ void initChangeTables(void) {
* Genetic
**/
set_sc( GN_CARTBOOST , SC_GN_CARTBOOST, SI_CARTSBOOST , SCB_SPEED );
- set_sc( GN_THORNS_TRAP , SC_THORNSTRAP , SI_THORNTRAP , SCB_NONE );
- set_sc_with_vfx( GN_BLOOD_SUCKER , SC_BLOODSUCKER , SI_BLOODSUCKER , SCB_NONE );
+ set_sc( GN_THORNS_TRAP , SC_THORNS_TRAP , SI_THORNTRAP , SCB_NONE );
+ set_sc_with_vfx( GN_BLOOD_SUCKER , SC_BLOOD_SUCKER , SI_BLOODSUCKER , SCB_NONE );
set_sc( GN_WALLOFTHORN , SC_STOP , SI_BLANK , SCB_NONE );
- set_sc( GN_FIRE_EXPANSION_SMOKE_POWDER, SC_SMOKEPOWDER , SI_FIRE_EXPANSION_SMOKE_POWDER, SCB_NONE );
- set_sc( GN_FIRE_EXPANSION_TEAR_GAS , SC_TEARGAS , SI_FIRE_EXPANSION_TEAR_GAS , SCB_NONE );
+ set_sc( GN_FIRE_EXPANSION_SMOKE_POWDER, SC_FIRE_EXPANSION_SMOKE_POWDER , SI_FIRE_EXPANSION_SMOKE_POWDER, SCB_NONE );
+ set_sc( GN_FIRE_EXPANSION_TEAR_GAS , SC_FIRE_EXPANSION_TEAR_GAS , SI_FIRE_EXPANSION_TEAR_GAS , SCB_NONE );
set_sc( GN_MANDRAGORA , SC_MANDRAGORA , SI_MANDRAGORA , SCB_INT );
// Elemental Spirit summoner's 'side' status changes.
@@ -727,7 +741,7 @@ void initChangeTables(void) {
set_sc( EL_ROCK_CRUSHER_ATK, SC_ROCK_CRUSHER_ATK , SI_ROCK_CRUSHER_ATK , SCB_SPEED );
add_sc( KO_YAMIKUMO , SC_HIDING );
- set_sc_with_vfx( KO_JYUMONJIKIRI , SC_JYUMONJIKIRI , SI_KO_JYUMONJIKIRI , SCB_NONE );
+ set_sc_with_vfx( KO_JYUMONJIKIRI , SC_KO_JYUMONJIKIRI , SI_KO_JYUMONJIKIRI , SCB_NONE );
add_sc( KO_MAKIBISHI , SC_STUN );
set_sc( KO_MEIKYOUSISUI , SC_MEIKYOUSISUI , SI_MEIKYOUSISUI , SCB_NONE );
set_sc( KO_KYOUGAKU , SC_KYOUGAKU , SI_KYOUGAKU , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK );
@@ -736,12 +750,14 @@ void initChangeTables(void) {
set_sc( KO_IZAYOI , SC_IZAYOI , SI_IZAYOI , SCB_MATK );
set_sc( KG_KYOMU , SC_KYOMU , SI_KYOMU , SCB_NONE );
set_sc( KG_KAGEMUSYA , SC_KAGEMUSYA , SI_KAGEMUSYA , SCB_NONE );
- set_sc( KG_KAGEHUMI , SC_KAGEHUMI , SI_KG_KAGEHUMI , SCB_NONE );
+ set_sc( KG_KAGEHUMI , SC_KG_KAGEHUMI , SI_KG_KAGEHUMI , SCB_NONE );
set_sc( OB_ZANGETSU , SC_ZANGETSU , SI_ZANGETSU , SCB_MATK|SCB_BATK );
set_sc_with_vfx( OB_AKAITSUKI , SC_AKAITSUKI , SI_AKAITSUKI , SCB_NONE );
set_sc( OB_OBOROGENSOU , SC_GENSOU , SI_GENSOU , SCB_NONE );
- // Storing the target job rather than simply SC_SPIRIT simplifies code later on.
+ set_sc( ALL_FULL_THROTTLE , SC_FULL_THROTTLE , SI_FULL_THROTTLE , SCB_SPEED|SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK );
+
+ // Storing the target job rather than simply SC_SOULLINK simplifies code later on.
SkillStatusChangeTable[SL_ALCHEMIST] = (sc_type)MAPID_ALCHEMIST,
SkillStatusChangeTable[SL_MONK] = (sc_type)MAPID_MONK,
SkillStatusChangeTable[SL_STAR] = (sc_type)MAPID_STAR_GLADIATOR,
@@ -759,33 +775,33 @@ void initChangeTables(void) {
SkillStatusChangeTable[SL_SOULLINKER] = (sc_type)MAPID_SOUL_LINKER,
//Status that don't have a skill associated.
- StatusIconChangeTable[SC_WEIGHT50] = SI_WEIGHT50;
- StatusIconChangeTable[SC_WEIGHT90] = SI_WEIGHT90;
- StatusIconChangeTable[SC_ASPDPOTION0] = SI_ASPDPOTION0;
- StatusIconChangeTable[SC_ASPDPOTION1] = SI_ASPDPOTION1;
- StatusIconChangeTable[SC_ASPDPOTION2] = SI_ASPDPOTION2;
- StatusIconChangeTable[SC_ASPDPOTION3] = SI_ASPDPOTIONINFINITY;
- StatusIconChangeTable[SC_SPEEDUP0] = SI_MOVHASTE_HORSE;
- StatusIconChangeTable[SC_SPEEDUP1] = SI_SPEEDPOTION1;
- StatusIconChangeTable[SC_INCSTR] = SI_INCSTR;
- StatusIconChangeTable[SC_MIRACLE] = SI_SPIRIT;
- StatusIconChangeTable[SC_INTRAVISION] = SI_INTRAVISION;
- StatusIconChangeTable[SC_STRFOOD] = SI_FOODSTR;
- StatusIconChangeTable[SC_AGIFOOD] = SI_FOODAGI;
- StatusIconChangeTable[SC_VITFOOD] = SI_FOODVIT;
- StatusIconChangeTable[SC_INTFOOD] = SI_FOODINT;
- StatusIconChangeTable[SC_DEXFOOD] = SI_FOODDEX;
- StatusIconChangeTable[SC_LUKFOOD] = SI_FOODLUK;
- StatusIconChangeTable[SC_FLEEFOOD]= SI_FOODFLEE;
- StatusIconChangeTable[SC_HITFOOD] = SI_FOODHIT;
+ StatusIconChangeTable[SC_WEIGHTOVER50] = SI_WEIGHTOVER50;
+ StatusIconChangeTable[SC_WEIGHTOVER90] = SI_WEIGHTOVER90;
+ StatusIconChangeTable[SC_ATTHASTE_POTION1] = SI_ATTHASTE_POTION1;
+ StatusIconChangeTable[SC_ATTHASTE_POTION2] = SI_ATTHASTE_POTION2;
+ StatusIconChangeTable[SC_ATTHASTE_POTION3] = SI_ATTHASTE_POTION3;
+ StatusIconChangeTable[SC_ATTHASTE_INFINITY] = SI_ATTHASTE_INFINITY;
+ StatusIconChangeTable[SC_MOVHASTE_HORSE] = SI_MOVHASTE_HORSE;
+ StatusIconChangeTable[SC_MOVHASTE_INFINITY] = SI_MOVHASTE_INFINITY;
+ StatusIconChangeTable[SC_CHASEWALK2] = SI_INCSTR;
+ StatusIconChangeTable[SC_MIRACLE] = SI_SOULLINK;
+ StatusIconChangeTable[SC_CLAIRVOYANCE] = SI_CLAIRVOYANCE;
+ StatusIconChangeTable[SC_FOOD_STR] = SI_FOOD_STR;
+ StatusIconChangeTable[SC_FOOD_AGI] = SI_FOOD_AGI;
+ StatusIconChangeTable[SC_FOOD_VIT] = SI_FOOD_VIT;
+ StatusIconChangeTable[SC_FOOD_INT] = SI_FOOD_INT;
+ StatusIconChangeTable[SC_FOOD_DEX] = SI_FOOD_DEX;
+ StatusIconChangeTable[SC_FOOD_LUK] = SI_FOOD_LUK;
+ StatusIconChangeTable[SC_FOOD_BASICAVOIDANCE]= SI_FOOD_BASICAVOIDANCE;
+ StatusIconChangeTable[SC_FOOD_BASICHIT] = SI_FOOD_BASICHIT;
StatusIconChangeTable[SC_MANU_ATK] = SI_MANU_ATK;
StatusIconChangeTable[SC_MANU_DEF] = SI_MANU_DEF;
StatusIconChangeTable[SC_SPL_ATK] = SI_SPL_ATK;
StatusIconChangeTable[SC_SPL_DEF] = SI_SPL_DEF;
StatusIconChangeTable[SC_MANU_MATK] = SI_MANU_MATK;
StatusIconChangeTable[SC_SPL_MATK] = SI_SPL_MATK;
- StatusIconChangeTable[SC_ATKPOTION] = SI_PLUSATTACKPOWER;
- StatusIconChangeTable[SC_MATKPOTION] = SI_PLUSMAGICPOWER;
+ StatusIconChangeTable[SC_PLUSATTACKPOWER] = SI_PLUSATTACKPOWER;
+ StatusIconChangeTable[SC_PLUSMAGICPOWER] = SI_PLUSMAGICPOWER;
//Cash Items
StatusIconChangeTable[SC_FOOD_STR_CASH] = SI_FOOD_STR_CASH;
StatusIconChangeTable[SC_FOOD_AGI_CASH] = SI_FOOD_AGI_CASH;
@@ -793,32 +809,32 @@ void initChangeTables(void) {
StatusIconChangeTable[SC_FOOD_DEX_CASH] = SI_FOOD_DEX_CASH;
StatusIconChangeTable[SC_FOOD_INT_CASH] = SI_FOOD_INT_CASH;
StatusIconChangeTable[SC_FOOD_LUK_CASH] = SI_FOOD_LUK_CASH;
- StatusIconChangeTable[SC_EXPBOOST] = SI_EXPBOOST;
- StatusIconChangeTable[SC_ITEMBOOST] = SI_ITEMBOOST;
- StatusIconChangeTable[SC_JEXPBOOST] = SI_CASH_PLUSONLYJOBEXP;
- StatusIconChangeTable[SC_LIFEINSURANCE] = SI_LIFEINSURANCE;
- StatusIconChangeTable[SC_BOSSMAPINFO] = SI_BOSSMAPINFO;
- StatusIconChangeTable[SC_DEF_RATE] = SI_DEF_RATE;
- StatusIconChangeTable[SC_MDEF_RATE] = SI_MDEF_RATE;
- StatusIconChangeTable[SC_INCCRI] = SI_INCCRI;
- StatusIconChangeTable[SC_INCFLEE2] = SI_PLUSAVOIDVALUE;
- StatusIconChangeTable[SC_INCHEALRATE] = SI_INCHEALRATE;
+ StatusIconChangeTable[SC_CASH_PLUSEXP] = SI_CASH_PLUSEXP;
+ StatusIconChangeTable[SC_CASH_RECEIVEITEM] = SI_CASH_RECEIVEITEM;
+ StatusIconChangeTable[SC_CASH_PLUSONLYJOBEXP] = SI_CASH_PLUSONLYJOBEXP;
+ StatusIconChangeTable[SC_CASH_DEATHPENALTY] = SI_CASH_DEATHPENALTY;
+ StatusIconChangeTable[SC_CASH_BOSS_ALARM] = SI_CASH_BOSS_ALARM;
+ StatusIconChangeTable[SC_PROTECT_DEF] = SI_PROTECT_DEF;
+ StatusIconChangeTable[SC_PROTECT_MDEF] = SI_PROTECT_MDEF;
+ StatusIconChangeTable[SC_CRITICALPERCENT] = SI_CRITICALPERCENT;
+ StatusIconChangeTable[SC_PLUSAVOIDVALUE] = SI_PLUSAVOIDVALUE;
+ StatusIconChangeTable[SC_HEALPLUS] = SI_HEALPLUS;
StatusIconChangeTable[SC_S_LIFEPOTION] = SI_S_LIFEPOTION;
StatusIconChangeTable[SC_L_LIFEPOTION] = SI_L_LIFEPOTION;
- StatusIconChangeTable[SC_SPCOST_RATE] = SI_ATKER_BLOOD;
- StatusIconChangeTable[SC_COMMONSC_RESIST] = SI_TARGET_BLOOD;
+ StatusIconChangeTable[SC_ATKER_BLOOD] = SI_ATKER_BLOOD;
+ StatusIconChangeTable[SC_TARGET_BLOOD] = SI_TARGET_BLOOD;
// Mercenary Bonus Effects
- StatusIconChangeTable[SC_MERC_FLEEUP] = SI_MERC_FLEEUP;
- StatusIconChangeTable[SC_MERC_ATKUP] = SI_MERC_ATKUP;
- StatusIconChangeTable[SC_MERC_HPUP] = SI_MERC_HPUP;
- StatusIconChangeTable[SC_MERC_SPUP] = SI_MERC_SPUP;
- StatusIconChangeTable[SC_MERC_HITUP] = SI_MERC_HITUP;
+ StatusIconChangeTable[SC_MER_FLEE] = SI_MER_FLEE;
+ StatusIconChangeTable[SC_MER_ATK] = SI_MER_ATK;
+ StatusIconChangeTable[SC_MER_HP] = SI_MER_HP;
+ StatusIconChangeTable[SC_MER_SP] = SI_MER_SP;
+ StatusIconChangeTable[SC_MER_HIT] = SI_MER_HIT;
// Warlock Spheres
- StatusIconChangeTable[SC_SPHERE_1] = SI_SPHERE_1;
- StatusIconChangeTable[SC_SPHERE_2] = SI_SPHERE_2;
- StatusIconChangeTable[SC_SPHERE_3] = SI_SPHERE_3;
- StatusIconChangeTable[SC_SPHERE_4] = SI_SPHERE_4;
- StatusIconChangeTable[SC_SPHERE_5] = SI_SPHERE_5;
+ StatusIconChangeTable[SC_SUMMON1] = SI_SPHERE_1;
+ StatusIconChangeTable[SC_SUMMON2] = SI_SPHERE_2;
+ StatusIconChangeTable[SC_SUMMON3] = SI_SPHERE_3;
+ StatusIconChangeTable[SC_SUMMON4] = SI_SPHERE_4;
+ StatusIconChangeTable[SC_SUMMON5] = SI_SPHERE_5;
// Warlock Preserved spells
StatusIconChangeTable[SC_SPELLBOOK1] = SI_SPELLBOOK1;
StatusIconChangeTable[SC_SPELLBOOK2] = SI_SPELLBOOK2;
@@ -826,7 +842,7 @@ void initChangeTables(void) {
StatusIconChangeTable[SC_SPELLBOOK4] = SI_SPELLBOOK4;
StatusIconChangeTable[SC_SPELLBOOK5] = SI_SPELLBOOK5;
StatusIconChangeTable[SC_SPELLBOOK6] = SI_SPELLBOOK6;
- StatusIconChangeTable[SC_MAXSPELLBOOK] = SI_SPELLBOOK7;
+ StatusIconChangeTable[SC_SPELLBOOK7] = SI_SPELLBOOK7;
StatusIconChangeTable[SC_NEUTRALBARRIER_MASTER] = SI_NEUTRALBARRIER_MASTER;
StatusIconChangeTable[SC_STEALTHFIELD_MASTER] = SI_STEALTHFIELD_MASTER;
@@ -856,7 +872,7 @@ void initChangeTables(void) {
StatusIconChangeTable[SC_MYSTERIOUS_POWDER] = SI_MYSTERIOUS_POWDER;
StatusIconChangeTable[SC_MELON_BOMB] = SI_MELON_BOMB;
StatusIconChangeTable[SC_BANANA_BOMB] = SI_BANANA_BOMB;
- StatusIconChangeTable[SC_BANANA_BOMB_SITDOWN] = SI_BANANA_BOMB_SITDOWN_POSTDELAY;
+ StatusIconChangeTable[SC_BANANA_BOMB_SITDOWN_POSTDELAY] = SI_BANANA_BOMB_SITDOWN_POSTDELAY;
//Genetics New Food Items Status Icons
StatusIconChangeTable[SC_SAVAGE_STEAK] = SI_SAVAGE_STEAK;
@@ -897,19 +913,21 @@ void initChangeTables(void) {
StatusIconChangeTable[SC_CURSED_SOIL] = SI_CURSED_SOIL;
StatusIconChangeTable[SC_UPHEAVAL] = SI_UPHEAVAL;
StatusIconChangeTable[SC_PUSH_CART] = SI_ON_PUSH_CART;
+ StatusIconChangeTable[SC_REBOUND] = SI_REBOUND;
StatusIconChangeTable[SC_ALL_RIDING] = SI_ALL_RIDING;
+ StatusIconChangeTable[SC_MONSTER_TRANSFORM] = SI_MONSTER_TRANSFORM;
//Other SC which are not necessarily associated to skills.
- StatusChangeFlagTable[SC_ASPDPOTION0] = SCB_ASPD;
- StatusChangeFlagTable[SC_ASPDPOTION1] = SCB_ASPD;
- StatusChangeFlagTable[SC_ASPDPOTION2] = SCB_ASPD;
- StatusChangeFlagTable[SC_ASPDPOTION3] = SCB_ASPD;
- StatusChangeFlagTable[SC_SPEEDUP0] = SCB_SPEED;
- StatusChangeFlagTable[SC_SPEEDUP1] = SCB_SPEED;
- StatusChangeFlagTable[SC_ATKPOTION] = SCB_BATK;
- StatusChangeFlagTable[SC_MATKPOTION] = SCB_MATK;
+ StatusChangeFlagTable[SC_ATTHASTE_POTION1] = SCB_ASPD;
+ StatusChangeFlagTable[SC_ATTHASTE_POTION2] = SCB_ASPD;
+ StatusChangeFlagTable[SC_ATTHASTE_POTION3] = SCB_ASPD;
+ StatusChangeFlagTable[SC_ATTHASTE_INFINITY] = SCB_ASPD;
+ StatusChangeFlagTable[SC_MOVHASTE_HORSE] = SCB_SPEED;
+ StatusChangeFlagTable[SC_MOVHASTE_INFINITY] = SCB_SPEED;
+ StatusChangeFlagTable[SC_PLUSATTACKPOWER] = SCB_BATK;
+ StatusChangeFlagTable[SC_PLUSMAGICPOWER] = SCB_MATK;
StatusChangeFlagTable[SC_INCALLSTATUS] |= SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK;
- StatusChangeFlagTable[SC_INCSTR] |= SCB_STR;
+ StatusChangeFlagTable[SC_CHASEWALK2] |= SCB_STR;
StatusChangeFlagTable[SC_INCAGI] |= SCB_AGI;
StatusChangeFlagTable[SC_INCVIT] |= SCB_VIT;
StatusChangeFlagTable[SC_INCINT] |= SCB_INT;
@@ -919,9 +937,9 @@ void initChangeTables(void) {
StatusChangeFlagTable[SC_INCHITRATE] |= SCB_HIT;
StatusChangeFlagTable[SC_INCFLEE] |= SCB_FLEE;
StatusChangeFlagTable[SC_INCFLEERATE] |= SCB_FLEE;
- StatusChangeFlagTable[SC_INCCRI] |= SCB_CRI;
+ StatusChangeFlagTable[SC_CRITICALPERCENT] |= SCB_CRI;
StatusChangeFlagTable[SC_INCASPDRATE] |= SCB_ASPD;
- StatusChangeFlagTable[SC_INCFLEE2] |= SCB_FLEE2;
+ StatusChangeFlagTable[SC_PLUSAVOIDVALUE] |= SCB_FLEE2;
StatusChangeFlagTable[SC_INCMHPRATE] |= SCB_MAXHP;
StatusChangeFlagTable[SC_INCMSPRATE] |= SCB_MAXSP;
StatusChangeFlagTable[SC_INCMHP] |= SCB_MAXHP;
@@ -929,20 +947,20 @@ void initChangeTables(void) {
StatusChangeFlagTable[SC_INCATKRATE] |= SCB_BATK|SCB_WATK;
StatusChangeFlagTable[SC_INCMATKRATE] |= SCB_MATK;
StatusChangeFlagTable[SC_INCDEFRATE] |= SCB_DEF;
- StatusChangeFlagTable[SC_STRFOOD] |= SCB_STR;
- StatusChangeFlagTable[SC_AGIFOOD] |= SCB_AGI;
- StatusChangeFlagTable[SC_VITFOOD] |= SCB_VIT;
- StatusChangeFlagTable[SC_INTFOOD] |= SCB_INT;
- StatusChangeFlagTable[SC_DEXFOOD] |= SCB_DEX;
- StatusChangeFlagTable[SC_LUKFOOD] |= SCB_LUK;
- StatusChangeFlagTable[SC_HITFOOD] |= SCB_HIT;
- StatusChangeFlagTable[SC_FLEEFOOD] |= SCB_FLEE;
+ StatusChangeFlagTable[SC_FOOD_STR] |= SCB_STR;
+ StatusChangeFlagTable[SC_FOOD_AGI] |= SCB_AGI;
+ StatusChangeFlagTable[SC_FOOD_VIT] |= SCB_VIT;
+ StatusChangeFlagTable[SC_FOOD_INT] |= SCB_INT;
+ StatusChangeFlagTable[SC_FOOD_DEX] |= SCB_DEX;
+ StatusChangeFlagTable[SC_FOOD_LUK] |= SCB_LUK;
+ StatusChangeFlagTable[SC_FOOD_BASICHIT] |= SCB_HIT;
+ StatusChangeFlagTable[SC_FOOD_BASICAVOIDANCE] |= SCB_FLEE;
StatusChangeFlagTable[SC_BATKFOOD] |= SCB_BATK;
StatusChangeFlagTable[SC_WATKFOOD] |= SCB_WATK;
StatusChangeFlagTable[SC_MATKFOOD] |= SCB_MATK;
- StatusChangeFlagTable[SC_ARMOR_ELEMENT] |= SCB_ALL;
+ StatusChangeFlagTable[SC_ARMORPROPERTY] |= SCB_ALL;
StatusChangeFlagTable[SC_ARMOR_RESIST] |= SCB_ALL;
- StatusChangeFlagTable[SC_SPCOST_RATE] |= SCB_ALL;
+ StatusChangeFlagTable[SC_ATKER_BLOOD] |= SCB_ALL;
StatusChangeFlagTable[SC_WALKSPEED] |= SCB_SPEED;
StatusChangeFlagTable[SC_ITEMSCRIPT] |= SCB_ALL;
// Cash Items
@@ -953,11 +971,11 @@ void initChangeTables(void) {
StatusChangeFlagTable[SC_FOOD_INT_CASH] = SCB_INT;
StatusChangeFlagTable[SC_FOOD_LUK_CASH] = SCB_LUK;
// Mercenary Bonus Effects
- StatusChangeFlagTable[SC_MERC_FLEEUP] |= SCB_FLEE;
- StatusChangeFlagTable[SC_MERC_ATKUP] |= SCB_WATK;
- StatusChangeFlagTable[SC_MERC_HPUP] |= SCB_MAXHP;
- StatusChangeFlagTable[SC_MERC_SPUP] |= SCB_MAXSP;
- StatusChangeFlagTable[SC_MERC_HITUP] |= SCB_HIT;
+ StatusChangeFlagTable[SC_MER_FLEE] |= SCB_FLEE;
+ StatusChangeFlagTable[SC_MER_ATK] |= SCB_WATK;
+ StatusChangeFlagTable[SC_MER_HP] |= SCB_MAXHP;
+ StatusChangeFlagTable[SC_MER_SP] |= SCB_MAXSP;
+ StatusChangeFlagTable[SC_MER_HIT] |= SCB_HIT;
// Guillotine Cross Poison Effects
StatusChangeFlagTable[SC_PARALYSE] |= SCB_ASPD|SCB_FLEE|SCB_SPEED;
StatusChangeFlagTable[SC_DEATHHURT] |= SCB_REGEN;
@@ -978,32 +996,34 @@ void initChangeTables(void) {
StatusChangeFlagTable[SC_EXTRACT_WHITE_POTION_Z] |= SCB_REGEN;
StatusChangeFlagTable[SC_VITATA_500] |= SCB_REGEN;
StatusChangeFlagTable[SC_EXTRACT_SALAMINE_JUICE] |= SCB_ASPD;
+ StatusChangeFlagTable[SC_REBOUND] |= SCB_SPEED|SCB_REGEN;
StatusChangeFlagTable[SC_ALL_RIDING] = SCB_SPEED;
/* StatusDisplayType Table [Ind/Hercules] */
StatusDisplayType[SC_ALL_RIDING] = true;
StatusDisplayType[SC_PUSH_CART] = true;
- StatusDisplayType[SC_SPHERE_1] = true;
- StatusDisplayType[SC_SPHERE_2] = true;
- StatusDisplayType[SC_SPHERE_3] = true;
- StatusDisplayType[SC_SPHERE_4] = true;
- StatusDisplayType[SC_SPHERE_5] = true;
+ StatusDisplayType[SC_SUMMON1] = true;
+ StatusDisplayType[SC_SUMMON2] = true;
+ StatusDisplayType[SC_SUMMON3] = true;
+ StatusDisplayType[SC_SUMMON4] = true;
+ StatusDisplayType[SC_SUMMON5] = true;
StatusDisplayType[SC_CAMOUFLAGE] = true;
StatusDisplayType[SC_DUPLELIGHT] = true;
StatusDisplayType[SC_ORATIO] = true;
- StatusDisplayType[SC_FREEZING] = true;
+ StatusDisplayType[SC_FROSTMISTY] = true;
StatusDisplayType[SC_VENOMIMPRESS] = true;
StatusDisplayType[SC_HALLUCINATIONWALK] = true;
StatusDisplayType[SC_ROLLINGCUTTER] = true;
StatusDisplayType[SC_BANDING] = true;
StatusDisplayType[SC_CRYSTALIZE] = true;
- StatusDisplayType[SC_DEEPSLEEP] = true;
+ StatusDisplayType[SC_DEEP_SLEEP] = true;
StatusDisplayType[SC_CURSEDCIRCLE_ATKER]= true;
StatusDisplayType[SC_CURSEDCIRCLE_TARGET]= true;
- StatusDisplayType[SC_BLOODSUCKER] = true;
+ StatusDisplayType[SC_BLOOD_SUCKER] = true;
StatusDisplayType[SC__SHADOWFORM] = true;
StatusDisplayType[SC__MANHOLE] = true;
+ StatusDisplayType[SC_MONSTER_TRANSFORM] = true;
#ifdef RENEWAL_EDP
// renewal EDP increases your weapon atk
@@ -1011,7 +1031,7 @@ void initChangeTables(void) {
#endif
if( !battle_config.display_hallucination ) //Disable Hallucination.
- StatusIconChangeTable[SC_HALLUCINATION] = SI_BLANK;
+ StatusIconChangeTable[SC_ILLUSION] = SI_BLANK;
}
static void initDummyData(void)
@@ -1109,7 +1129,7 @@ int status_damage(struct block_list *src,struct block_list *target,int hp, int s
}
if (target->type == BL_SKILL)
- return skill->unit_ondamaged((struct skill_unit *)target, src, hp, gettick());
+ return skill->unit_ondamaged((struct skill_unit *)target, src, hp, iTimer->gettick());
status = status_get_status_data(target);
if( status == &dummy_status )
@@ -1147,7 +1167,7 @@ int status_damage(struct block_list *src,struct block_list *target,int hp, int s
status_change_end(target, SC_STONE, INVALID_TIMER);
status_change_end(target, SC_FREEZE, INVALID_TIMER);
status_change_end(target, SC_SLEEP, INVALID_TIMER);
- status_change_end(target, SC_WINKCHARM, INVALID_TIMER);
+ status_change_end(target, SC_DC_WINKCHARM, INVALID_TIMER);
status_change_end(target, SC_CONFUSION, INVALID_TIMER);
status_change_end(target, SC_TRICKDEAD, INVALID_TIMER);
status_change_end(target, SC_HIDING, INVALID_TIMER);
@@ -1155,8 +1175,8 @@ int status_damage(struct block_list *src,struct block_list *target,int hp, int s
status_change_end(target, SC_CHASEWALK, INVALID_TIMER);
status_change_end(target, SC_CAMOUFLAGE, INVALID_TIMER);
status_change_end(target, SC__INVISIBILITY, INVALID_TIMER);
- status_change_end(target, SC_DEEPSLEEP, INVALID_TIMER);
- if ((sce=sc->data[SC_ENDURE]) && !sce->val4) {
+ status_change_end(target, SC_DEEP_SLEEP, INVALID_TIMER);
+ if ((sce=sc->data[SC_ENDURE]) && !sce->val4 && !sc->data[SC_LKCONCENTRATION]) {
//Endure count is only reduced by non-players on non-gvg maps.
//val4 signals infinite endure. [Skotlex]
if (src && src->type != BL_PC && !map_flag_gvg(target->m) && !map[target->m].flag.battleground && --(sce->val2) < 0)
@@ -1192,14 +1212,14 @@ int status_damage(struct block_list *src,struct block_list *target,int hp, int s
status_change_end(target, SC_BERSERK, INVALID_TIMER);
if( sc->data[SC_RAISINGDRAGON] && status->hp <= 1000 )
status_change_end(target, SC_RAISINGDRAGON, INVALID_TIMER);
- if (sc->data[SC_SATURDAYNIGHTFEVER] && status->hp <= 100)
- status_change_end(target, SC_SATURDAYNIGHTFEVER, INVALID_TIMER);
+ if (sc->data[SC_SATURDAY_NIGHT_FEVER] && status->hp <= 100)
+ status_change_end(target, SC_SATURDAY_NIGHT_FEVER, INVALID_TIMER);
if (sc->data[SC__BLOODYLUST] && status->hp <= 100)
status_change_end(target, SC__BLOODYLUST, INVALID_TIMER);
}
switch (target->type) {
- case BL_PC: pc_damage((TBL_PC*)target,src,hp,sp); break;
+ case BL_PC: pc->damage((TBL_PC*)target,src,hp,sp); break;
case BL_MOB: mob_damage((TBL_MOB*)target, src, hp); break;
case BL_HOM: homun->damaged((TBL_HOM*)target); break;
case BL_MER: mercenary_heal((TBL_MER*)target,hp,sp); break;
@@ -1213,7 +1233,7 @@ int status_damage(struct block_list *src,struct block_list *target,int hp, int s
if( status->hp || (flag&8) )
{ //Still lives or has been dead before this damage.
if (walkdelay)
- unit_set_walkdelay(target, gettick(), walkdelay, 0);
+ unit_set_walkdelay(target, iTimer->gettick(), walkdelay, 0);
return hp+sp;
}
@@ -1224,7 +1244,7 @@ int status_damage(struct block_list *src,struct block_list *target,int hp, int s
//&2: Also remove object from map.
//&4: Also delete object from memory.
switch (target->type) {
- case BL_PC: flag = pc_dead((TBL_PC*)target,src); break;
+ case BL_PC: flag = pc->dead((TBL_PC*)target,src); break;
case BL_MOB: flag = mob_dead((TBL_MOB*)target, src, flag&4?3:0); break;
case BL_HOM: flag = homun->dead((TBL_HOM*)target); break;
case BL_MER: flag = mercenary_dead((TBL_MER*)target); break;
@@ -1303,7 +1323,7 @@ int status_damage(struct block_list *src,struct block_list *target,int hp, int s
unit_stop_walking(target,1);
unit_skillcastcancel(target,0);
clif->clearunit_area(target,CLR_DEAD);
- skill->unit_move(target,gettick(),4);
+ skill->unit_move(target,iTimer->gettick(),4);
skill->cleartimerskill(target);
}
@@ -1370,7 +1390,7 @@ int status_heal(struct block_list *bl,int hp,int sp, int flag)
// send hp update to client
switch(bl->type) {
- case BL_PC: pc_heal((TBL_PC*)bl,hp,sp,flag&2?1:0); break;
+ case BL_PC: pc->heal((TBL_PC*)bl,hp,sp,flag&2?1:0); break;
case BL_MOB: mob_heal((TBL_MOB*)bl,hp); break;
case BL_HOM: homun->healed((TBL_HOM*)bl); break;
case BL_MER: mercenary_heal((TBL_MER*)bl,hp,sp); break;
@@ -1474,7 +1494,7 @@ int status_revive(struct block_list *bl, unsigned char per_hp, unsigned char per
if (bl->prev) //Animation only if character is already on a map.
clif->resurrection(bl, 1);
switch (bl->type) {
- case BL_PC: pc_revive((TBL_PC*)bl, hp, sp); break;
+ case BL_PC: pc->revive((TBL_PC*)bl, hp, sp); break;
case BL_MOB: mob_revive((TBL_MOB*)bl, hp); break;
case BL_HOM: homun->revive((TBL_HOM*)bl, hp, sp); break;
}
@@ -1516,7 +1536,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin
if( skill_id ) {
- if( src ) {
+ if( src && !(src->type == BL_PC && ((TBL_PC*)src)->skillitem)) { // Items that cast skills using 'itemskill' will not be handled by map_zone_db.
int i;
for(i = 0; i < map[src->m].zone->disabled_skills_count; i++) {
@@ -1547,7 +1567,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin
break;
case AL_TELEPORT:
//Should fail when used on top of Land Protector [Skotlex]
- if (src && map_getcell(src->m, src->x, src->y, CELL_CHKLANDPROTECTOR)
+ if (src && iMap->getcell(src->m, src->x, src->y, CELL_CHKLANDPROTECTOR)
&& !(status->mode&MD_BOSS)
&& (src->type != BL_PC || ((TBL_PC*)src)->skillitem != skill_id))
return 0;
@@ -1576,9 +1596,9 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin
)
return 0;
- if (sc->data[SC_WINKCHARM] && target && !flag) { //Prevents skill usage
+ if (sc->data[SC_DC_WINKCHARM] && target && !flag) { //Prevents skill usage
if( unit_bl2ud(src) && (unit_bl2ud(src))->walktimer == INVALID_TIMER )
- unit_walktobl(src, map_id2bl(sc->data[SC_WINKCHARM]->val2), 3, 1);
+ unit_walktobl(src, iMap->id2bl(sc->data[SC_DC_WINKCHARM]->val2), 3, 1);
clif->emotion(src, E_LV);
return 0;
}
@@ -1597,7 +1617,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin
if (sc->data[SC_DANCING] && flag!=2) {
if( src->type == BL_PC && skill_id >= WA_SWING_DANCE && skill_id <= WM_UNLIMITED_HUMMING_VOICE )
{ // Lvl 5 Lesson or higher allow you use 3rd job skills while dancing.v
- if( pc_checkskill((TBL_PC*)src,WM_LESSON) < 5 )
+ if( pc->checkskill((TBL_PC*)src,WM_LESSON) < 5 )
return 0;
} else if(sc->data[SC_LONGING]) { //Allow everything except dancing/re-dancing. [Skotlex]
if (skill_id == BD_ENCORE ||
@@ -1632,13 +1652,13 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin
sc->data[SC__INVISIBILITY] ||
(sc->data[SC_CRYSTALIZE] && src->type != BL_MOB) ||
sc->data[SC__IGNORANCE] ||
- sc->data[SC_DEEPSLEEP] ||
- sc->data[SC_SATURDAYNIGHTFEVER] ||
+ sc->data[SC_DEEP_SLEEP] ||
+ sc->data[SC_SATURDAY_NIGHT_FEVER] ||
sc->data[SC_CURSEDCIRCLE_TARGET] ||
- (sc->data[SC_MARIONETTE] && skill_id != CG_MARIONETTE) || //Only skill you can use is marionette again to cancel it
- (sc->data[SC_MARIONETTE2] && skill_id == CG_MARIONETTE) || //Cannot use marionette if you are being buffed by another
+ (sc->data[SC_MARIONETTE_MASTER] && skill_id != CG_MARIONETTE) || //Only skill you can use is marionette again to cancel it
+ (sc->data[SC_MARIONETTE] && skill_id == CG_MARIONETTE) || //Cannot use marionette if you are being buffed by another
(sc->data[SC_STASIS] && skill->block_check(src, SC_STASIS, skill_id)) ||
- (sc->data[SC_KAGEHUMI] && skill->block_check(src, SC_KAGEHUMI, skill_id))
+ (sc->data[SC_KG_KAGEHUMI] && skill->block_check(src, SC_KG_KAGEHUMI, skill_id))
))
return 0;
@@ -1813,21 +1833,21 @@ int status_base_amotion_pc(struct map_session_data* sd, struct status_data* stat
}
amotion = ( sd->status.weapon < MAX_WEAPON_TYPE && mod < 0 )
- ? (aspd_base[pc_class2idx(sd->status.class_)][sd->status.weapon]) // single weapon
- : ((aspd_base[pc_class2idx(sd->status.class_)][sd->weapontype2] // dual-wield
- + aspd_base[pc_class2idx(sd->status.class_)][sd->weapontype2]) * 6 / 10 + 10 * mod
- - aspd_base[pc_class2idx(sd->status.class_)][sd->weapontype2]
- + aspd_base[pc_class2idx(sd->status.class_)][sd->weapontype1]);
+ ? (aspd_base[pc->class2idx(sd->status.class_)][sd->status.weapon]) // single weapon
+ : ((aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype2] // dual-wield
+ + aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype2]) * 6 / 10 + 10 * mod
+ - aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype2]
+ + aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype1]);
if ( sd->status.shield )
- amotion += ( 2000 - aspd_base[pc_class2idx(sd->status.class_)][W_FIST] ) +
- ( aspd_base[pc_class2idx(sd->status.class_)][MAX_WEAPON_TYPE] - 2000 );
+ amotion += ( 2000 - aspd_base[pc->class2idx(sd->status.class_)][W_FIST] ) +
+ ( aspd_base[pc->class2idx(sd->status.class_)][MAX_WEAPON_TYPE] - 2000 );
#else
// base weapon delay
amotion = (sd->status.weapon < MAX_WEAPON_TYPE)
- ? (aspd_base[pc_class2idx(sd->status.class_)][sd->status.weapon]) // single weapon
- : (aspd_base[pc_class2idx(sd->status.class_)][sd->weapontype1] + aspd_base[pc_class2idx(sd->status.class_)][sd->weapontype2])*7/10; // dual-wield
+ ? (aspd_base[pc->class2idx(sd->status.class_)][sd->status.weapon]) // single weapon
+ : (aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype1] + aspd_base[pc->class2idx(sd->status.class_)][sd->weapontype2])*7/10; // dual-wield
// percentual delay reduction from stats
amotion -= amotion * (4*status->agi + status->dex)/1000;
@@ -1882,17 +1902,18 @@ static unsigned short status_base_atk(const struct block_list *bl, const struct
str += dstr*dstr;
if (bl->type == BL_PC)
#ifdef RENEWAL
- str = (rstr*10 + dex*10/5 + status->luk*10/3 + ((TBL_PC*)bl)->status.base_level*10/4)/10;
+ str = (int)(rstr + (float)dex/5 + (float)status->luk/3 + (float)((TBL_PC*)bl)->status.base_level/4);
+ else if(bl->type == BL_MOB)
+ str = rstr + ((TBL_MOB*)bl)->level;
#else
str+= dex/5 + status->luk/5;
#endif
return cap_value(str, 0, USHRT_MAX);
}
-#ifndef RENEWAL
static inline unsigned short status_base_matk_min(const struct status_data* status){ return status->int_+(status->int_/7)*(status->int_/7); }
static inline unsigned short status_base_matk_max(const struct status_data* status){ return status->int_+(status->int_/5)*(status->int_/5); }
-#else
+#ifdef RENEWAL
unsigned short status_base_matk(const struct status_data* status, int level){ return status->int_+(status->int_/2)+(status->dex/5)+(status->luk/3)+(level/4); }
#endif
@@ -1907,11 +1928,11 @@ void status_calc_misc(struct block_list *bl, struct status_data *status, int lev
status->cri = status->flee2 = 0;
#ifdef RENEWAL // renewal formulas
- status->matk_min = status->matk_max = status_base_matk(status, level);
- status->hit += level + status->dex + status->luk/3 + 175; //base level + ( every 1 dex = +1 hit ) + (every 3 luk = +1 hit) + 175
- status->flee += level + status->agi + status->luk/5 + 100; //base level + ( every 1 agi = +1 flee ) + (every 5 luk = +1 flee) + 100
- status->def2 += (int)(((float)level + status->vit)/2 + ((float)status->agi/5)); //base level + (every 2 vit = +1 def) + (every 5 agi = +1 def)
- status->mdef2 += (int)(status->int_ + ((float)level/4) + ((float)status->dex/5) + ((float)status->vit/5)); //(every 4 base level = +1 mdef) + (every 1 int = +1 mdef) + (every 5 dex = +1 mdef) + (every 5 vit = +1 mdef)
+ status->matk_min = status->matk_max = bl->type == BL_PC ? status_base_matk(status, level) : level + status->int_;
+ status->hit += level + status->dex + (bl->type == BL_PC ? status->luk/3 + 175 : 150); //base level + ( every 1 dex = +1 hit ) + (every 3 luk = +1 hit) + 175
+ status->flee += level + status->agi + (bl->type == BL_PC ? status->luk/5 : 0) + 100; //base level + ( every 1 agi = +1 flee ) + (every 5 luk = +1 flee) + 100
+ status->def2 += (int)(((float)level + status->vit)/2 + ( bl->type == BL_PC ? ((float)status->agi/5) : 0 )); //base level + (every 2 vit = +1 def) + (every 5 agi = +1 def)
+ status->mdef2 += (int)( bl->type == BL_PC ?(status->int_ + ((float)level/4) + ((float)(status->dex+status->vit)/5)):((float)(status->int_ + level)/4)); //(every 4 base level = +1 mdef) + (every 1 int = +1 mdef) + (every 5 dex = +1 mdef) + (every 5 vit = +1 mdef)
#else
status->matk_min = status_base_matk_min(status);
status->matk_max = status_base_matk_max(status);
@@ -1947,6 +1968,13 @@ void status_calc_misc(struct block_list *bl, struct status_data *status, int lev
case BL_PC:
//Players don't have a critical adjustment setting as of yet.
break;
+ case BL_MER:
+#ifdef RENEWAL
+ status->matk_min = status->matk_max = status_base_matk_max(status);
+ status->def2 = status->vit + level / 10 + status->vit / 5;
+ status->mdef2 = level / 10 + status->int_ / 5;
+#endif
+ break;
default:
if(battle_config.critical_rate != 100)
status->cri = status->cri*battle_config.critical_rate/100;
@@ -2008,7 +2036,7 @@ int status_calc_mob_(struct mob_data* md, bool first)
memcpy(status, &md->db->status, sizeof(struct status_data));
if (flag&(8|16))
- mbl = map_id2bl(md->master_id);
+ mbl = iMap->id2bl(md->master_id);
if (flag&8 && mbl) {
struct status_data *mstatus = status_get_base_status(mbl);
@@ -2030,7 +2058,7 @@ int status_calc_mob_(struct mob_data* md, bool first)
if (ud->skill_id == AM_SPHEREMINE) {
status->max_hp = 2000 + 400*ud->skill_lv;
} else if(ud->skill_id == KO_ZANZOU){
- status->max_hp = 3000 + 3000 * ud->skill_lv;
+ status->max_hp = 3000 + 3000 * ud->skill_lv + status_get_max_sp(battle->get_master(mbl));
} else { //AM_CANNIBALIZE
status->max_hp = 1500 + 200*ud->skill_lv + 10*status_get_lv(mbl);
status->mode|= MD_CANATTACK|MD_AGGRESSIVE;
@@ -2222,12 +2250,12 @@ static void status_calc_sigma(void)
/// f(x) = 35 + x*(A + B*C/D) + sum(i=2..x){ i*C/D }
static unsigned int status_base_pc_maxhp(struct map_session_data* sd, struct status_data* status)
{
- uint64 val = pc_class2idx(sd->status.class_);
+ uint64 val = pc->class2idx(sd->status.class_);
val = 35 + sd->status.base_level*(int64)hp_coefficient2[val]/100 + hp_sigma_val[val][sd->status.base_level];
if((sd->class_&MAPID_UPPERMASK) == MAPID_NINJA || (sd->class_&MAPID_UPPERMASK) == MAPID_GUNSLINGER)
val += 100; //Since their HP can't be approximated well enough without this.
- if((sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc_famerank(sd->status.char_id, MAPID_TAEKWON))
+ if((sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON))
val *= 3; //Triple max HP for top ranking Taekwons over level 90.
if((sd->class_&MAPID_UPPERMASK) == MAPID_SUPER_NOVICE && sd->status.base_level >= 99)
val += 2000; //Supernovice lvl99 hp bonus.
@@ -2245,14 +2273,14 @@ static unsigned int status_base_pc_maxsp(struct map_session_data* sd, struct sta
{
uint64 val;
- val = 10 + sd->status.base_level*(int64)sp_coefficient[pc_class2idx(sd->status.class_)]/100;
+ val = 10 + sd->status.base_level*(int64)sp_coefficient[pc->class2idx(sd->status.class_)]/100;
val += val * status->int_/100;
if (sd->class_&JOBL_UPPER)
val += val * 25/100;
else if (sd->class_&JOBL_BABY)
val -= val * 30/100;
- if ((sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc_famerank(sd->status.char_id, MAPID_TAEKWON))
+ if ((sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON))
val *= 3; //Triple max SP for top ranking Taekwons over level 90.
return (unsigned int)val;
@@ -2279,9 +2307,9 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
b_max_weight = sd->max_weight;
b_cart_weight_max = sd->cart_weight_max;
- pc_calc_skilltree(sd); // SkillTree calculation
+ pc->calc_skilltree(sd); // SkillTree calculation
- sd->max_weight = max_weight_base[pc_class2idx(sd->status.class_)]+sd->status.str*300;
+ sd->max_weight = max_weight_base[pc->class2idx(sd->status.class_)]+sd->status.str*300;
if(first) {
//Load Hp/SP from char-received data.
@@ -2343,7 +2371,6 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
+ sizeof(sd->expaddrace)
+ sizeof(sd->ignore_mdef)
+ sizeof(sd->ignore_def)
- + sizeof(sd->itemgrouphealrate)
+ sizeof(sd->sp_gain_race)
+ sizeof(sd->sp_gain_race_attack)
+ sizeof(sd->hp_gain_race_attack)
@@ -2352,8 +2379,8 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
memset (&sd->right_weapon.overrefine, 0, sizeof(sd->right_weapon) - sizeof(sd->right_weapon.atkmods));
memset (&sd->left_weapon.overrefine, 0, sizeof(sd->left_weapon) - sizeof(sd->left_weapon.atkmods));
- if (sd->special_state.intravision && !sd->sc.data[SC_INTRAVISION]) //Clear intravision as long as nothing else is using it
- clif->sc_end(&sd->bl,sd->bl.id,SELF,SI_INTRAVISION);
+ if (sd->special_state.intravision && !sd->sc.data[SC_CLAIRVOYANCE]) //Clear intravision as long as nothing else is using it
+ clif->sc_end(&sd->bl,sd->bl.id,SELF,SI_CLAIRVOYANCE);
memset(&sd->special_state,0,sizeof(sd->special_state));
memset(&status->max_hp, 0, sizeof(struct status_data)-(sizeof(status->hp)+sizeof(status->sp)));
@@ -2365,7 +2392,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
status->mode = MD_MASK&~(MD_BOSS|MD_PLANT|MD_DETECTOR|MD_ANGRY|MD_TARGETWEAK);
status->size = (sd->class_&JOBL_BABY)?SZ_SMALL:SZ_MEDIUM;
- if (battle_config.character_size && pc_isriding(sd)) { //[Lupus]
+ if (battle_config.character_size && (pc_isriding(sd) || pc_isridingdragon(sd)) ) { //[Lupus]
if (sd->class_&JOBL_BABY) {
if (battle_config.character_size&SZ_BIG)
status->size++;
@@ -2410,9 +2437,9 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
memset (&sd->bonus, 0,sizeof(sd->bonus));
// Autobonus
- pc_delautobonus(sd,sd->autobonus,ARRAYLENGTH(sd->autobonus),true);
- pc_delautobonus(sd,sd->autobonus2,ARRAYLENGTH(sd->autobonus2),true);
- pc_delautobonus(sd,sd->autobonus3,ARRAYLENGTH(sd->autobonus3),true);
+ pc->delautobonus(sd,sd->autobonus,ARRAYLENGTH(sd->autobonus),true);
+ pc->delautobonus(sd,sd->autobonus2,ARRAYLENGTH(sd->autobonus2),true);
+ pc->delautobonus(sd,sd->autobonus3,ARRAYLENGTH(sd->autobonus3),true);
// Parse equipment.
for(i=0;i<EQI_MAX-1;i++) {
@@ -2474,7 +2501,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
#ifdef RENEWAL
wa->matk += sd->inventory_data[index]->matk;
wa->wlv = wlv;
- if( r ) // renewal magic attack refine bonus
+ if( r && sd->weapontype1 != W_BOW ) // renewal magic attack refine bonus
wa->matk += refine_info[wlv].bonus[r-1] / 100;
#endif
@@ -2498,7 +2525,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
{ // Forged weapon
wd->star += (sd->status.inventory[index].card[1]>>8);
if(wd->star >= 15) wd->star = 40; // 3 Star Crumbs now give +40 dmg
- if(pc_famerank(MakeDWord(sd->status.inventory[index].card[2],sd->status.inventory[index].card[3]) ,MAPID_BLACKSMITH))
+ if(pc->famerank(MakeDWord(sd->status.inventory[index].card[2],sd->status.inventory[index].card[3]) ,MAPID_BLACKSMITH))
wd->star += 10;
if (!wa->ele) //Do not overwrite element from previous bonuses.
@@ -2572,19 +2599,12 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
current_equip_card_id= c= sd->status.inventory[index].card[j];
if(!c)
continue;
- data = itemdb_exists(c);
+ data = itemdb->exists(c);
if(!data)
continue;
- if(first && data->equip_script) {//Execute equip-script on login
- run_script(data->equip_script,0,sd->bl.id,0);
- if (!calculating)
- return 1;
- }
- if(!data->script)
- continue;
for(k = 0; k < map[sd->bl.m].zone->disabled_items_count; k++) {
- if( map[sd->bl.m].zone->disabled_items[k] == sd->inventory_data[index]->nameid ) {
+ if( map[sd->bl.m].zone->disabled_items[k] == data->nameid ) {
break;
}
}
@@ -2592,6 +2612,15 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
if( k < map[sd->bl.m].zone->disabled_items_count )
continue;
+ if(first && data->equip_script) {//Execute equip-script on login
+ run_script(data->equip_script,0,sd->bl.id,0);
+ if (!calculating)
+ return 1;
+ }
+
+ if(!data->script)
+ continue;
+
if(i == EQI_HAND_L && sd->status.inventory[index].equip == EQP_HAND_L) { //Left hand status.
sd->state.lr_flag = 1;
run_script(data->script,0,sd->bl.id,0);
@@ -2604,20 +2633,18 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
}
}
- if( sc->count && sc->data[SC_ITEMSCRIPT] )
- {
- struct item_data *data = itemdb_exists(sc->data[SC_ITEMSCRIPT]->val1);
+ if( sc->count && sc->data[SC_ITEMSCRIPT] ) {
+ struct item_data *data = itemdb->exists(sc->data[SC_ITEMSCRIPT]->val1);
if( data && data->script )
run_script(data->script,0,sd->bl.id,0);
}
- if( sd->pd )
- { // Pet Bonus
+ if( sd->pd ) { // Pet Bonus
struct pet_data *pd = sd->pd;
if( pd && pd->petDB && pd->petDB->equip_script && pd->pet.intimate >= battle_config.pet_equip_min_friendly )
run_script(pd->petDB->equip_script,0,sd->bl.id,0);
if( pd && pd->pet.intimate > 0 && (!battle_config.pet_equip_required || pd->pet.equip > 0) && pd->state.skillbonus == 1 && pd->bonus )
- pc_bonus(sd,pd->bonus->type, pd->bonus->val);
+ pc->bonus(sd,pd->bonus->type, pd->bonus->val);
}
//param_bonus now holds card bonuses.
@@ -2638,7 +2665,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
sd->left_weapon.atkmods[1] = atkmods[1][sd->weapontype2];
sd->left_weapon.atkmods[2] = atkmods[2][sd->weapontype2];
- if(pc_isriding(sd) &&
+ if( (pc_isriding(sd) || pc_isridingdragon(sd)) &&
(sd->status.weapon==W_1HSPEAR || sd->status.weapon==W_2HSPEAR))
{ //When Riding with spear, damage modifier to mid-class becomes
//same as versus large size.
@@ -2649,7 +2676,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
// ----- STATS CALCULATION -----
// Job bonuses
- index = pc_class2idx(sd->status.class_);
+ index = pc->class2idx(sd->status.class_);
for(i=0;i<(int)sd->status.job_level && i<MAX_LEVEL;i++){
if(!job_bonus[index][i])
continue;
@@ -2674,13 +2701,13 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
}
// Absolute modifiers from passive skills
- if(pc_checkskill(sd,BS_HILTBINDING)>0)
+ if(pc->checkskill(sd,BS_HILTBINDING)>0)
status->str++;
- if((skill=pc_checkskill(sd,SA_DRAGONOLOGY))>0)
+ if((skill=pc->checkskill(sd,SA_DRAGONOLOGY))>0)
status->int_ += (skill+1)/2; // +1 INT / 2 lv
- if((skill=pc_checkskill(sd,AC_OWL))>0)
+ if((skill=pc->checkskill(sd,AC_OWL))>0)
status->dex += skill;
- if((skill = pc_checkskill(sd,RA_RESEARCHTRAP))>0)
+ if((skill = pc->checkskill(sd,RA_RESEARCHTRAP))>0)
status->int_ += skill;
// Bonuses from cards and equipment as well as base stat, remember to avoid overflows.
@@ -2704,8 +2731,10 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
if (sd->status.weapon < MAX_WEAPON_TYPE && sd->weapon_atk[sd->status.weapon])
status->batk += sd->weapon_atk[sd->status.weapon];
// Absolute modifiers from passive skills
- if((skill=pc_checkskill(sd,BS_HILTBINDING))>0)
+#ifndef RENEWAL
+ if((skill=pc->checkskill(sd,BS_HILTBINDING))>0) // it doesn't work in RE.
status->batk += 4;
+#endif
// ----- HP MAX CALCULATION -----
@@ -2717,7 +2746,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
status->max_hp = (unsigned int)cap_value(i64, 0, INT_MAX);
// Absolute modifiers from passive skills
- if((skill=pc_checkskill(sd,CR_TRUST))>0)
+ if((skill=pc->checkskill(sd,CR_TRUST))>0)
status->max_hp += skill*200;
// Apply relative modifiers from equipment
@@ -2742,15 +2771,15 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
status->max_sp = (unsigned int)cap_value(i64, 0, INT_MAX);
// Absolute modifiers from passive skills
- if((skill=pc_checkskill(sd,SL_KAINA))>0)
+ if((skill=pc->checkskill(sd,SL_KAINA))>0)
status->max_sp += 30*skill;
- if((skill=pc_checkskill(sd,HP_MEDITATIO))>0)
+ if((skill=pc->checkskill(sd,HP_MEDITATIO))>0)
status->max_sp += (int64)status->max_sp * skill/100;
- if((skill=pc_checkskill(sd,HW_SOULDRAIN))>0)
+ if((skill=pc->checkskill(sd,HW_SOULDRAIN))>0)
status->max_sp += (int64)status->max_sp * 2*skill/100;
- if( (skill = pc_checkskill(sd,RA_RESEARCHTRAP)) > 0 )
+ if( (skill = pc->checkskill(sd,RA_RESEARCHTRAP)) > 0 )
status->max_sp += 200 + 20 * skill;
- if( (skill = pc_checkskill(sd,WM_LESSON)) > 0 )
+ if( (skill = pc->checkskill(sd,WM_LESSON)) > 0 )
status->max_sp += 30 * skill;
@@ -2834,9 +2863,9 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
// ----- HIT CALCULATION -----
// Absolute modifiers from passive skills
- if((skill=pc_checkskill(sd,BS_WEAPONRESEARCH))>0)
+ if((skill=pc->checkskill(sd,BS_WEAPONRESEARCH))>0)
status->hit += skill*2;
- if((skill=pc_checkskill(sd,AC_VULTURE))>0){
+ if((skill=pc->checkskill(sd,AC_VULTURE))>0){
#ifndef RENEWAL
status->hit += skill;
#endif
@@ -2845,9 +2874,9 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
}
if(sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE)
{
- if((skill=pc_checkskill(sd,GS_SINGLEACTION))>0)
+ if((skill=pc->checkskill(sd,GS_SINGLEACTION))>0)
status->hit += 2*skill;
- if((skill=pc_checkskill(sd,GS_SNAKEEYE))>0) {
+ if((skill=pc->checkskill(sd,GS_SNAKEEYE))>0) {
status->hit += skill;
status->rhw.range += skill;
}
@@ -2856,9 +2885,9 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
// ----- FLEE CALCULATION -----
// Absolute modifiers from passive skills
- if((skill=pc_checkskill(sd,TF_MISS))>0)
+ if((skill=pc->checkskill(sd,TF_MISS))>0)
status->flee += skill*(sd->class_&JOBL_2 && (sd->class_&MAPID_BASEMASK) == MAPID_THIEF? 4 : 3);
- if((skill=pc_checkskill(sd,MO_DODGE))>0)
+ if((skill=pc->checkskill(sd,MO_DODGE))>0)
status->flee += (skill*3)>>1;
// ----- EQUIPMENT-DEF CALCULATION -----
@@ -2905,29 +2934,29 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
// Relative modifiers from passive skills
#ifndef RENEWAL_ASPD
- if((skill=pc_checkskill(sd,SA_ADVANCEDBOOK))>0 && sd->status.weapon == W_BOOK)
+ if((skill=pc->checkskill(sd,SA_ADVANCEDBOOK))>0 && sd->status.weapon == W_BOOK)
status->aspd_rate -= 5*skill;
- if((skill = pc_checkskill(sd,SG_DEVIL)) > 0 && !pc_nextjobexp(sd))
+ if((skill = pc->checkskill(sd,SG_DEVIL)) > 0 && !pc->nextjobexp(sd))
status->aspd_rate -= 30*skill;
- if((skill=pc_checkskill(sd,GS_SINGLEACTION))>0 &&
+ if((skill=pc->checkskill(sd,GS_SINGLEACTION))>0 &&
(sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE))
status->aspd_rate -= ((skill+1)/2) * 10;
if(pc_isriding(sd))
- status->aspd_rate += 500-100*pc_checkskill(sd,KN_CAVALIERMASTERY);
+ status->aspd_rate += 500-100*pc->checkskill(sd,KN_CAVALIERMASTERY);
else if(pc_isridingdragon(sd))
- status->aspd_rate += 250-50*pc_checkskill(sd,RK_DRAGONTRAINING);
+ status->aspd_rate += 250-50*pc->checkskill(sd,RK_DRAGONTRAINING);
#else // needs more info
- if((skill=pc_checkskill(sd,SA_ADVANCEDBOOK))>0 && sd->status.weapon == W_BOOK)
+ if((skill=pc->checkskill(sd,SA_ADVANCEDBOOK))>0 && sd->status.weapon == W_BOOK)
status->aspd_rate += 5*skill;
- if((skill = pc_checkskill(sd,SG_DEVIL)) > 0 && !pc_nextjobexp(sd))
+ if((skill = pc->checkskill(sd,SG_DEVIL)) > 0 && !pc->nextjobexp(sd))
status->aspd_rate += 30*skill;
- if((skill=pc_checkskill(sd,GS_SINGLEACTION))>0 &&
+ if((skill=pc->checkskill(sd,GS_SINGLEACTION))>0 &&
(sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE))
status->aspd_rate += ((skill+1)/2) * 10;
if(pc_isriding(sd))
- status->aspd_rate -= 500-100*pc_checkskill(sd,KN_CAVALIERMASTERY);
+ status->aspd_rate -= 500-100*pc->checkskill(sd,KN_CAVALIERMASTERY);
else if(pc_isridingdragon(sd))
- status->aspd_rate -= 250-50*pc_checkskill(sd,RK_DRAGONTRAINING);
+ status->aspd_rate -= 250-50*pc->checkskill(sd,RK_DRAGONTRAINING);
#endif
status->adelay = 2*status->amotion;
@@ -2942,33 +2971,33 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
// ----- MISC CALCULATIONS -----
// Weight
- if((skill=pc_checkskill(sd,MC_INCCARRY))>0)
+ if((skill=pc->checkskill(sd,MC_INCCARRY))>0)
sd->max_weight += 2000*skill;
- if(pc_isriding(sd) && pc_checkskill(sd,KN_RIDING)>0)
+ if(pc_isriding(sd) && pc->checkskill(sd,KN_RIDING)>0)
sd->max_weight += 10000;
else if(pc_isridingdragon(sd))
- sd->max_weight += 5000+2000*pc_checkskill(sd,RK_DRAGONTRAINING);
+ sd->max_weight += 5000+2000*pc->checkskill(sd,RK_DRAGONTRAINING);
if(sc->data[SC_KNOWLEDGE])
sd->max_weight += sd->max_weight*sc->data[SC_KNOWLEDGE]->val1/10;
- if((skill=pc_checkskill(sd,ALL_INCCARRY))>0)
+ if((skill=pc->checkskill(sd,ALL_INCCARRY))>0)
sd->max_weight += 2000*skill;
- sd->cart_weight_max = battle_config.max_cart_weight + (pc_checkskill(sd, GN_REMODELING_CART)*5000);
+ sd->cart_weight_max = battle_config.max_cart_weight + (pc->checkskill(sd, GN_REMODELING_CART)*5000);
- if (pc_checkskill(sd,SM_MOVINGRECOVERY)>0)
+ if (pc->checkskill(sd,SM_MOVINGRECOVERY)>0)
sd->regen.state.walk = 1;
else
sd->regen.state.walk = 0;
// Skill SP cost
- if((skill=pc_checkskill(sd,HP_MANARECHARGE))>0 )
+ if((skill=pc->checkskill(sd,HP_MANARECHARGE))>0 )
sd->dsprate -= 4*skill;
- if(sc->data[SC_SERVICE4U])
- sd->dsprate -= sc->data[SC_SERVICE4U]->val3;
+ if(sc->data[SC_SERVICEFORYOU])
+ sd->dsprate -= sc->data[SC_SERVICEFORYOU]->val3;
- if(sc->data[SC_SPCOST_RATE])
- sd->dsprate -= sc->data[SC_SPCOST_RATE]->val1;
+ if(sc->data[SC_ATKER_BLOOD])
+ sd->dsprate -= sc->data[SC_ATKER_BLOOD]->val1;
//Underflow protections.
if(sd->dsprate < 0)
@@ -2983,17 +3012,17 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
sd->sprecov_rate = 0;
// Anti-element and anti-race
- if((skill=pc_checkskill(sd,CR_TRUST))>0)
+ if((skill=pc->checkskill(sd,CR_TRUST))>0)
sd->subele[ELE_HOLY] += skill*5;
- if((skill=pc_checkskill(sd,BS_SKINTEMPER))>0) {
+ if((skill=pc->checkskill(sd,BS_SKINTEMPER))>0) {
sd->subele[ELE_NEUTRAL] += skill;
sd->subele[ELE_FIRE] += skill*4;
}
- if((skill=pc_checkskill(sd,NC_RESEARCHFE))>0) {
+ if((skill=pc->checkskill(sd,NC_RESEARCHFE))>0) {
sd->subele[ELE_EARTH] += skill*10;
sd->subele[ELE_FIRE] += skill*10;
}
- if((skill=pc_checkskill(sd,SA_DRAGONOLOGY))>0 ){
+ if((skill=pc->checkskill(sd,SA_DRAGONOLOGY))>0 ){
skill = skill*4;
sd->right_weapon.addrace[RC_DRAGON]+=skill;
sd->left_weapon.addrace[RC_DRAGON]+=skill;
@@ -3002,9 +3031,9 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
}
if(sc->count){
- if(sc->data[SC_CONCENTRATE]) { //Update the card-bonus data
- sc->data[SC_CONCENTRATE]->val3 = sd->param_bonus[1]; //Agi
- sc->data[SC_CONCENTRATE]->val4 = sd->param_bonus[4]; //Dex
+ if(sc->data[SC_CONCENTRATION]) { //Update the card-bonus data
+ sc->data[SC_CONCENTRATION]->val3 = sd->param_bonus[1]; //Agi
+ sc->data[SC_CONCENTRATION]->val4 = sd->param_bonus[4]; //Dex
}
if(sc->data[SC_SIEGFRIED]){
i = sc->data[SC_SIEGFRIED]->val2;
@@ -3022,11 +3051,11 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
sd->subele[ELE_HOLY] += sc->data[SC_PROVIDENCE]->val2;
sd->subrace[RC_DEMON] += sc->data[SC_PROVIDENCE]->val2;
}
- if(sc->data[SC_ARMOR_ELEMENT]) { //This status change should grant card-type elemental resist.
- sd->subele[ELE_WATER] += sc->data[SC_ARMOR_ELEMENT]->val1;
- sd->subele[ELE_EARTH] += sc->data[SC_ARMOR_ELEMENT]->val2;
- sd->subele[ELE_FIRE] += sc->data[SC_ARMOR_ELEMENT]->val3;
- sd->subele[ELE_WIND] += sc->data[SC_ARMOR_ELEMENT]->val4;
+ if(sc->data[SC_ARMORPROPERTY]) { //This status change should grant card-type elemental resist.
+ sd->subele[ELE_WATER] += sc->data[SC_ARMORPROPERTY]->val1;
+ sd->subele[ELE_EARTH] += sc->data[SC_ARMORPROPERTY]->val2;
+ sd->subele[ELE_FIRE] += sc->data[SC_ARMORPROPERTY]->val3;
+ sd->subele[ELE_WIND] += sc->data[SC_ARMORPROPERTY]->val4;
}
if(sc->data[SC_ARMOR_RESIST]) { // Undead Scroll
sd->subele[ELE_WATER] += sc->data[SC_ARMOR_RESIST]->val1;
@@ -3077,7 +3106,7 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
clif->updatestatus(sd,SP_WEIGHT);
if(b_max_weight != sd->max_weight) {
clif->updatestatus(sd,SP_MAXWEIGHT);
- pc_updateweightstatus(sd);
+ pc->updateweightstatus(sd);
}
if( b_cart_weight_max != sd->cart_weight_max ) {
clif->updatestatus(sd,SP_CARTINFO);
@@ -3266,17 +3295,13 @@ static unsigned short status_calc_vit(struct block_list *,struct status_change *
static unsigned short status_calc_int(struct block_list *,struct status_change *,int);
static unsigned short status_calc_dex(struct block_list *,struct status_change *,int);
static unsigned short status_calc_luk(struct block_list *,struct status_change *,int);
-static unsigned short status_calc_batk(struct block_list *,struct status_change *,int);
-static unsigned short status_calc_watk(struct block_list *,struct status_change *,int);
-static unsigned short status_calc_matk(struct block_list *,struct status_change *,int);
-static signed short status_calc_hit(struct block_list *,struct status_change *,int);
-static signed short status_calc_critical(struct block_list *,struct status_change *,int);
-static signed short status_calc_flee(struct block_list *,struct status_change *,int);
-static signed short status_calc_flee2(struct block_list *,struct status_change *,int);
-static defType status_calc_def(struct block_list *bl, struct status_change *sc, int);
-static signed short status_calc_def2(struct block_list *,struct status_change *,int);
-static defType status_calc_mdef(struct block_list *bl, struct status_change *sc, int);
-static signed short status_calc_mdef2(struct block_list *,struct status_change *,int);
+static unsigned short status_calc_batk(struct block_list *,struct status_change *,int,bool);
+static unsigned short status_calc_watk(struct block_list *,struct status_change *,int,bool);
+static unsigned short status_calc_matk(struct block_list *,struct status_change *,int,bool);
+static signed short status_calc_hit(struct block_list *,struct status_change *,int,bool);
+static signed short status_calc_critical(struct block_list *,struct status_change *,int,bool);
+static signed short status_calc_flee(struct block_list *,struct status_change *,int,bool);
+static signed short status_calc_flee2(struct block_list *,struct status_change *,int,bool);
static unsigned short status_calc_speed(struct block_list *,struct status_change *,int);
static short status_calc_aspd_rate(struct block_list *,struct status_change *,int);
static unsigned short status_calc_dmotion(struct block_list *bl, struct status_change *sc, int dmotion);
@@ -3324,7 +3349,7 @@ void status_calc_regen(struct block_list *bl, struct status_data *status, struct
if( sd )
{
struct regen_data_sub *sregen;
- if( (skill=pc_checkskill(sd,HP_MEDITATIO)) > 0 )
+ if( (skill=pc->checkskill(sd,HP_MEDITATIO)) > 0 )
{
val = regen->sp*(100+3*skill)/100;
regen->sp = cap_value(val, 1, SHRT_MAX);
@@ -3333,16 +3358,16 @@ void status_calc_regen(struct block_list *bl, struct status_data *status, struct
sregen = regen->sregen;
val = 0;
- if( (skill=pc_checkskill(sd,SM_RECOVERY)) > 0 )
+ if( (skill=pc->checkskill(sd,SM_RECOVERY)) > 0 )
val += skill*5 + skill*status->max_hp/500;
sregen->hp = cap_value(val, 0, SHRT_MAX);
val = 0;
- if( (skill=pc_checkskill(sd,MG_SRECOVERY)) > 0 )
+ if( (skill=pc->checkskill(sd,MG_SRECOVERY)) > 0 )
val += skill*3 + skill*status->max_sp/500;
- if( (skill=pc_checkskill(sd,NJ_NINPOU)) > 0 )
+ if( (skill=pc->checkskill(sd,NJ_NINPOU)) > 0 )
val += skill*3 + skill*status->max_sp/500;
- if( (skill=pc_checkskill(sd,WM_LESSON)) > 0 )
+ if( (skill=pc->checkskill(sd,WM_LESSON)) > 0 )
val += 3 + 3 * skill;
sregen->sp = cap_value(val, 0, SHRT_MAX);
@@ -3351,21 +3376,21 @@ void status_calc_regen(struct block_list *bl, struct status_data *status, struct
sregen = regen->ssregen;
val = 0;
- if( (skill=pc_checkskill(sd,MO_SPIRITSRECOVERY)) > 0 )
+ if( (skill=pc->checkskill(sd,MO_SPIRITSRECOVERY)) > 0 )
val += skill*4 + skill*status->max_hp/500;
- if( (skill=pc_checkskill(sd,TK_HPTIME)) > 0 && sd->state.rest )
+ if( (skill=pc->checkskill(sd,TK_HPTIME)) > 0 && sd->state.rest )
val += skill*30 + skill*status->max_hp/500;
sregen->hp = cap_value(val, 0, SHRT_MAX);
val = 0;
- if( (skill=pc_checkskill(sd,TK_SPTIME)) > 0 && sd->state.rest )
+ if( (skill=pc->checkskill(sd,TK_SPTIME)) > 0 && sd->state.rest )
{
val += skill*3 + skill*status->max_sp/500;
- if ((skill=pc_checkskill(sd,SL_KAINA)) > 0) //Power up Enjoyable Rest
+ if ((skill=pc->checkskill(sd,SL_KAINA)) > 0) //Power up Enjoyable Rest
val += (30+10*skill)*val/100;
}
- if( (skill=pc_checkskill(sd,MO_SPIRITSRECOVERY)) > 0 )
+ if( (skill=pc->checkskill(sd,MO_SPIRITSRECOVERY)) > 0 )
val += skill*2 + skill*status->max_sp/500;
sregen->sp = cap_value(val, 0, SHRT_MAX);
}
@@ -3430,18 +3455,18 @@ void status_calc_regen_rate(struct block_list *bl, struct regen_data *regen, str
|| (sc->data[SC_DPOISON] && !sc->data[SC_SLOWPOISON])
|| sc->data[SC_BERSERK] || sc->data[SC__BLOODYLUST]
|| sc->data[SC_TRICKDEAD]
- || sc->data[SC_BLEEDING]
+ || sc->data[SC_BLOODING]
|| sc->data[SC_MAGICMUSHROOM]
|| sc->data[SC_RAISINGDRAGON]
- || sc->data[SC_SATURDAYNIGHTFEVER]
+ || sc->data[SC_SATURDAY_NIGHT_FEVER]
) //No regen
regen->flag = 0;
if (
- sc->data[SC_DANCING] || sc->data[SC_OBLIVIONCURSE] || sc->data[SC_MAXIMIZEPOWER]
+ sc->data[SC_DANCING] || sc->data[SC_OBLIVIONCURSE] || sc->data[SC_MAXIMIZEPOWER] || sc->data[SC_REBOUND]
|| (
(bl->type == BL_PC && ((TBL_PC*)bl)->class_&MAPID_UPPERMASK) == MAPID_MONK &&
- (sc->data[SC_EXTREMITYFIST] || (sc->data[SC_EXPLOSIONSPIRITS] && (!sc->data[SC_SPIRIT] || sc->data[SC_SPIRIT]->val2 != SL_MONK)))
+ (sc->data[SC_EXTREMITYFIST] || (sc->data[SC_EXPLOSIONSPIRITS] && (!sc->data[SC_SOULLINK] || sc->data[SC_SOULLINK]->val2 != SL_MONK)))
)
) //No natural SP regen
regen->flag &=~RGN_SP;
@@ -3458,9 +3483,9 @@ void status_calc_regen_rate(struct block_list *bl, struct regen_data *regen, str
regen->rate.hp += 1;
regen->rate.sp += 1;
}
- if (sc->data[SC_REGENERATION])
+ if (sc->data[SC_GDSKILL_REGENERATION])
{
- const struct status_change_entry *sce = sc->data[SC_REGENERATION];
+ const struct status_change_entry *sce = sc->data[SC_GDSKILL_REGENERATION];
if (!sce->val4)
{
regen->rate.hp += sce->val2;
@@ -3468,8 +3493,8 @@ void status_calc_regen_rate(struct block_list *bl, struct regen_data *regen, str
} else
regen->flag&=~sce->val4; //Remove regen as specified by val4
}
- if(sc->data[SC_GT_REVITALIZE]){
- regen->hp = cap_value(regen->hp*sc->data[SC_GT_REVITALIZE]->val3/100, 1, SHRT_MAX);
+ if(sc->data[SC_GENTLETOUCH_REVITALIZE]){
+ regen->hp = cap_value(regen->hp*sc->data[SC_GENTLETOUCH_REVITALIZE]->val3/100, 1, SHRT_MAX);
regen->state.walk= 1;
}
if ((sc->data[SC_FIRE_INSIGNIA] && sc->data[SC_FIRE_INSIGNIA]->val1 == 1) //if insignia lvl 1
@@ -3563,23 +3588,22 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
temp += status->batk;
status->batk = cap_value(temp, 0, USHRT_MAX);
}
- status->batk = status_calc_batk(bl, sc, status->batk);
+ status->batk = status_calc_batk(bl, sc, status->batk, true);
}
- if(flag&SCB_WATK) {
-
- status->rhw.atk = status_calc_watk(bl, sc, b_status->rhw.atk);
+ if(flag&SCB_WATK) {
+ status->rhw.atk = status_calc_watk(bl, sc, b_status->rhw.atk, true);
if (!sd) //Should not affect weapon refine bonus
- status->rhw.atk2 = status_calc_watk(bl, sc, b_status->rhw.atk2);
+ status->rhw.atk2 = status_calc_watk(bl, sc, b_status->rhw.atk2, true);
if(b_status->lhw.atk) {
if (sd) {
sd->state.lr_flag = 1;
- status->lhw.atk = status_calc_watk(bl, sc, b_status->lhw.atk);
+ status->lhw.atk = status_calc_watk(bl, sc, b_status->lhw.atk, true);
sd->state.lr_flag = 0;
} else {
- status->lhw.atk = status_calc_watk(bl, sc, b_status->lhw.atk);
- status->lhw.atk2= status_calc_watk(bl, sc, b_status->lhw.atk2);
+ status->lhw.atk = status_calc_watk(bl, sc, b_status->lhw.atk, true);
+ status->lhw.atk2 = status_calc_watk(bl, sc, b_status->lhw.atk2, true);
}
}
@@ -3598,13 +3622,13 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
&& status->luk == b_status->luk
#endif
)
- status->hit = status_calc_hit(bl, sc, b_status->hit);
+ status->hit = status_calc_hit(bl, sc, b_status->hit, true);
else
status->hit = status_calc_hit(bl, sc, b_status->hit + (status->dex - b_status->dex)
#ifdef RENEWAL
+ (status->luk/3 - b_status->luk/3)
#endif
- );
+ , true);
}
if(flag&SCB_FLEE) {
@@ -3613,18 +3637,18 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
&& status->luk == b_status->luk
#endif
)
- status->flee = status_calc_flee(bl, sc, b_status->flee);
+ status->flee = status_calc_flee(bl, sc, b_status->flee, true);
else
status->flee = status_calc_flee(bl, sc, b_status->flee +(status->agi - b_status->agi)
#ifdef RENEWAL
+ (status->luk/5 - b_status->luk/5)
#endif
- );
+ , true);
}
if(flag&SCB_DEF)
{
- status->def = status_calc_def(bl, sc, b_status->def);
+ status->def = status_calc_def(bl, sc, b_status->def, true);
if( bl->type&BL_HOM )
status->def += (status->vit/5 - b_status->vit/5);
@@ -3636,7 +3660,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
&& status->agi == b_status->agi
#endif
)
- status->def2 = status_calc_def2(bl, sc, b_status->def2);
+ status->def2 = status_calc_def2(bl, sc, b_status->def2, true);
else
status->def2 = status_calc_def2(bl, sc, b_status->def2
#ifdef RENEWAL
@@ -3644,12 +3668,12 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
#else
+ (status->vit - b_status->vit)
#endif
- );
+ , true);
}
if(flag&SCB_MDEF)
{
- status->mdef = status_calc_mdef(bl, sc, b_status->mdef);
+ status->mdef = status_calc_mdef(bl, sc, b_status->mdef, true);
if( bl->type&BL_HOM )
status->mdef += (status->int_/5 - b_status->int_/5);
@@ -3661,7 +3685,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
&& status->dex == b_status->dex
#endif
)
- status->mdef2 = status_calc_mdef2(bl, sc, b_status->mdef2);
+ status->mdef2 = status_calc_mdef2(bl, sc, b_status->mdef2, true);
else
status->mdef2 = status_calc_mdef2(bl, sc, b_status->mdef2 +(status->int_ - b_status->int_)
#ifdef RENEWAL
@@ -3669,7 +3693,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
#else
+ ((status->vit - b_status->vit)>>1)
#endif
- );
+ , true);
}
if(flag&SCB_SPEED) {
@@ -3693,9 +3717,9 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
if(flag&SCB_CRI && b_status->cri) {
if (status->luk == b_status->luk)
- status->cri = status_calc_critical(bl, sc, b_status->cri);
+ status->cri = status_calc_critical(bl, sc, b_status->cri, true);
else
- status->cri = status_calc_critical(bl, sc, b_status->cri + 3*(status->luk - b_status->luk));
+ status->cri = status_calc_critical(bl, sc, b_status->cri + 3*(status->luk - b_status->luk), true);
/**
* after status_calc_critical so the bonus is applied despite if you have or not a sc bugreport:5240
**/
@@ -3706,9 +3730,9 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
if(flag&SCB_FLEE2 && b_status->flee2) {
if (status->luk == b_status->luk)
- status->flee2 = status_calc_flee2(bl, sc, b_status->flee2);
+ status->flee2 = status_calc_flee2(bl, sc, b_status->flee2, true);
else
- status->flee2 = status_calc_flee2(bl, sc, b_status->flee2 +(status->luk - b_status->luk));
+ status->flee2 = status_calc_flee2(bl, sc, b_status->flee2 +(status->luk - b_status->luk), true);
}
if(flag&SCB_ATK_ELE) {
@@ -3784,52 +3808,8 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
}
}
- if(flag&SCB_MATK) {
-#ifndef RENEWAL
- status->matk_min = status_base_matk_min(status) + (sd?sd->bonus.ematk:0);
- status->matk_max = status_base_matk_max(status) + (sd?sd->bonus.ematk:0);
-#else
- /**
- * RE MATK Formula (from irowiki:http://irowiki.org/wiki/MATK)
- * MATK = (sMATK + wMATK + eMATK) * Multiplicative Modifiers
- **/
- status->matk_min = status->matk_max = status_base_matk(status, status_get_lv(bl));
- if( bl->type&BL_PC ){
- // Any +MATK you get from skills and cards, including cards in weapon, is added here.
- if( sd->bonus.ematk > 0 ){
- status->matk_max += sd->bonus.ematk;
- status->matk_min += sd->bonus.ematk;
- }
- status->matk_min = status_calc_ematk(bl, sc, status->matk_min);
- status->matk_max = status_calc_ematk(bl, sc, status->matk_max);
- //This is the only portion in MATK that varies depending on the weapon level and refinement rate.
- if( status->rhw.matk > 0 ){
- int wMatk = status->rhw.matk;
- int variance = wMatk * status->rhw.wlv / 10;
- status->matk_min += wMatk - variance;
- status->matk_max += wMatk + variance;
- }
- }
-#endif
- if (bl->type&BL_PC && sd->matk_rate != 100) {
- status->matk_max = status->matk_max * sd->matk_rate/100;
- status->matk_min = status->matk_min * sd->matk_rate/100;
- }
-
- status->matk_min = status_calc_matk(bl, sc, status->matk_min);
- status->matk_max = status_calc_matk(bl, sc, status->matk_max);
-
- if ((bl->type&BL_HOM && battle_config.hom_setting&0x20) //Hom Min Matk is always the same as Max Matk
- || sc->data[SC_RECOGNIZEDSPELL])
- status->matk_min = status->matk_max;
-
-#ifdef RENEWAL
- if( sd && sd->right_weapon.overrefine > 0){
- status->matk_min++;
- status->matk_max += sd->right_weapon.overrefine - 1;
- }
-#endif
-
+ if(flag&SCB_MATK) {
+ status_get_matk(bl, 0);
}
if(flag&SCB_ASPD) {
@@ -3844,11 +3824,11 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
amotion = amotion*status->aspd_rate/1000;
#else
// aspd = baseaspd + floor(sqrt((agi^2/2) + (dex^2/5))/4 + (potskillbonus*agi/200))
- amotion -= (int)(sqrt( (pow(status->agi, 2) / 2) + (pow(status->dex, 2) / 5) ) / 4 + (status_calc_aspd(bl, sc, 1) * status->agi / 200)) * 10;
+ amotion -= (int)(sqrt( (pow(status->agi, 2) / 2) + (pow(status->dex, 2) / 5) ) / 4 + ((float)status_calc_aspd(bl, sc, 1) * status->agi / 200)) * 10;
if( (status_calc_aspd(bl, sc, 2) + status->aspd_rate2) != 0 ) // RE ASPD percertage modifier
- amotion -= ( amotion - ((sd->class_&JOBL_THIRD) ? battle_config.max_third_aspd : battle_config.max_aspd) )
- * (status_calc_aspd(bl, sc, 2) + status->aspd_rate2) / 100;
+ amotion -= (( amotion - ((sd->class_&JOBL_THIRD) ? battle_config.max_third_aspd : battle_config.max_aspd) )
+ * (status_calc_aspd(bl, sc, 2) + status->aspd_rate2) / 10 + 5) / 10;
if(status->aspd_rate != 1000) // absolute percentage modifier
amotion = ( 200 - (200-amotion/10) * status->aspd_rate / 1000 ) * 10;
@@ -3890,8 +3870,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
if(flag&SCB_DSPD) {
int dmotion;
- if( bl->type&BL_PC )
- {
+ if( bl->type&BL_PC ) {
if (b_status->agi == status->agi)
status->dmotion = status_calc_dmotion(bl, sc, b_status->dmotion);
else {
@@ -3902,16 +3881,11 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
//It's safe to ignore b_status->dmotion since no bonus affects it.
status->dmotion = status_calc_dmotion(bl, sc, status->dmotion);
}
- }
- else
- if( bl->type&BL_HOM )
- {
+ } else if( bl->type&BL_HOM ) {
dmotion = 800-status->agi*4;
status->dmotion = cap_value(dmotion, 400, 800);
status->dmotion = status_calc_dmotion(bl, sc, b_status->dmotion);
- }
- else // mercenary and mobs
- {
+ } else { // mercenary and mobs
status->dmotion = status_calc_dmotion(bl, sc, b_status->dmotion);
}
}
@@ -3937,13 +3911,13 @@ void status_calc_bl_(struct block_list* bl, enum scb_flag flag, bool first)
if( flag&SCB_BASE ) {// calculate the object's base status too
switch( bl->type ) {
- case BL_PC: status_calc_pc_(BL_CAST(BL_PC,bl), first); break;
- case BL_MOB: status_calc_mob_(BL_CAST(BL_MOB,bl), first); break;
- case BL_PET: status_calc_pet_(BL_CAST(BL_PET,bl), first); break;
- case BL_HOM: status_calc_homunculus_(BL_CAST(BL_HOM,bl), first); break;
- case BL_MER: status_calc_mercenary_(BL_CAST(BL_MER,bl), first); break;
- case BL_ELEM: status_calc_elemental_(BL_CAST(BL_ELEM,bl), first); break;
- case BL_NPC: status_calc_npc_(BL_CAST(BL_NPC,bl), first); break;
+ case BL_PC: status_calc_pc_(BL_CAST(BL_PC,bl), first); break;
+ case BL_MOB: status_calc_mob_(BL_CAST(BL_MOB,bl), first); break;
+ case BL_PET: status_calc_pet_(BL_CAST(BL_PET,bl), first); break;
+ case BL_HOM: status_calc_homunculus_(BL_CAST(BL_HOM,bl), first); break;
+ case BL_MER: status_calc_mercenary_(BL_CAST(BL_MER,bl), first); break;
+ case BL_ELEM: status_calc_elemental_(BL_CAST(BL_ELEM,bl), first); break;
+ case BL_NPC: status_calc_npc_(BL_CAST(BL_NPC,bl), first); break;
}
}
@@ -4102,38 +4076,38 @@ static unsigned short status_calc_str(struct block_list *bl, struct status_chang
str -= sc->data[SC_HARMONIZE]->val2;
return (unsigned short)cap_value(str,0,USHRT_MAX);
}
- if(sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_HIGH && str < 50)
+ if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_HIGH && str < 50)
return 50;
if(sc->data[SC_INCALLSTATUS])
str += sc->data[SC_INCALLSTATUS]->val1;
- if(sc->data[SC_INCSTR])
- str += sc->data[SC_INCSTR]->val1;
- if(sc->data[SC_STRFOOD])
- str += sc->data[SC_STRFOOD]->val1;
+ if(sc->data[SC_CHASEWALK2])
+ str += sc->data[SC_CHASEWALK2]->val1;
+ if(sc->data[SC_FOOD_STR])
+ str += sc->data[SC_FOOD_STR]->val1;
if(sc->data[SC_FOOD_STR_CASH])
str += sc->data[SC_FOOD_STR_CASH]->val1;
- if(sc->data[SC_BATTLEORDERS])
+ if(sc->data[SC_GDSKILL_BATTLEORDER])
str += 5;
if(sc->data[SC_LEADERSHIP])
str += sc->data[SC_LEADERSHIP]->val1;
- if(sc->data[SC_LOUD])
+ if(sc->data[SC_SHOUT])
str += 4;
if(sc->data[SC_TRUESIGHT])
str += 5;
- if(sc->data[SC_SPURT])
+ if(sc->data[SC_STRUP])
str += 10;
- if(sc->data[SC_NEN])
- str += sc->data[SC_NEN]->val1;
+ if(sc->data[SC_NJ_NEN])
+ str += sc->data[SC_NJ_NEN]->val1;
if(sc->data[SC_BLESSING]){
if(sc->data[SC_BLESSING]->val2)
str += sc->data[SC_BLESSING]->val2;
else
str >>= 1;
}
+ if(sc->data[SC_MARIONETTE_MASTER])
+ str -= ((sc->data[SC_MARIONETTE_MASTER]->val3)>>16)&0xFF;
if(sc->data[SC_MARIONETTE])
- str -= ((sc->data[SC_MARIONETTE]->val3)>>16)&0xFF;
- if(sc->data[SC_MARIONETTE2])
- str += ((sc->data[SC_MARIONETTE2]->val3)>>16)&0xFF;
+ str += ((sc->data[SC_MARIONETTE]->val3)>>16)&0xFF;
if(sc->data[SC_GIANTGROWTH])
str += 30;
if(sc->data[SC_SAVAGE_STEAK])
@@ -4144,6 +4118,8 @@ static unsigned short status_calc_str(struct block_list *bl, struct status_chang
str -= sc->data[SC_STOMACHACHE]->val1;
if(sc->data[SC_KYOUGAKU])
str -= sc->data[SC_KYOUGAKU]->val2;
+ if(sc->data[SC_FULL_THROTTLE])
+ str += str * 20 / 100;
return (unsigned short)cap_value(str,0,USHRT_MAX);
}
@@ -4157,36 +4133,36 @@ static unsigned short status_calc_agi(struct block_list *bl, struct status_chang
agi -= sc->data[SC_HARMONIZE]->val2;
return (unsigned short)cap_value(agi,0,USHRT_MAX);
}
- if(sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_HIGH && agi < 50)
+ if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_HIGH && agi < 50)
return 50;
- if(sc->data[SC_CONCENTRATE] && !sc->data[SC_QUAGMIRE])
- agi += (agi-sc->data[SC_CONCENTRATE]->val3)*sc->data[SC_CONCENTRATE]->val2/100;
+ if(sc->data[SC_CONCENTRATION] && !sc->data[SC_QUAGMIRE])
+ agi += (agi-sc->data[SC_CONCENTRATION]->val3)*sc->data[SC_CONCENTRATION]->val2/100;
if(sc->data[SC_INCALLSTATUS])
agi += sc->data[SC_INCALLSTATUS]->val1;
if(sc->data[SC_INCAGI])
agi += sc->data[SC_INCAGI]->val1;
- if(sc->data[SC_AGIFOOD])
- agi += sc->data[SC_AGIFOOD]->val1;
+ if(sc->data[SC_FOOD_AGI])
+ agi += sc->data[SC_FOOD_AGI]->val1;
if(sc->data[SC_FOOD_AGI_CASH])
agi += sc->data[SC_FOOD_AGI_CASH]->val1;
if(sc->data[SC_SOULCOLD])
agi += sc->data[SC_SOULCOLD]->val1;
if(sc->data[SC_TRUESIGHT])
agi += 5;
- if(sc->data[SC_INCREASEAGI])
- agi += sc->data[SC_INCREASEAGI]->val2;
- if(sc->data[SC_INCREASING])
+ if(sc->data[SC_INC_AGI])
+ agi += sc->data[SC_INC_AGI]->val2;
+ if(sc->data[SC_GS_ACCURACY])
agi += 4; // added based on skill updates [Reddozen]
- if(sc->data[SC_DECREASEAGI])
- agi -= sc->data[SC_DECREASEAGI]->val2;
+ if(sc->data[SC_DEC_AGI])
+ agi -= sc->data[SC_DEC_AGI]->val2;
if(sc->data[SC_QUAGMIRE])
agi -= sc->data[SC_QUAGMIRE]->val2;
- if(sc->data[SC_SUITON] && sc->data[SC_SUITON]->val3)
- agi -= sc->data[SC_SUITON]->val2;
+ if(sc->data[SC_NJ_SUITON] && sc->data[SC_NJ_SUITON]->val3)
+ agi -= sc->data[SC_NJ_SUITON]->val2;
+ if(sc->data[SC_MARIONETTE_MASTER])
+ agi -= ((sc->data[SC_MARIONETTE_MASTER]->val3)>>8)&0xFF;
if(sc->data[SC_MARIONETTE])
- agi -= ((sc->data[SC_MARIONETTE]->val3)>>8)&0xFF;
- if(sc->data[SC_MARIONETTE2])
- agi += ((sc->data[SC_MARIONETTE2]->val3)>>8)&0xFF;
+ agi += ((sc->data[SC_MARIONETTE]->val3)>>8)&0xFF;
if(sc->data[SC_ADORAMUS])
agi -= sc->data[SC_ADORAMUS]->val2;
if(sc->data[SC_DROCERA_HERB_STEAMED])
@@ -4198,6 +4174,11 @@ static unsigned short status_calc_agi(struct block_list *bl, struct status_chang
if(sc->data[SC_KYOUGAKU])
agi -= sc->data[SC_KYOUGAKU]->val2;
+ if(sc->data[SC_MARSHOFABYSS])
+ agi -= agi * sc->data[SC_MARSHOFABYSS]->val2 / 100;
+ if(sc->data[SC_FULL_THROTTLE])
+ agi += agi * 20 / 100;
+
return (unsigned short)cap_value(agi,0,USHRT_MAX);
}
@@ -4210,26 +4191,26 @@ static unsigned short status_calc_vit(struct block_list *bl, struct status_chang
vit -= sc->data[SC_HARMONIZE]->val2;
return (unsigned short)cap_value(vit,0,USHRT_MAX);
}
- if(sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_HIGH && vit < 50)
+ if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_HIGH && vit < 50)
return 50;
if(sc->data[SC_INCALLSTATUS])
vit += sc->data[SC_INCALLSTATUS]->val1;
if(sc->data[SC_INCVIT])
vit += sc->data[SC_INCVIT]->val1;
- if(sc->data[SC_VITFOOD])
- vit += sc->data[SC_VITFOOD]->val1;
+ if(sc->data[SC_FOOD_VIT])
+ vit += sc->data[SC_FOOD_VIT]->val1;
if(sc->data[SC_FOOD_VIT_CASH])
vit += sc->data[SC_FOOD_VIT_CASH]->val1;
- if(sc->data[SC_CHANGE])
- vit += sc->data[SC_CHANGE]->val2;
+ if(sc->data[SC_HLIF_CHANGE])
+ vit += sc->data[SC_HLIF_CHANGE]->val2;
if(sc->data[SC_GLORYWOUNDS])
vit += sc->data[SC_GLORYWOUNDS]->val1;
if(sc->data[SC_TRUESIGHT])
vit += 5;
+ if(sc->data[SC_MARIONETTE_MASTER])
+ vit -= sc->data[SC_MARIONETTE_MASTER]->val3&0xFF;
if(sc->data[SC_MARIONETTE])
- vit -= sc->data[SC_MARIONETTE]->val3&0xFF;
- if(sc->data[SC_MARIONETTE2])
- vit += sc->data[SC_MARIONETTE2]->val3&0xFF;
+ vit += sc->data[SC_MARIONETTE]->val3&0xFF;
if(sc->data[SC_LAUDAAGNUS])
vit += 4 + sc->data[SC_LAUDAAGNUS]->val1;
if(sc->data[SC_MINOR_BBQ])
@@ -4241,8 +4222,10 @@ static unsigned short status_calc_vit(struct block_list *bl, struct status_chang
if(sc->data[SC_KYOUGAKU])
vit -= sc->data[SC_KYOUGAKU]->val2;
- if(sc->data[SC_STRIPARMOR])
- vit -= vit * sc->data[SC_STRIPARMOR]->val2/100;
+ if(sc->data[SC_NOEQUIPARMOR])
+ vit -= vit * sc->data[SC_NOEQUIPARMOR]->val2/100;
+ if(sc->data[SC_FULL_THROTTLE])
+ vit += vit * 20 / 100;
return (unsigned short)cap_value(vit,0,USHRT_MAX);
}
@@ -4256,19 +4239,19 @@ static unsigned short status_calc_int(struct block_list *bl, struct status_chang
int_ -= sc->data[SC_HARMONIZE]->val2;
return (unsigned short)cap_value(int_,0,USHRT_MAX);
}
- if(sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_HIGH && int_ < 50)
+ if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_HIGH && int_ < 50)
return 50;
if(sc->data[SC_INCALLSTATUS])
int_ += sc->data[SC_INCALLSTATUS]->val1;
if(sc->data[SC_INCINT])
int_ += sc->data[SC_INCINT]->val1;
- if(sc->data[SC_INTFOOD])
- int_ += sc->data[SC_INTFOOD]->val1;
+ if(sc->data[SC_FOOD_INT])
+ int_ += sc->data[SC_FOOD_INT]->val1;
if(sc->data[SC_FOOD_INT_CASH])
int_ += sc->data[SC_FOOD_INT_CASH]->val1;
- if(sc->data[SC_CHANGE])
- int_ += sc->data[SC_CHANGE]->val3;
- if(sc->data[SC_BATTLEORDERS])
+ if(sc->data[SC_HLIF_CHANGE])
+ int_ += sc->data[SC_HLIF_CHANGE]->val3;
+ if(sc->data[SC_GDSKILL_BATTLEORDER])
int_ += 5;
if(sc->data[SC_TRUESIGHT])
int_ += 5;
@@ -4278,12 +4261,12 @@ static unsigned short status_calc_int(struct block_list *bl, struct status_chang
else
int_ >>= 1;
}
- if(sc->data[SC_NEN])
- int_ += sc->data[SC_NEN]->val1;
+ if(sc->data[SC_NJ_NEN])
+ int_ += sc->data[SC_NJ_NEN]->val1;
+ if(sc->data[SC_MARIONETTE_MASTER])
+ int_ -= ((sc->data[SC_MARIONETTE_MASTER]->val4)>>16)&0xFF;
if(sc->data[SC_MARIONETTE])
- int_ -= ((sc->data[SC_MARIONETTE]->val4)>>16)&0xFF;
- if(sc->data[SC_MARIONETTE2])
- int_ += ((sc->data[SC_MARIONETTE2]->val4)>>16)&0xFF;
+ int_ += ((sc->data[SC_MARIONETTE]->val4)>>16)&0xFF;
if(sc->data[SC_MANDRAGORA])
int_ -= 5 + 5 * sc->data[SC_MANDRAGORA]->val1;
if(sc->data[SC_COCKTAIL_WARG_BLOOD])
@@ -4295,10 +4278,12 @@ static unsigned short status_calc_int(struct block_list *bl, struct status_chang
if(sc->data[SC_KYOUGAKU])
int_ -= sc->data[SC_KYOUGAKU]->val2;
- if(sc->data[SC_STRIPHELM])
- int_ -= int_ * sc->data[SC_STRIPHELM]->val2/100;
- if(sc->data[SC__STRIPACCESSORY])
- int_ -= int_ * sc->data[SC__STRIPACCESSORY]->val2 / 100;
+ if(sc->data[SC_NOEQUIPHELM])
+ int_ -= int_ * sc->data[SC_NOEQUIPHELM]->val2/100;
+ if(sc->data[SC__STRIPACCESSARY])
+ int_ -= int_ * sc->data[SC__STRIPACCESSARY]->val2 / 100;
+ if(sc->data[SC_FULL_THROTTLE])
+ int_ += int_ * 20 / 100;
return (unsigned short)cap_value(int_,0,USHRT_MAX);
}
@@ -4312,19 +4297,19 @@ static unsigned short status_calc_dex(struct block_list *bl, struct status_chang
dex -= sc->data[SC_HARMONIZE]->val2;
return (unsigned short)cap_value(dex,0,USHRT_MAX);
}
- if(sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_HIGH && dex < 50)
+ if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_HIGH && dex < 50)
return 50;
- if(sc->data[SC_CONCENTRATE] && !sc->data[SC_QUAGMIRE])
- dex += (dex-sc->data[SC_CONCENTRATE]->val4)*sc->data[SC_CONCENTRATE]->val2/100;
+ if(sc->data[SC_CONCENTRATION] && !sc->data[SC_QUAGMIRE])
+ dex += (dex-sc->data[SC_CONCENTRATION]->val4)*sc->data[SC_CONCENTRATION]->val2/100;
if(sc->data[SC_INCALLSTATUS])
dex += sc->data[SC_INCALLSTATUS]->val1;
if(sc->data[SC_INCDEX])
dex += sc->data[SC_INCDEX]->val1;
- if(sc->data[SC_DEXFOOD])
- dex += sc->data[SC_DEXFOOD]->val1;
+ if(sc->data[SC_FOOD_DEX])
+ dex += sc->data[SC_FOOD_DEX]->val1;
if(sc->data[SC_FOOD_DEX_CASH])
dex += sc->data[SC_FOOD_DEX_CASH]->val1;
- if(sc->data[SC_BATTLEORDERS])
+ if(sc->data[SC_GDSKILL_BATTLEORDER])
dex += 5;
if(sc->data[SC_HAWKEYES])
dex += sc->data[SC_HAWKEYES]->val1;
@@ -4338,12 +4323,12 @@ static unsigned short status_calc_dex(struct block_list *bl, struct status_chang
else
dex >>= 1;
}
- if(sc->data[SC_INCREASING])
+ if(sc->data[SC_GS_ACCURACY])
dex += 4; // added based on skill updates [Reddozen]
+ if(sc->data[SC_MARIONETTE_MASTER])
+ dex -= ((sc->data[SC_MARIONETTE_MASTER]->val4)>>8)&0xFF;
if(sc->data[SC_MARIONETTE])
- dex -= ((sc->data[SC_MARIONETTE]->val4)>>8)&0xFF;
- if(sc->data[SC_MARIONETTE2])
- dex += ((sc->data[SC_MARIONETTE2]->val4)>>8)&0xFF;
+ dex += ((sc->data[SC_MARIONETTE]->val4)>>8)&0xFF;
if(sc->data[SC_SIROMA_ICE_TEA])
dex += sc->data[SC_SIROMA_ICE_TEA]->val1;
if(sc->data[SC_INSPIRATION])
@@ -4353,8 +4338,12 @@ static unsigned short status_calc_dex(struct block_list *bl, struct status_chang
if(sc->data[SC_KYOUGAKU])
dex -= sc->data[SC_KYOUGAKU]->val2;
- if(sc->data[SC__STRIPACCESSORY])
- dex -= dex * sc->data[SC__STRIPACCESSORY]->val2 / 100;
+ if(sc->data[SC_MARSHOFABYSS])
+ dex -= dex * sc->data[SC_MARSHOFABYSS]->val2 / 100;
+ if(sc->data[SC__STRIPACCESSARY])
+ dex -= dex * sc->data[SC__STRIPACCESSARY]->val2 / 100;
+ if(sc->data[SC_FULL_THROTTLE])
+ dex += dex * 20 / 100;
return (unsigned short)cap_value(dex,0,USHRT_MAX);
}
@@ -4370,24 +4359,24 @@ static unsigned short status_calc_luk(struct block_list *bl, struct status_chang
}
if(sc->data[SC_CURSE])
return 0;
- if(sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_HIGH && luk < 50)
+ if(sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_HIGH && luk < 50)
return 50;
if(sc->data[SC_INCALLSTATUS])
luk += sc->data[SC_INCALLSTATUS]->val1;
if(sc->data[SC_INCLUK])
luk += sc->data[SC_INCLUK]->val1;
- if(sc->data[SC_LUKFOOD])
- luk += sc->data[SC_LUKFOOD]->val1;
+ if(sc->data[SC_FOOD_LUK])
+ luk += sc->data[SC_FOOD_LUK]->val1;
if(sc->data[SC_FOOD_LUK_CASH])
luk += sc->data[SC_FOOD_LUK_CASH]->val1;
if(sc->data[SC_TRUESIGHT])
luk += 5;
if(sc->data[SC_GLORIA])
luk += 30;
+ if(sc->data[SC_MARIONETTE_MASTER])
+ luk -= sc->data[SC_MARIONETTE_MASTER]->val4&0xFF;
if(sc->data[SC_MARIONETTE])
- luk -= sc->data[SC_MARIONETTE]->val4&0xFF;
- if(sc->data[SC_MARIONETTE2])
- luk += sc->data[SC_MARIONETTE2]->val4&0xFF;
+ luk += sc->data[SC_MARIONETTE]->val4&0xFF;
if(sc->data[SC_PUTTI_TAILS_NOODLES])
luk += sc->data[SC_PUTTI_TAILS_NOODLES]->val1;
if(sc->data[SC_INSPIRATION])
@@ -4399,26 +4388,33 @@ static unsigned short status_calc_luk(struct block_list *bl, struct status_chang
if(sc->data[SC_LAUDARAMUS])
luk += 4 + sc->data[SC_LAUDARAMUS]->val1;
- if(sc->data[SC__STRIPACCESSORY])
- luk -= luk * sc->data[SC__STRIPACCESSORY]->val2 / 100;
+ if(sc->data[SC__STRIPACCESSARY])
+ luk -= luk * sc->data[SC__STRIPACCESSARY]->val2 / 100;
if(sc->data[SC_BANANA_BOMB])
luk -= luk * sc->data[SC_BANANA_BOMB]->val1 / 100;
+ if(sc->data[SC_FULL_THROTTLE])
+ luk += luk * 20 / 100;
return (unsigned short)cap_value(luk,0,USHRT_MAX);
}
-static unsigned short status_calc_batk(struct block_list *bl, struct status_change *sc, int batk)
+static unsigned short status_calc_batk(struct block_list *bl, struct status_change *sc, int batk, bool viewable)
{
if(!sc || !sc->count)
return cap_value(batk,0,USHRT_MAX);
+
+ if( !viewable ){
+ /* some statuses that are hidden in the status window */
+ return (unsigned short)cap_value(batk,0,USHRT_MAX);
+ }
- if(sc->data[SC_ATKPOTION])
- batk += sc->data[SC_ATKPOTION]->val1;
+ if(sc->data[SC_PLUSATTACKPOWER])
+ batk += sc->data[SC_PLUSATTACKPOWER]->val1;
if(sc->data[SC_BATKFOOD])
batk += sc->data[SC_BATKFOOD]->val1;
- if(sc->data[SC_GATLINGFEVER])
- batk += sc->data[SC_GATLINGFEVER]->val3;
- if(sc->data[SC_MADNESSCANCEL])
+ if(sc->data[SC_GS_GATLINGFEVER])
+ batk += sc->data[SC_GS_GATLINGFEVER]->val3;
+ if(sc->data[SC_GS_MADNESSCANCEL])
batk += 100;
if(sc->data[SC_FIRE_INSIGNIA] && sc->data[SC_FIRE_INSIGNIA]->val1 == 2)
batk += 50;
@@ -4433,7 +4429,7 @@ static unsigned short status_calc_batk(struct block_list *bl, struct status_chan
batk += sc->data[SC_FULL_SWING_K]->val1;
if(sc->data[SC_ODINS_POWER])
batk += 70;
- if(sc->data[SC_ASH] && (bl->type==BL_MOB)){
+ if(sc->data[SC_VOLCANIC_ASH] && (bl->type==BL_MOB)){
if(status_get_element(bl) == ELE_WATER) //water type
batk /= 2;
}
@@ -4446,42 +4442,53 @@ static unsigned short status_calc_batk(struct block_list *bl, struct status_chan
batk += batk * sc->data[SC_INCATKRATE]->val1/100;
if(sc->data[SC_PROVOKE])
batk += batk * sc->data[SC_PROVOKE]->val3/100;
- if(sc->data[SC_CONCENTRATION])
- batk += batk * sc->data[SC_CONCENTRATION]->val2/100;
+#ifndef RENEWAL
+ if(sc->data[SC_LKCONCENTRATION])
+ batk += batk * sc->data[SC_LKCONCENTRATION]->val2/100;
+#endif
if(sc->data[SC_SKE])
batk += batk * 3;
- if(sc->data[SC_BLOODLUST])
- batk += batk * sc->data[SC_BLOODLUST]->val2/100;
+ if(sc->data[SC_HAMI_BLOODLUST])
+ batk += batk * sc->data[SC_HAMI_BLOODLUST]->val2/100;
if(sc->data[SC_JOINTBEAT] && sc->data[SC_JOINTBEAT]->val2&BREAK_WAIST)
batk -= batk * 25/100;
if(sc->data[SC_CURSE])
batk -= batk * 25/100;
+ if( sc->data[SC_ZANGETSU] )
+ batk += sc->data[SC_ZANGETSU]->val2;
//Curse shouldn't effect on this? <- Curse OR Bleeding??
-// if(sc->data[SC_BLEEDING])
+// if(sc->data[SC_BLOODING])
// batk -= batk * 25/100;
- if(sc->data[SC_FLEET])
- batk += batk * sc->data[SC_FLEET]->val3/100;
+ if(sc->data[SC_HLIF_FLEET])
+ batk += batk * sc->data[SC_HLIF_FLEET]->val3/100;
if(sc->data[SC__ENERVATION])
batk -= batk * sc->data[SC__ENERVATION]->val2 / 100;
- if(sc->data[SC_RUSHWINDMILL])
- batk += batk * sc->data[SC_RUSHWINDMILL]->val2/100;
- if(sc->data[SC_SATURDAYNIGHTFEVER])
- batk += 100 * sc->data[SC_SATURDAYNIGHTFEVER]->val1;
+ if(sc->data[SC_RUSH_WINDMILL])
+ batk += batk * sc->data[SC_RUSH_WINDMILL]->val2/100;
+ if(sc->data[SC_SATURDAY_NIGHT_FEVER])
+ batk += 100 * sc->data[SC_SATURDAY_NIGHT_FEVER]->val1;
if(sc->data[SC_MELODYOFSINK])
batk -= batk * sc->data[SC_MELODYOFSINK]->val3/100;
- if(sc->data[SC_BEYONDOFWARCRY])
- batk += batk * sc->data[SC_BEYONDOFWARCRY]->val3/100;
- if( sc->data[SC_ZANGETSU] )
- batk += batk * sc->data[SC_ZANGETSU]->val2 / 100;
+ if(sc->data[SC_BEYOND_OF_WARCRY])
+ batk += batk * sc->data[SC_BEYOND_OF_WARCRY]->val3/100;
return (unsigned short)cap_value(batk,0,USHRT_MAX);
}
-static unsigned short status_calc_watk(struct block_list *bl, struct status_change *sc, int watk)
+static unsigned short status_calc_watk(struct block_list *bl, struct status_change *sc, int watk, bool viewable)
{
if(!sc || !sc->count)
return cap_value(watk,0,USHRT_MAX);
+ if( !viewable ){
+ /* some statuses that are hidden in the status window */
+ if(sc->data[SC_STRIKING])
+ watk += sc->data[SC_STRIKING]->val2;
+ if(sc->data[SC_GENTLETOUCH_CHANGE] && sc->data[SC_GENTLETOUCH_CHANGE]->val2)
+ watk += sc->data[SC_GENTLETOUCH_CHANGE]->val2;
+ return (unsigned short)cap_value(watk,0,USHRT_MAX);
+ }
+
if(sc->data[SC_IMPOSITIO])
watk += sc->data[SC_IMPOSITIO]->val2;
if(sc->data[SC_WATKFOOD])
@@ -4490,12 +4497,10 @@ static unsigned short status_calc_watk(struct block_list *bl, struct status_chan
watk += sc->data[SC_DRUMBATTLE]->val2;
if(sc->data[SC_VOLCANO])
watk += sc->data[SC_VOLCANO]->val2;
- if(sc->data[SC_MERC_ATKUP])
- watk += sc->data[SC_MERC_ATKUP]->val2;
+ if(sc->data[SC_MER_ATK])
+ watk += sc->data[SC_MER_ATK]->val2;
if(sc->data[SC_FIGHTINGSPIRIT])
watk += sc->data[SC_FIGHTINGSPIRIT]->val1;
- if(sc->data[SC_STRIKING])
- watk += sc->data[SC_STRIKING]->val2;
if(sc->data[SC_SHIELDSPELL_DEF] && sc->data[SC_SHIELDSPELL_DEF]->val1 == 3)
watk += sc->data[SC_SHIELDSPELL_DEF]->val2;
if(sc->data[SC_INSPIRATION])
@@ -4522,23 +4527,28 @@ static unsigned short status_calc_watk(struct block_list *bl, struct status_chan
watk += sc->data[SC_NIBELUNGEN]->val2;
}
}
-
+#ifndef RENEWAL
+ if(sc->data[SC_STRIKING])
+ watk += sc->data[SC_STRIKING]->val2;
+ if(sc->data[SC_GENTLETOUCH_CHANGE] && sc->data[SC_GENTLETOUCH_CHANGE]->val2)
+ watk += sc->data[SC_GENTLETOUCH_CHANGE]->val2;
+ if(sc->data[SC_LKCONCENTRATION])
+ watk += watk * sc->data[SC_LKCONCENTRATION]->val2/100;
+#endif
if(sc->data[SC_INCATKRATE])
watk += watk * sc->data[SC_INCATKRATE]->val1/100;
if(sc->data[SC_PROVOKE])
watk += watk * sc->data[SC_PROVOKE]->val3/100;
- if(sc->data[SC_CONCENTRATION])
- watk += watk * sc->data[SC_CONCENTRATION]->val2/100;
if(sc->data[SC_SKE])
watk += watk * 3;
if(sc->data[SC__ENERVATION])
watk -= watk * sc->data[SC__ENERVATION]->val2 / 100;
- if(sc->data[SC_FLEET])
- watk += watk * sc->data[SC_FLEET]->val3/100;
+ if(sc->data[SC_HLIF_FLEET])
+ watk += watk * sc->data[SC_HLIF_FLEET]->val3/100;
if(sc->data[SC_CURSE])
watk -= watk * 25/100;
- if(sc->data[SC_STRIPWEAPON])
- watk -= watk * sc->data[SC_STRIPWEAPON]->val2/100;
+ if(sc->data[SC_NOEQUIPWEAPON])
+ watk -= watk * sc->data[SC_NOEQUIPWEAPON]->val2/100;
if(sc->data[SC__ENERVATION])
watk -= watk * sc->data[SC__ENERVATION]->val2 / 100;
if((sc->data[SC_FIRE_INSIGNIA] && sc->data[SC_FIRE_INSIGNIA]->val1 == 2)
@@ -4551,10 +4561,6 @@ static unsigned short status_calc_watk(struct block_list *bl, struct status_chan
watk += watk * sc->data[SC_TIDAL_WEAPON]->val2 / 100;
if(sc->data[SC_ANGRIFFS_MODUS])
watk += watk * sc->data[SC_ANGRIFFS_MODUS]->val2/100;
-#ifdef RENEWAL_EDP
- if( sc->data[SC_EDP] )
- watk = watk * (100 + sc->data[SC_EDP]->val1 * 80) / 100;
-#endif
return (unsigned short)cap_value(watk,0,USHRT_MAX);
}
@@ -4564,8 +4570,8 @@ static unsigned short status_calc_ematk(struct block_list *bl, struct status_cha
if (!sc || !sc->count)
return cap_value(matk,0,USHRT_MAX);
- if (sc->data[SC_MATKPOTION])
- matk += sc->data[SC_MATKPOTION]->val1;
+ if (sc->data[SC_PLUSMAGICPOWER])
+ matk += sc->data[SC_PLUSMAGICPOWER]->val1;
if (sc->data[SC_MATKFOOD])
matk += sc->data[SC_MATKFOOD]->val1;
if(sc->data[SC_MANA_PLUS])
@@ -4581,18 +4587,24 @@ static unsigned short status_calc_ematk(struct block_list *bl, struct status_cha
if(sc->data[SC_ODINS_POWER])
matk += 40 + 30 * sc->data[SC_ODINS_POWER]->val1; //70 lvl1, 100lvl2
if(sc->data[SC_IZAYOI])
- matk += 50 * sc->data[SC_IZAYOI]->val1;
+ matk += 25 * sc->data[SC_IZAYOI]->val1;
return (unsigned short)cap_value(matk,0,USHRT_MAX);
}
#endif
-static unsigned short status_calc_matk(struct block_list *bl, struct status_change *sc, int matk)
+static unsigned short status_calc_matk(struct block_list *bl, struct status_change *sc, int matk, bool viewable)
{
if(!sc || !sc->count)
return cap_value(matk,0,USHRT_MAX);
+
+ if( !viewable ){
+ /* some statuses that are hidden in the status window */
+ return (unsigned short)cap_value(matk,0,USHRT_MAX);
+ }
+
#ifndef RENEWAL
// take note fixed value first before % modifiers
- if (sc->data[SC_MATKPOTION])
- matk += sc->data[SC_MATKPOTION]->val1;
+ if (sc->data[SC_PLUSMAGICPOWER])
+ matk += sc->data[SC_PLUSMAGICPOWER]->val1;
if (sc->data[SC_MATKFOOD])
matk += sc->data[SC_MATKFOOD]->val1;
if (sc->data[SC_MANA_PLUS])
@@ -4608,33 +4620,38 @@ static unsigned short status_calc_matk(struct block_list *bl, struct status_chan
if (sc->data[SC_ODINS_POWER])
matk += 40 + 30 * sc->data[SC_ODINS_POWER]->val1; //70 lvl1, 100lvl2
if (sc->data[SC_IZAYOI])
- matk += 50 * sc->data[SC_IZAYOI]->val1;
+ matk += 25 * sc->data[SC_IZAYOI]->val1;
#endif
+ if( sc->data[SC_ZANGETSU] )
+ matk += sc->data[SC_ZANGETSU]->val3;
if (sc->data[SC_MAGICPOWER] && sc->data[SC_MAGICPOWER]->val4)
matk += matk * sc->data[SC_MAGICPOWER]->val3/100;
if (sc->data[SC_MINDBREAKER])
matk += matk * sc->data[SC_MINDBREAKER]->val2/100;
if (sc->data[SC_INCMATKRATE])
matk += matk * sc->data[SC_INCMATKRATE]->val1/100;
- if (sc->data[SC_MOONLITSERENADE])
- matk += matk * sc->data[SC_MOONLITSERENADE]->val2/100;
+ if (sc->data[SC_MOONLIT_SERENADE])
+ matk += matk * sc->data[SC_MOONLIT_SERENADE]->val2/100;
if (sc->data[SC_MELODYOFSINK])
matk += matk * sc->data[SC_MELODYOFSINK]->val3/100;
- if (sc->data[SC_BEYONDOFWARCRY])
- matk -= matk * sc->data[SC_BEYONDOFWARCRY]->val3/100;
- if( sc->data[SC_ZANGETSU] )
- matk += matk * sc->data[SC_ZANGETSU]->val2 / 100;
+ if (sc->data[SC_BEYOND_OF_WARCRY])
+ matk -= matk * sc->data[SC_BEYOND_OF_WARCRY]->val3/100;
return (unsigned short)cap_value(matk,0,USHRT_MAX);
}
-static signed short status_calc_critical(struct block_list *bl, struct status_change *sc, int critical) {
+static signed short status_calc_critical(struct block_list *bl, struct status_change *sc, int critical, bool viewable) {
if(!sc || !sc->count)
return cap_value(critical,10,SHRT_MAX);
- if (sc->data[SC_INCCRI])
- critical += sc->data[SC_INCCRI]->val2;
+ if( !viewable ){
+ /* some statuses that are hidden in the status window */
+ return (short)cap_value(critical,10,SHRT_MAX);
+ }
+
+ if (sc->data[SC_CRITICALPERCENT])
+ critical += sc->data[SC_CRITICALPERCENT]->val2;
if (sc->data[SC_EXPLOSIONSPIRITS])
critical += sc->data[SC_EXPLOSIONSPIRITS]->val2;
if (sc->data[SC_FORTUNE])
@@ -4658,30 +4675,35 @@ static signed short status_calc_critical(struct block_list *bl, struct status_ch
return (short)cap_value(critical,10,SHRT_MAX);
}
-static signed short status_calc_hit(struct block_list *bl, struct status_change *sc, int hit)
+static signed short status_calc_hit(struct block_list *bl, struct status_change *sc, int hit, bool viewable)
{
if(!sc || !sc->count)
return cap_value(hit,1,SHRT_MAX);
+ if( !viewable ){
+ /* some statuses that are hidden in the status window */
+ return (short)cap_value(hit,1,SHRT_MAX);
+ }
+
if(sc->data[SC_INCHIT])
hit += sc->data[SC_INCHIT]->val1;
- if(sc->data[SC_HITFOOD])
- hit += sc->data[SC_HITFOOD]->val1;
+ if(sc->data[SC_FOOD_BASICHIT])
+ hit += sc->data[SC_FOOD_BASICHIT]->val1;
if(sc->data[SC_TRUESIGHT])
hit += sc->data[SC_TRUESIGHT]->val3;
if(sc->data[SC_HUMMING])
hit += sc->data[SC_HUMMING]->val2;
- if(sc->data[SC_CONCENTRATION])
- hit += sc->data[SC_CONCENTRATION]->val3;
+ if(sc->data[SC_LKCONCENTRATION])
+ hit += sc->data[SC_LKCONCENTRATION]->val3;
if(sc->data[SC_INSPIRATION])
hit += 5 * sc->data[SC_INSPIRATION]->val1;
- if(sc->data[SC_ADJUSTMENT])
+ if(sc->data[SC_GS_ADJUSTMENT])
hit -= 30;
- if(sc->data[SC_INCREASING])
+ if(sc->data[SC_GS_ACCURACY])
hit += 20; // RockmanEXE; changed based on updated [Reddozen]
- if(sc->data[SC_MERC_HITUP])
- hit += sc->data[SC_MERC_HITUP]->val2;
+ if(sc->data[SC_MER_HIT])
+ hit += sc->data[SC_MER_HIT]->val2;
if(sc->data[SC_INCHITRATE])
hit += hit * sc->data[SC_INCHITRATE]->val1/100;
@@ -4691,13 +4713,13 @@ static signed short status_calc_hit(struct block_list *bl, struct status_change
hit -= hit * sc->data[SC__GROOMY]->val3 / 100;
if(sc->data[SC_FEAR])
hit -= hit * 20 / 100;
- if (sc->data[SC_ASH])
+ if (sc->data[SC_VOLCANIC_ASH])
hit /= 2;
return (short)cap_value(hit,1,SHRT_MAX);
}
-static signed short status_calc_flee(struct block_list *bl, struct status_change *sc, int flee)
+static signed short status_calc_flee(struct block_list *bl, struct status_change *sc, int flee, bool viewable)
{
if( bl->type == BL_PC )
{
@@ -4710,10 +4732,15 @@ static signed short status_calc_flee(struct block_list *bl, struct status_change
if(!sc || !sc->count)
return cap_value(flee,1,SHRT_MAX);
+ if( !viewable ){
+ /* some statuses that are hidden in the status window */
+ return (short)cap_value(flee,1,SHRT_MAX);
+ }
+
if(sc->data[SC_INCFLEE])
flee += sc->data[SC_INCFLEE]->val1;
- if(sc->data[SC_FLEEFOOD])
- flee += sc->data[SC_FLEEFOOD]->val1;
+ if(sc->data[SC_FOOD_BASICAVOIDANCE])
+ flee += sc->data[SC_FOOD_BASICAVOIDANCE]->val1;
if(sc->data[SC_WHISTLE])
flee += sc->data[SC_WHISTLE]->val2;
if(sc->data[SC_WINDWALK])
@@ -4722,28 +4749,26 @@ static signed short status_calc_flee(struct block_list *bl, struct status_change
flee += sc->data[SC_VIOLENTGALE]->val2;
if(sc->data[SC_MOON_COMFORT]) //SG skill [Komurka]
flee += sc->data[SC_MOON_COMFORT]->val2;
- if(sc->data[SC_CLOSECONFINE])
+ if(sc->data[SC_RG_CCONFINE_M])
flee += 10;
if (sc->data[SC_ANGRIFFS_MODUS])
flee -= sc->data[SC_ANGRIFFS_MODUS]->val3;
if (sc->data[SC_OVERED_BOOST])
flee = max(flee,sc->data[SC_OVERED_BOOST]->val2);
- if(sc->data[SC_ADJUSTMENT])
+ if(sc->data[SC_GS_ADJUSTMENT])
flee += 30;
- if(sc->data[SC_SPEED])
- flee += 10 + sc->data[SC_SPEED]->val1 * 10;
- if(sc->data[SC_GATLINGFEVER])
- flee -= sc->data[SC_GATLINGFEVER]->val4;
+ if(sc->data[SC_HLIF_SPEED])
+ flee += 10 + sc->data[SC_HLIF_SPEED]->val1 * 10;
+ if(sc->data[SC_GS_GATLINGFEVER])
+ flee -= sc->data[SC_GS_GATLINGFEVER]->val4;
if(sc->data[SC_PARTYFLEE])
flee += sc->data[SC_PARTYFLEE]->val1 * 10;
- if(sc->data[SC_MERC_FLEEUP])
- flee += sc->data[SC_MERC_FLEEUP]->val2;
+ if(sc->data[SC_MER_FLEE])
+ flee += sc->data[SC_MER_FLEE]->val2;
if( sc->data[SC_HALLUCINATIONWALK] )
flee += sc->data[SC_HALLUCINATIONWALK]->val2;
if( sc->data[SC_WATER_BARRIER] )
flee -= sc->data[SC_WATER_BARRIER]->val3;
- if( sc->data[SC_MARSHOFABYSS] )
- flee -= (9 * sc->data[SC_MARSHOFABYSS]->val3 / 10 + sc->data[SC_MARSHOFABYSS]->val2 / 10) * (bl->type == BL_MOB ? 2 : 1);
#ifdef RENEWAL
if( sc->data[SC_SPEARQUICKEN] )
flee += 2 * sc->data[SC_SPEARQUICKEN]->val1;
@@ -4767,13 +4792,13 @@ static signed short status_calc_flee(struct block_list *bl, struct status_change
flee -= flee * sc->data[SC__LAZINESS]->val3 / 100;
if( sc->data[SC_GLOOMYDAY] )
flee -= flee * sc->data[SC_GLOOMYDAY]->val2 / 100;
- if( sc->data[SC_SATURDAYNIGHTFEVER] )
- flee -= flee * (40 + 10 * sc->data[SC_SATURDAYNIGHTFEVER]->val1) / 100;
+ if( sc->data[SC_SATURDAY_NIGHT_FEVER] )
+ flee -= flee * (40 + 10 * sc->data[SC_SATURDAY_NIGHT_FEVER]->val1) / 100;
if( sc->data[SC_WIND_STEP_OPTION] )
flee += flee * sc->data[SC_WIND_STEP_OPTION]->val2 / 100;
if( sc->data[SC_ZEPHYR] )
flee += flee * sc->data[SC_ZEPHYR]->val2 / 100;
- if(sc->data[SC_ASH] && (bl->type==BL_MOB)){ //mob
+ if(sc->data[SC_VOLCANIC_ASH] && (bl->type==BL_MOB)){ //mob
if(status_get_element(bl) == ELE_WATER) //water type
flee /= 2;
}
@@ -4781,13 +4806,18 @@ static signed short status_calc_flee(struct block_list *bl, struct status_change
return (short)cap_value(flee,1,SHRT_MAX);
}
-static signed short status_calc_flee2(struct block_list *bl, struct status_change *sc, int flee2)
+static signed short status_calc_flee2(struct block_list *bl, struct status_change *sc, int flee2, bool viewable)
{
if(!sc || !sc->count)
return cap_value(flee2,10,SHRT_MAX);
- if(sc->data[SC_INCFLEE2])
- flee2 += sc->data[SC_INCFLEE2]->val2;
+ if( !viewable ){
+ /* some statuses that are hidden in the status window */
+ return (short)cap_value(flee2,10,SHRT_MAX);
+ }
+
+ if(sc->data[SC_PLUSAVOIDVALUE])
+ flee2 += sc->data[SC_PLUSAVOIDVALUE]->val2;
if(sc->data[SC_WHISTLE])
flee2 += sc->data[SC_WHISTLE]->val3*10;
if(sc->data[SC__UNLUCKY])
@@ -4795,11 +4825,20 @@ static signed short status_calc_flee2(struct block_list *bl, struct status_chang
return (short)cap_value(flee2,10,SHRT_MAX);
}
-static defType status_calc_def(struct block_list *bl, struct status_change *sc, int def) {
+defType status_calc_def(struct block_list *bl, struct status_change *sc, int def, bool viewable) {
if(!sc || !sc->count)
return (defType)cap_value(def,DEFTYPE_MIN,DEFTYPE_MAX);
+ if( !viewable ){
+ /* some statuses that are hidden in the status window */
+ if( sc && sc->data[SC_CAMOUFLAGE] )
+ def -= def * 5 * (10-sc->data[SC_CAMOUFLAGE]->val4) / 100;
+ if( sc && sc->data[SC_GENTLETOUCH_REVITALIZE] && sc->data[SC_GENTLETOUCH_REVITALIZE]->val4 )
+ def += 2 * sc->data[SC_GENTLETOUCH_REVITALIZE]->val4;
+ return (defType)cap_value(def,DEFTYPE_MIN,DEFTYPE_MAX);
+ }
+
if (sc->data[SC_BERSERK] || sc->data[SC__BLOODYLUST])
return 0;
if(sc->data[SC_SKA])
@@ -4813,12 +4852,12 @@ static defType status_calc_def(struct block_list *bl, struct status_change *sc,
return 90;
#endif
- if(sc->data[SC_ARMORCHANGE])
- def += sc->data[SC_ARMORCHANGE]->val2;
+ if(sc->data[SC_STONESKIN])
+ def += sc->data[SC_STONESKIN]->val2;
if(sc->data[SC_DRUMBATTLE])
def += sc->data[SC_DRUMBATTLE]->val3;
- if(sc->data[SC_DEFENCE]) //[orn]
- def += sc->data[SC_DEFENCE]->val2 ;
+ if(sc->data[SC_HAMI_DEFENCE]) //[orn]
+ def += sc->data[SC_HAMI_DEFENCE]->val2 ;
if(sc->data[SC_INCDEFRATE])
def += def * sc->data[SC_INCDEFRATE]->val1/100;
if(sc->data[SC_EARTH_INSIGNIA] && sc->data[SC_EARTH_INSIGNIA]->val1 == 2)
@@ -4833,28 +4872,24 @@ static defType status_calc_def(struct block_list *bl, struct status_change *sc,
def >>=1;
if(sc->data[SC_FREEZE])
def >>=1;
- if(sc->data[SC_SIGNUMCRUCIS])
- def -= def * sc->data[SC_SIGNUMCRUCIS]->val2/100;
- if(sc->data[SC_CONCENTRATION])
- def -= def * sc->data[SC_CONCENTRATION]->val4/100;
+ if(sc->data[SC_CRUCIS])
+ def -= def * sc->data[SC_CRUCIS]->val2/100;
+ if(sc->data[SC_LKCONCENTRATION])
+ def -= def * sc->data[SC_LKCONCENTRATION]->val4/100;
if(sc->data[SC_SKE])
def >>=1;
if(sc->data[SC_PROVOKE] && bl->type != BL_PC) // Provoke doesn't alter player defense->
def -= def * sc->data[SC_PROVOKE]->val4/100;
- if(sc->data[SC_STRIPSHIELD])
- def -= def * sc->data[SC_STRIPSHIELD]->val2/100;
+ if(sc->data[SC_NOEQUIPSHIELD])
+ def -= def * sc->data[SC_NOEQUIPSHIELD]->val2/100;
if (sc->data[SC_FLING])
def -= def * (sc->data[SC_FLING]->val2)/100;
- if( sc->data[SC_FREEZING] )
- def -= def * 10 / 100;
- if( sc->data[SC_MARSHOFABYSS] )
- def -= def * ( 6 + 6 * sc->data[SC_MARSHOFABYSS]->val3/10 + (bl->type == BL_MOB ? 5 : 3) * sc->data[SC_MARSHOFABYSS]->val2/36 ) / 100;
if( sc->data[SC_ANALYZE] )
def -= def * ( 14 * sc->data[SC_ANALYZE]->val1 ) / 100;
if( sc->data[SC_FORCEOFVANGUARD] )
def += def * 2 * sc->data[SC_FORCEOFVANGUARD]->val1 / 100;
- if(sc->data[SC_SATURDAYNIGHTFEVER])
- def -= def * (10 + 10 * sc->data[SC_SATURDAYNIGHTFEVER]->val1) / 100;
+ if(sc->data[SC_SATURDAY_NIGHT_FEVER])
+ def -= def * (10 + 10 * sc->data[SC_SATURDAY_NIGHT_FEVER]->val1) / 100;
if(sc->data[SC_EARTHDRIVE])
def -= def * 25 / 100;
if( sc->data[SC_ROCK_CRUSHER] )
@@ -4863,15 +4898,17 @@ static defType status_calc_def(struct block_list *bl, struct status_change *sc,
def += def * sc->data[SC_POWER_OF_GAIA]->val2 / 100;
if( sc->data[SC_PRESTIGE] )
def += def * sc->data[SC_PRESTIGE]->val1 / 100;
- if(sc->data[SC_ASH] && (bl->type==BL_MOB)){
+ if( sc->data[SC_FROSTMISTY] )
+ def -= def * 10 / 100;
+ if(sc->data[SC_VOLCANIC_ASH] && (bl->type==BL_MOB)){
if(status_get_race(bl)==RC_PLANT)
def /= 2;
}
- return (defType)cap_value(def,DEFTYPE_MIN,DEFTYPE_MAX);;
+ return (defType)cap_value(def,DEFTYPE_MIN,DEFTYPE_MAX);
}
-static signed short status_calc_def2(struct block_list *bl, struct status_change *sc, int def2)
+signed short status_calc_def2(struct block_list *bl, struct status_change *sc, int def2, bool viewable)
{
if(!sc || !sc->count)
#ifdef RENEWAL
@@ -4880,6 +4917,21 @@ static signed short status_calc_def2(struct block_list *bl, struct status_change
return (short)cap_value(def2,1,SHRT_MAX);
#endif
+ if( !viewable ){
+ /* some statuses that are hidden in the status window */
+#ifdef RENEWAL
+ if( sc && sc->data[SC_ASSUMPTIO] )
+ def2 <<= 1;
+#endif
+ if( sc && sc->data[SC_CAMOUFLAGE] )
+ def2 -= def2 * 5 * (10-sc->data[SC_CAMOUFLAGE]->val4) / 100;
+#ifdef RENEWAL
+ return (short)cap_value(def2,SHRT_MIN,SHRT_MAX);
+#else
+ return (short)cap_value(def2,1,SHRT_MAX);
+#endif
+ }
+
if (sc->data[SC_BERSERK] || sc->data[SC__BLOODYLUST])
return 0;
if(sc->data[SC_ETERNALCHAOS])
@@ -4896,9 +4948,9 @@ static signed short status_calc_def2(struct block_list *bl, struct status_change
def2 += status_get_vit(bl) / 2 * sc->data[SC_ANGELUS]->val2/100;
#else
def2 += def2 * sc->data[SC_ANGELUS]->val2/100;
+ if(sc->data[SC_LKCONCENTRATION])
+ def2 -= def2 * sc->data[SC_LKCONCENTRATION]->val4/100;
#endif
- if(sc->data[SC_CONCENTRATION])
- def2 -= def2 * sc->data[SC_CONCENTRATION]->val4/100;
if(sc->data[SC_POISON])
def2 -= def2 * 25/100;
if(sc->data[SC_DPOISON])
@@ -4912,18 +4964,16 @@ static signed short status_calc_def2(struct block_list *bl, struct status_change
+ def2 * ( sc->data[SC_JOINTBEAT]->val2&BREAK_WAIST ? 25 : 0 ) / 100;
if(sc->data[SC_FLING])
def2 -= def2 * (sc->data[SC_FLING]->val3)/100;
- if( sc->data[SC_FREEZING] )
- def2 -= def2 * 3 / 10;
if(sc->data[SC_ANALYZE])
def2 -= def2 * ( 14 * sc->data[SC_ANALYZE]->val1 ) / 100;
if( sc->data[SC_ECHOSONG] )
def2 += def2 * sc->data[SC_ECHOSONG]->val2/100;
- if(sc->data[SC_ASH] && (bl->type==BL_MOB)){
+ if(sc->data[SC_VOLCANIC_ASH] && (bl->type==BL_MOB)){
if(status_get_race(bl)==RC_PLANT)
def2 /= 2;
}
- if (sc->data[SC_PARALYSIS])
- def2 -= def2 * sc->data[SC_PARALYSIS]->val2 / 100;
+ if (sc->data[SC_NEEDLE_OF_PARALYZE])
+ def2 -= def2 * sc->data[SC_NEEDLE_OF_PARALYZE]->val2 / 100;
#ifdef RENEWAL
return (short)cap_value(def2,SHRT_MIN,SHRT_MAX);
@@ -4933,11 +4983,16 @@ static signed short status_calc_def2(struct block_list *bl, struct status_change
}
-static defType status_calc_mdef(struct block_list *bl, struct status_change *sc, int mdef) {
+defType status_calc_mdef(struct block_list *bl, struct status_change *sc, int mdef, bool viewable) {
if(!sc || !sc->count)
return (defType)cap_value(mdef,DEFTYPE_MIN,DEFTYPE_MAX);
+ if( !viewable ){
+ /* some statuses that are hidden in the status window */
+ return (defType)cap_value(mdef,DEFTYPE_MIN,DEFTYPE_MAX);
+ }
+
if (sc->data[SC_BERSERK] || sc->data[SC__BLOODYLUST])
return 0;
if(sc->data[SC_BARRIER])
@@ -4948,15 +5003,13 @@ static defType status_calc_mdef(struct block_list *bl, struct status_change *sc,
return 90;
#endif
- if(sc->data[SC_ARMORCHANGE])
- mdef += sc->data[SC_ARMORCHANGE]->val3;
+ if(sc->data[SC_STONESKIN])
+ mdef += sc->data[SC_STONESKIN]->val3;
if(sc->data[SC_EARTH_INSIGNIA] && sc->data[SC_EARTH_INSIGNIA]->val1 == 3)
mdef += 50;
if(sc->data[SC_ENDURE])// It has been confirmed that eddga card grants 1 MDEF, not 0, not 10, but 1.
mdef += (sc->data[SC_ENDURE]->val4 == 0) ? sc->data[SC_ENDURE]->val1 : 1;
- if(sc->data[SC_CONCENTRATION])
- mdef += 1; //Skill info says it adds a fixed 1 Mdef point.
- if(sc->data[SC_STONEHARDSKIN])
+ if(sc->data[SC_STONEHARDSKIN])// Final MDEF increase divided by 10 since were using classic (pre-renewal) mechanics. [Rytech]
mdef += sc->data[SC_STONEHARDSKIN]->val1;
if(sc->data[SC_WATER_BARRIER])
mdef += sc->data[SC_WATER_BARRIER]->val2;
@@ -4964,21 +5017,21 @@ static defType status_calc_mdef(struct block_list *bl, struct status_change *sc,
mdef += 25*mdef/100;
if(sc->data[SC_FREEZE])
mdef += 25*mdef/100;
- if( sc->data[SC_MARSHOFABYSS] )
- mdef -= mdef * ( 6 + 6 * sc->data[SC_MARSHOFABYSS]->val3/10 + (bl->type == BL_MOB ? 5 : 3) * sc->data[SC_MARSHOFABYSS]->val2/36 ) / 100;
if(sc->data[SC_ANALYZE])
mdef -= mdef * ( 14 * sc->data[SC_ANALYZE]->val1 ) / 100;
- if(sc->data[SC_SYMPHONYOFLOVER])
- mdef += mdef * sc->data[SC_SYMPHONYOFLOVER]->val2 / 100;
- if(sc->data[SC_GT_CHANGE] && sc->data[SC_GT_CHANGE]->val4)
- mdef -= mdef * sc->data[SC_GT_CHANGE]->val4 / 100;
+ if(sc->data[SC_SYMPHONY_LOVE])
+ mdef += mdef * sc->data[SC_SYMPHONY_LOVE]->val2 / 100;
+ if(sc->data[SC_GENTLETOUCH_CHANGE] && sc->data[SC_GENTLETOUCH_CHANGE]->val4)
+ mdef -= mdef * sc->data[SC_GENTLETOUCH_CHANGE]->val4 / 100;
if (sc->data[SC_ODINS_POWER])
mdef -= 20 * sc->data[SC_ODINS_POWER]->val1;
+ if(sc->data[SC_BURNING])
+ mdef -= mdef *25 / 100;
return (defType)cap_value(mdef,DEFTYPE_MIN,DEFTYPE_MAX);
}
-static signed short status_calc_mdef2(struct block_list *bl, struct status_change *sc, int mdef2)
+signed short status_calc_mdef2(struct block_list *bl, struct status_change *sc, int mdef2, bool viewable)
{
if(!sc || !sc->count)
#ifdef RENEWAL
@@ -4987,6 +5040,16 @@ static signed short status_calc_mdef2(struct block_list *bl, struct status_chang
return (short)cap_value(mdef2,1,SHRT_MAX);
#endif
+ if( !viewable ){
+ /* some statuses that are hidden in the status window */
+#ifdef RENEWAL
+ if(sc && sc->data[SC_ASSUMPTIO])
+ mdef2 <<= 1;
+ return (short)cap_value(mdef2,SHRT_MIN,SHRT_MAX);
+#else
+ return (short)cap_value(mdef2,1,SHRT_MAX);
+#endif
+ }
if (sc->data[SC_BERSERK] || sc->data[SC__BLOODYLUST])
return 0;
@@ -5015,12 +5078,12 @@ static unsigned short status_calc_speed(struct block_list *bl, struct status_cha
if (sd && sd->state.permanent_speed)
return (short)cap_value(speed,10,USHRT_MAX);
- if( sd && sd->ud.skilltimer != INVALID_TIMER && (pc_checkskill(sd,SA_FREECAST) > 0 || sd->ud.skill_id == LG_EXEEDBREAK) )
+ if( sd && sd->ud.skilltimer != INVALID_TIMER && (pc->checkskill(sd,SA_FREECAST) > 0 || sd->ud.skill_id == LG_EXEEDBREAK) )
{
if( sd->ud.skill_id == LG_EXEEDBREAK )
speed_rate = 100 + 60 - (sd->ud.skill_lv * 10);
else
- speed_rate = 175 - 5 * pc_checkskill(sd,SA_FREECAST);
+ speed_rate = 175 - 5 * pc->checkskill(sd,SA_FREECAST);
}
else
{
@@ -5036,9 +5099,9 @@ static unsigned short status_calc_speed(struct block_list *bl, struct status_cha
if( pc_isriding(sd) || sd->sc.option&(OPTION_DRAGON) || sd->sc.data[SC_ALL_RIDING] )
val = 25;//Same bonus
else if( pc_isridingwug(sd) )
- val = 15 + 5 * pc_checkskill(sd, RA_WUGRIDER);
+ val = 15 + 5 * pc->checkskill(sd, RA_WUGRIDER);
else if( pc_ismadogear(sd) ) {
- val = (- 10 * (5 - pc_checkskill(sd,NC_MADOLICENCE)));
+ val = (- 10 * (5 - pc->checkskill(sd,NC_MADOLICENCE)));
if( sc->data[SC_ACCELERATION] )
val += 25;
}
@@ -5051,8 +5114,8 @@ static unsigned short status_calc_speed(struct block_list *bl, struct status_cha
{
int val = 0;
- if( sd && sc->data[SC_HIDING] && pc_checkskill(sd,RG_TUNNELDRIVE) > 0 )
- val = 120 - 6 * pc_checkskill(sd,RG_TUNNELDRIVE);
+ if( sd && sc->data[SC_HIDING] && pc->checkskill(sd,RG_TUNNELDRIVE) > 0 )
+ val = 120 - 6 * pc->checkskill(sd,RG_TUNNELDRIVE);
else
if( sd && sc->data[SC_CHASEWALK] && sc->data[SC_CHASEWALK]->val3 < 0 )
val = sc->data[SC_CHASEWALK]->val3;
@@ -5063,9 +5126,9 @@ static unsigned short status_calc_speed(struct block_list *bl, struct status_cha
val = max( val, 50 - 10 * sc->data[SC_LONGING]->val1 );
else
if( sd && sc->data[SC_DANCING] )
- val = max( val, 500 - (40 + 10 * (sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_BARDDANCER)) * pc_checkskill(sd,(sd->status.sex?BA_MUSICALLESSON:DC_DANCINGLESSON)) );
+ val = max( val, 500 - (40 + 10 * (sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_BARDDANCER)) * pc->checkskill(sd,(sd->status.sex?BA_MUSICALLESSON:DC_DANCINGLESSON)) );
- if( sc->data[SC_DECREASEAGI] )
+ if( sc->data[SC_DEC_AGI] )
val = max( val, 25 );
if( sc->data[SC_QUAGMIRE] || sc->data[SC_HALLUCINATIONWALK_POSTDELAY] || (sc->data[SC_GLOOMYDAY] && sc->data[SC_GLOOMYDAY]->val4) )
val = max( val, 50 );
@@ -5085,16 +5148,14 @@ static unsigned short status_calc_speed(struct block_list *bl, struct status_cha
val = max( val, 75 );
if( sc->data[SC_SLOWDOWN] ) // Slow Potion
val = max( val, 100 );
- if( sc->data[SC_GATLINGFEVER] )
+ if( sc->data[SC_GS_GATLINGFEVER] )
val = max( val, 100 );
- if( sc->data[SC_SUITON] )
- val = max( val, sc->data[SC_SUITON]->val3 );
+ if( sc->data[SC_NJ_SUITON] )
+ val = max( val, sc->data[SC_NJ_SUITON]->val3 );
if( sc->data[SC_SWOO] )
val = max( val, 300 );
- if( sc->data[SC_FREEZING] )
- val = max( val, 70 );
- if( sc->data[SC_MARSHOFABYSS] )
- val = max( val, 40 + 10 * sc->data[SC_MARSHOFABYSS]->val1 );
+ if( sc->data[SC_FROSTMISTY] )
+ val = max( val, 50 );
if( sc->data[SC_CAMOUFLAGE] && (sc->data[SC_CAMOUFLAGE]->val3&1) == 0 )
val = max( val, sc->data[SC_CAMOUFLAGE]->val1 < 3 ? 0 : 25 * (5 - sc->data[SC_CAMOUFLAGE]->val1) );
if( sc->data[SC__GROOMY] )
@@ -5109,6 +5170,9 @@ static unsigned short status_calc_speed(struct block_list *bl, struct status_cha
val = max( val, sc->data[SC_POWER_OF_GAIA]->val2 );
if( sc->data[SC_MELON_BOMB] )
val = max( val, sc->data[SC_MELON_BOMB]->val1 );
+
+ if( sc->data[SC_MARSHOFABYSS] ) // It stacks to other statuses so always put this at the end.
+ val = max( 50, val + 10 * sc->data[SC_MARSHOFABYSS]->val1 );
if( sd && sd->bonus.speed_rate + sd->bonus.speed_add_rate > 0 ) // permanent item-based speedup
val = max( val, sd->bonus.speed_rate + sd->bonus.speed_add_rate );
@@ -5121,24 +5185,24 @@ static unsigned short status_calc_speed(struct block_list *bl, struct status_cha
{
int val = 0;
- if( sc->data[SC_SPEEDUP1] ) //FIXME: used both by NPC_AGIUP and Speed Potion script
+ if( sc->data[SC_MOVHASTE_INFINITY] ) //FIXME: used both by NPC_AGIUP and Speed Potion script
val = max( val, 50 );
- if( sc->data[SC_INCREASEAGI] )
+ if( sc->data[SC_INC_AGI] )
val = max( val, 25 );
if( sc->data[SC_WINDWALK] )
val = max( val, 2 * sc->data[SC_WINDWALK]->val1 );
if( sc->data[SC_CARTBOOST] )
val = max( val, 20 );
- if( sd && (sd->class_&MAPID_UPPERMASK) == MAPID_ASSASSIN && pc_checkskill(sd,TF_MISS) > 0 )
- val = max( val, 1 * pc_checkskill(sd,TF_MISS) );
+ if( sd && (sd->class_&MAPID_UPPERMASK) == MAPID_ASSASSIN && pc->checkskill(sd,TF_MISS) > 0 )
+ val = max( val, 1 * pc->checkskill(sd,TF_MISS) );
if( sc->data[SC_CLOAKING] && (sc->data[SC_CLOAKING]->val4&1) == 1 )
val = max( val, sc->data[SC_CLOAKING]->val1 >= 10 ? 25 : 3 * sc->data[SC_CLOAKING]->val1 - 3 );
if (sc->data[SC_BERSERK] || sc->data[SC__BLOODYLUST])
val = max( val, 25 );
if( sc->data[SC_RUN] )
val = max( val, 55 );
- if( sc->data[SC_AVOID] )
- val = max( val, 10 * sc->data[SC_AVOID]->val1 );
+ if( sc->data[SC_HLIF_AVOID] )
+ val = max( val, 10 * sc->data[SC_HLIF_AVOID]->val1 );
if( sc->data[SC_INVINCIBLE] && !sc->data[SC_INVINCIBLEOFF] )
val = max( val, 75 );
if( sc->data[SC_CLOAKINGEXCEED] )
@@ -5147,13 +5211,14 @@ static unsigned short status_calc_speed(struct block_list *bl, struct status_cha
val = max( val, 10 );
if( sc->data[SC_GN_CARTBOOST] )
val = max( val, sc->data[SC_GN_CARTBOOST]->val2 );
- if( sc->data[SC_SWINGDANCE] )
- val = max( val, sc->data[SC_SWINGDANCE]->val2 );
+ if( sc->data[SC_SWING] )
+ val = max( val, sc->data[SC_SWING]->val2 );
if( sc->data[SC_WIND_STEP_OPTION] )
val = max( val, sc->data[SC_WIND_STEP_OPTION]->val2 );
-
+ if( sc->data[SC_FULL_THROTTLE] )
+ val = max( val, 30);
//FIXME: official items use a single bonus for this [ultramage]
- if( sc->data[SC_SPEEDUP0] ) // temporary item-based speedup
+ if( sc->data[SC_MOVHASTE_HORSE] ) // temporary item-based speedup
val = max( val, 25 );
if( sd && sd->bonus.speed_rate + sd->bonus.speed_add_rate < 0 ) // permanent item-based speedup
val = max( val, -(sd->bonus.speed_rate + sd->bonus.speed_add_rate) );
@@ -5168,9 +5233,11 @@ static unsigned short status_calc_speed(struct block_list *bl, struct status_cha
//GetSpeed()
{
if( sd && pc_iscarton(sd) )
- speed += speed * (50 - 5 * pc_checkskill(sd,MC_PUSHCART)) / 100;
+ speed += speed * (50 - 5 * pc->checkskill(sd,MC_PUSHCART)) / 100;
if( sc->data[SC_PARALYSE] )
speed += speed * 50 / 100;
+ if( sc->data[SC_REBOUND] )
+ speed += max(speed, 100);
if( speed_rate != 100 )
speed = speed * speed_rate / 100;
if( sc->data[SC_STEELBODY] )
@@ -5179,6 +5246,7 @@ static unsigned short status_calc_speed(struct block_list *bl, struct status_cha
speed = max(speed, 200);
if( sc->data[SC_WALKSPEED] && sc->data[SC_WALKSPEED]->val1 > 0 ) // ChangeSpeed
speed = speed * 100 / sc->data[SC_WALKSPEED]->val1;
+
}
return (short)cap_value(speed,10,USHRT_MAX);
@@ -5194,22 +5262,19 @@ static short status_calc_aspd(struct block_list *bl, struct status_change *sc, s
if(!sc || !sc->count)
return 0;
- if(sc->data[i=SC_ASPDPOTION3] ||
- sc->data[i=SC_ASPDPOTION2] ||
- sc->data[i=SC_ASPDPOTION1] ||
- sc->data[i=SC_ASPDPOTION0])
+ if(sc->data[i=SC_ATTHASTE_INFINITY] ||
+ sc->data[i=SC_ATTHASTE_POTION3] ||
+ sc->data[i=SC_ATTHASTE_POTION2] ||
+ sc->data[i=SC_ATTHASTE_POTION1])
pots += sc->data[i]->val1;
if( !sc->data[SC_QUAGMIRE] ){
- if(sc->data[SC_STAR_COMFORT])
- skills1 = 5; // needs more info
-
if(sc->data[SC_TWOHANDQUICKEN] && skills1 < 7)
skills1 = 7;
- if(sc->data[SC_ONEHAND] && skills1 < 7) skills1 = 7;
+ if(sc->data[SC_ONEHANDQUICKEN] && skills1 < 7) skills1 = 7;
- if(sc->data[SC_MERC_QUICKEN] && skills1 < 7) // needs more info
+ if(sc->data[SC_MER_QUICKEN] && skills1 < 7) // needs more info
skills1 = 7;
if(sc->data[SC_ADRENALINE2] && skills1 < 6)
@@ -5221,48 +5286,25 @@ static short status_calc_aspd(struct block_list *bl, struct status_change *sc, s
if(sc->data[SC_SPEARQUICKEN] && skills1 < 7)
skills1 = 7;
- if(sc->data[SC_GATLINGFEVER] && skills1 < 9) // needs more info
- skills1 = 9;
-
- if(sc->data[SC_FLEET] && skills1 < 5)
+ if(sc->data[SC_HLIF_FLEET] && skills1 < 5)
skills1 = 5;
-
- if(sc->data[SC_ASSNCROS] &&
- skills1 < 5+1*sc->data[SC_ASSNCROS]->val1) // needs more info
- {
- if (bl->type!=BL_PC)
- skills1 = 4+1*sc->data[SC_ASSNCROS]->val1;
- else
- switch(((TBL_PC*)bl)->status.weapon)
- {
- case W_BOW:
- case W_REVOLVER:
- case W_RIFLE:
- case W_GATLING:
- case W_SHOTGUN:
- case W_GRENADE:
- break;
- default:
- skills1 = 5+1*sc->data[SC_ASSNCROS]->val1;
- }
- }
}
if((sc->data[SC_BERSERK] || sc->data[SC__BLOODYLUST]) && skills1 < 15)
skills1 = 15;
- else if(sc->data[SC_MADNESSCANCEL] && skills1 < 15) // needs more info
- skills1 = 15;
+ else if(sc->data[SC_GS_MADNESSCANCEL] && skills1 < 20)
+ skills1 = 20;
if(sc->data[SC_DONTFORGETME])
- skills2 -= sc->data[SC_DONTFORGETME]->val2; // needs more info
+ skills2 -= sc->data[SC_DONTFORGETME]->val2;
if(sc->data[SC_LONGING])
- skills2 -= sc->data[SC_LONGING]->val2; // needs more info
+ skills2 -= sc->data[SC_LONGING]->val2;
if(sc->data[SC_STEELBODY])
skills2 -= 25;
if(sc->data[SC_SKA])
skills2 -= 25;
if(sc->data[SC_DEFENDER])
- skills2 -= sc->data[SC_DEFENDER]->val4; // needs more info
+ skills2 -= sc->data[SC_DEFENDER]->val4 / 10;
if(sc->data[SC_GOSPEL] && sc->data[SC_GOSPEL]->val4 == BCT_ENEMY) // needs more info
skills2 -= 25;
if(sc->data[SC_GRAVITATION])
@@ -5273,8 +5315,8 @@ static short status_calc_aspd(struct block_list *bl, struct status_change *sc, s
if( sc->data[SC_JOINTBEAT]->val2&BREAK_KNEE )
skills2 -= 10;
}
- if( sc->data[SC_FREEZING] )
- skills2 -= 30;
+ if( sc->data[SC_FROSTMISTY] )
+ skills2 -= 15;
if( sc->data[SC_HALLUCINATIONWALK_POSTDELAY] )
skills2 -= 50;
if( sc->data[SC_PARALYSE] )
@@ -5285,25 +5327,46 @@ static short status_calc_aspd(struct block_list *bl, struct status_change *sc, s
skills2 -= sc->data[SC__INVISIBILITY]->val2 ;
if( sc->data[SC__GROOMY] )
skills2 -= sc->data[SC__GROOMY]->val2;
- if( sc->data[SC_SWINGDANCE] )
- skills2 += sc->data[SC_SWINGDANCE]->val2;
- if( sc->data[SC_DANCEWITHWUG] )
- skills2 += sc->data[SC_DANCEWITHWUG]->val3;
if( sc->data[SC_GLOOMYDAY] )
skills2 -= sc->data[SC_GLOOMYDAY]->val3;
if( sc->data[SC_EARTHDRIVE] )
skills2 -= 25;
- if( sc->data[SC_GT_CHANGE] )
- skills2 += sc->data[SC_GT_CHANGE]->val3;
if( sc->data[SC_MELON_BOMB] )
skills2 -= sc->data[SC_MELON_BOMB]->val1;
+
+ if( sc->data[SC_SWING] )
+ skills2 += sc->data[SC_SWING]->val2;
+ if( sc->data[SC_DANCE_WITH_WUG] )
+ skills2 += sc->data[SC_DANCE_WITH_WUG]->val3;
+ if( sc->data[SC_GENTLETOUCH_CHANGE] )
+ skills2 += sc->data[SC_GENTLETOUCH_CHANGE]->val3;
if( sc->data[SC_BOOST500] )
skills2 += sc->data[SC_BOOST500]->val1;
if( sc->data[SC_EXTRACT_SALAMINE_JUICE] )
skills2 += sc->data[SC_EXTRACT_SALAMINE_JUICE]->val1;
if( sc->data[SC_INCASPDRATE] )
skills2 += sc->data[SC_INCASPDRATE]->val1;
-
+ if( sc->data[SC_GS_GATLINGFEVER] )
+ skills2 += sc->data[SC_GS_GATLINGFEVER]->val1;
+ if( sc->data[SC_STAR_COMFORT] )
+ skills2 += 3 * sc->data[SC_STAR_COMFORT]->val1;
+ if( sc->data[SC_ASSNCROS] && !skills1){
+ if (bl->type!=BL_PC)
+ skills2 += sc->data[SC_ASSNCROS]->val2;
+ else
+ switch(((TBL_PC*)bl)->status.weapon)
+ {
+ case W_BOW:
+ case W_REVOLVER:
+ case W_RIFLE:
+ case W_GATLING:
+ case W_SHOTGUN:
+ case W_GRENADE:
+ break;
+ default:
+ skills2 += sc->data[SC_ASSNCROS]->val2;
+ }
+ }
return ( flag&1? (skills1 + pots) : skills2 );
}
#endif
@@ -5321,7 +5384,7 @@ static short status_calc_fix_aspd(struct block_list *bl, struct status_change *s
|| sc->data[SC_WILD_STORM_OPTION]))
aspd -= 50; // +5 ASPD
if( sc && sc->data[SC_FIGHTINGSPIRIT] && sc->data[SC_FIGHTINGSPIRIT]->val2 )
- aspd -= (bl->type==BL_PC?pc_checkskill((TBL_PC *)bl, RK_RUNEMASTERY):10) / 10 * 40;
+ aspd -= (bl->type==BL_PC?pc->checkskill((TBL_PC *)bl, RK_RUNEMASTERY):10) / 10 * 40;
return cap_value(aspd, 0, 2000); // will be recap for proper bl anyway
}
@@ -5344,13 +5407,13 @@ static short status_calc_aspd_rate(struct block_list *bl, struct status_change *
max < sc->data[SC_TWOHANDQUICKEN]->val2)
max = sc->data[SC_TWOHANDQUICKEN]->val2;
- if(sc->data[SC_ONEHAND] &&
- max < sc->data[SC_ONEHAND]->val2)
- max = sc->data[SC_ONEHAND]->val2;
+ if(sc->data[SC_ONEHANDQUICKEN] &&
+ max < sc->data[SC_ONEHANDQUICKEN]->val2)
+ max = sc->data[SC_ONEHANDQUICKEN]->val2;
- if(sc->data[SC_MERC_QUICKEN] &&
- max < sc->data[SC_MERC_QUICKEN]->val2)
- max = sc->data[SC_MERC_QUICKEN]->val2;
+ if(sc->data[SC_MER_QUICKEN] &&
+ max < sc->data[SC_MER_QUICKEN]->val2)
+ max = sc->data[SC_MER_QUICKEN]->val2;
if(sc->data[SC_ADRENALINE2] &&
max < sc->data[SC_ADRENALINE2]->val3)
@@ -5364,13 +5427,13 @@ static short status_calc_aspd_rate(struct block_list *bl, struct status_change *
max < sc->data[SC_SPEARQUICKEN]->val2)
max = sc->data[SC_SPEARQUICKEN]->val2;
- if(sc->data[SC_GATLINGFEVER] &&
- max < sc->data[SC_GATLINGFEVER]->val2)
- max = sc->data[SC_GATLINGFEVER]->val2;
+ if(sc->data[SC_GS_GATLINGFEVER] &&
+ max < sc->data[SC_GS_GATLINGFEVER]->val2)
+ max = sc->data[SC_GS_GATLINGFEVER]->val2;
- if(sc->data[SC_FLEET] &&
- max < sc->data[SC_FLEET]->val2)
- max = sc->data[SC_FLEET]->val2;
+ if(sc->data[SC_HLIF_FLEET] &&
+ max < sc->data[SC_HLIF_FLEET]->val2)
+ max = sc->data[SC_HLIF_FLEET]->val2;
if(sc->data[SC_ASSNCROS] &&
max < sc->data[SC_ASSNCROS]->val2)
@@ -5395,14 +5458,14 @@ static short status_calc_aspd_rate(struct block_list *bl, struct status_change *
if((sc->data[SC_BERSERK] || sc->data[SC__BLOODYLUST]))
aspd_rate -= 300;
- else if(sc->data[SC_MADNESSCANCEL])
+ else if(sc->data[SC_GS_MADNESSCANCEL])
aspd_rate -= 200;
}
- if( sc->data[i=SC_ASPDPOTION3] ||
- sc->data[i=SC_ASPDPOTION2] ||
- sc->data[i=SC_ASPDPOTION1] ||
- sc->data[i=SC_ASPDPOTION0] )
+ if( sc->data[i=SC_ATTHASTE_INFINITY] ||
+ sc->data[i=SC_ATTHASTE_POTION3] ||
+ sc->data[i=SC_ATTHASTE_POTION2] ||
+ sc->data[i=SC_ATTHASTE_POTION1] )
aspd_rate -= sc->data[i]->val2;
if(sc->data[SC_DONTFORGETME])
@@ -5425,8 +5488,8 @@ static short status_calc_aspd_rate(struct block_list *bl, struct status_change *
if( sc->data[SC_JOINTBEAT]->val2&BREAK_KNEE )
aspd_rate += 100;
}
- if( sc->data[SC_FREEZING] )
- aspd_rate += 300;
+ if( sc->data[SC_FROSTMISTY] )
+ aspd_rate += 150;
if( sc->data[SC_HALLUCINATIONWALK_POSTDELAY] )
aspd_rate += 500;
if( sc->data[SC_FIGHTINGSPIRIT] && sc->data[SC_FIGHTINGSPIRIT]->val2 )
@@ -5439,16 +5502,16 @@ static short status_calc_aspd_rate(struct block_list *bl, struct status_change *
aspd_rate += sc->data[SC__INVISIBILITY]->val2 * 10 ;
if( sc->data[SC__GROOMY] )
aspd_rate += sc->data[SC__GROOMY]->val2 * 10;
- if( sc->data[SC_SWINGDANCE] )
- aspd_rate -= sc->data[SC_SWINGDANCE]->val2 * 10;
- if( sc->data[SC_DANCEWITHWUG] )
- aspd_rate -= sc->data[SC_DANCEWITHWUG]->val3 * 10;
+ if( sc->data[SC_SWING] )
+ aspd_rate -= sc->data[SC_SWING]->val2 * 10;
+ if( sc->data[SC_DANCE_WITH_WUG] )
+ aspd_rate -= sc->data[SC_DANCE_WITH_WUG]->val3 * 10;
if( sc->data[SC_GLOOMYDAY] )
aspd_rate += sc->data[SC_GLOOMYDAY]->val3 * 10;
if( sc->data[SC_EARTHDRIVE] )
aspd_rate += 250;
- if( sc->data[SC_GT_CHANGE] )
- aspd_rate -= sc->data[SC_GT_CHANGE]->val3 * 10;
+ if( sc->data[SC_GENTLETOUCH_CHANGE] )
+ aspd_rate -= sc->data[SC_GENTLETOUCH_CHANGE]->val3 * 10;
if( sc->data[SC_MELON_BOMB] )
aspd_rate += sc->data[SC_MELON_BOMB]->val1 * 10;
if( sc->data[SC_BOOST500] )
@@ -5474,8 +5537,6 @@ static unsigned short status_calc_dmotion(struct block_list *bl, struct status_c
**/
if( sc->data[SC_ENDURE] || ( bl->type == BL_MOB && (((TBL_MOB*)bl)->status.mode&MD_BOSS) ) )
return 0;
- if( sc->data[SC_CONCENTRATION] )
- return 0;
if( sc->data[SC_RUN] || sc->data[SC_WUGDASH] )
return 0;
@@ -5497,7 +5558,7 @@ static unsigned int status_calc_maxhp(struct block_list *bl, struct status_chang
maxhp += maxhp * sc->data[SC_DELUGE]->val2/100;
if (sc->data[SC_BERSERK] || sc->data[SC__BLOODYLUST])
maxhp += maxhp * 2;
- if(sc->data[SC_MARIONETTE])
+ if(sc->data[SC_MARIONETTE_MASTER])
maxhp -= 1000;
if(sc->data[SC_SOLID_SKIN_OPTION])
maxhp += 2000;// Fix amount.
@@ -5506,8 +5567,8 @@ static unsigned int status_calc_maxhp(struct block_list *bl, struct status_chang
if(sc->data[SC_EARTH_INSIGNIA] && sc->data[SC_EARTH_INSIGNIA]->val1 == 2)
maxhp += 500;
- if(sc->data[SC_MERC_HPUP])
- maxhp += maxhp * sc->data[SC_MERC_HPUP]->val2/100;
+ if(sc->data[SC_MER_HP])
+ maxhp += maxhp * sc->data[SC_MER_HP]->val2/100;
if(sc->data[SC_EPICLESIS])
maxhp += maxhp * 5 * sc->data[SC_EPICLESIS]->val1 / 100;
@@ -5515,18 +5576,18 @@ static unsigned int status_calc_maxhp(struct block_list *bl, struct status_chang
maxhp -= maxhp * 15 / 100;
if(sc->data[SC__WEAKNESS])
maxhp -= maxhp * sc->data[SC__WEAKNESS]->val2 / 100;
- if(sc->data[SC_LERADSDEW])
- maxhp += maxhp * sc->data[SC_LERADSDEW]->val3 / 100;
+ if(sc->data[SC_LERADS_DEW])
+ maxhp += maxhp * sc->data[SC_LERADS_DEW]->val3 / 100;
if(sc->data[SC_FORCEOFVANGUARD])
maxhp += maxhp * 3 * sc->data[SC_FORCEOFVANGUARD]->val1 / 100;
if(sc->data[SC_INSPIRATION]) //Custom value.
maxhp += maxhp * 3 * sc->data[SC_INSPIRATION]->val1 / 100;
if(sc->data[SC_RAISINGDRAGON])
maxhp += maxhp * (2 + sc->data[SC_RAISINGDRAGON]->val1) / 100;
- if(sc->data[SC_GT_CHANGE]) // Max HP decrease: [Skill Level x 4] %
- maxhp -= maxhp * (4 * sc->data[SC_GT_CHANGE]->val1) / 100;
- if(sc->data[SC_GT_REVITALIZE])// Max HP increase: [Skill Level x 2] %
- maxhp += maxhp * (2 * sc->data[SC_GT_REVITALIZE]->val1) / 100;
+ if(sc->data[SC_GENTLETOUCH_CHANGE]) // Max HP decrease: [Skill Level x 4] %
+ maxhp -= maxhp * (4 * sc->data[SC_GENTLETOUCH_CHANGE]->val1) / 100;
+ if(sc->data[SC_GENTLETOUCH_REVITALIZE])// Max HP increase: [Skill Level x 2] %
+ maxhp += maxhp * (2 * sc->data[SC_GENTLETOUCH_REVITALIZE]->val1) / 100;
if(sc->data[SC_MUSTLE_M])
maxhp += maxhp * sc->data[SC_MUSTLE_M]->val1/100;
if(sc->data[SC_MYSTERIOUS_POWDER])
@@ -5537,6 +5598,8 @@ static unsigned int status_calc_maxhp(struct block_list *bl, struct status_chang
maxhp += maxhp * 5 * sc->data[SC_ANGRIFFS_MODUS]->val1 /100;
if (sc->data[SC_GOLDENE_FERSE])
maxhp += maxhp * sc->data[SC_GOLDENE_FERSE]->val2 / 100;
+ if(sc->data[SC_FRIGG_SONG])
+ maxhp += maxhp * sc->data[SC_FRIGG_SONG]->val2 / 100;
return (unsigned int)cap_value(maxhp,1,UINT_MAX);
}
@@ -5550,10 +5613,10 @@ static unsigned int status_calc_maxsp(struct block_list *bl, struct status_chang
maxsp += maxsp * sc->data[SC_INCMSPRATE]->val1/100;
if(sc->data[SC_INCMSP])
maxsp += (sc->data[SC_INCMSP]->val1);
- if(sc->data[SC_SERVICE4U])
- maxsp += maxsp * sc->data[SC_SERVICE4U]->val2/100;
- if(sc->data[SC_MERC_SPUP])
- maxsp += maxsp * sc->data[SC_MERC_SPUP]->val2/100;
+ if(sc->data[SC_SERVICEFORYOU])
+ maxsp += maxsp * sc->data[SC_SERVICEFORYOU]->val2/100;
+ if(sc->data[SC_MER_SP])
+ maxsp += maxsp * sc->data[SC_MER_SP]->val2/100;
if(sc->data[SC_RAISINGDRAGON])
maxsp += maxsp * (2 + sc->data[SC_RAISINGDRAGON]->val1) / 100;
if(sc->data[SC_LIFE_FORCE_F])
@@ -5575,10 +5638,10 @@ static unsigned char status_calc_element(struct block_list *bl, struct status_ch
return ELE_EARTH;
if(sc->data[SC_BENEDICTIO])
return ELE_HOLY;
- if(sc->data[SC_CHANGEUNDEAD])
+ if(sc->data[SC_PROPERTYUNDEAD])
return ELE_UNDEAD;
- if(sc->data[SC_ELEMENTALCHANGE])
- return sc->data[SC_ELEMENTALCHANGE]->val2;
+ if(sc->data[SC_ARMOR_PROPERTY])
+ return sc->data[SC_ARMOR_PROPERTY]->val2;
if(sc->data[SC_SHAPESHIFT])
return sc->data[SC_SHAPESHIFT]->val2;
@@ -5596,10 +5659,10 @@ static unsigned char status_calc_element_lv(struct block_list *bl, struct status
return 1;
if(sc->data[SC_BENEDICTIO])
return 1;
- if(sc->data[SC_CHANGEUNDEAD])
+ if(sc->data[SC_PROPERTYUNDEAD])
return 1;
- if(sc->data[SC_ELEMENTALCHANGE])
- return sc->data[SC_ELEMENTALCHANGE]->val1;
+ if(sc->data[SC_ARMOR_PROPERTY])
+ return sc->data[SC_ARMOR_PROPERTY]->val1;
if(sc->data[SC_SHAPESHIFT])
return 1;
if(sc->data[SC__INVISIBILITY])
@@ -5615,25 +5678,25 @@ unsigned char status_calc_attack_element(struct block_list *bl, struct status_ch
return element;
if(sc->data[SC_ENCHANTARMS])
return sc->data[SC_ENCHANTARMS]->val2;
- if(sc->data[SC_WATERWEAPON]
+ if(sc->data[SC_PROPERTYWATER]
|| (sc->data[SC_WATER_INSIGNIA] && sc->data[SC_WATER_INSIGNIA]->val1 == 2) )
return ELE_WATER;
- if(sc->data[SC_EARTHWEAPON]
+ if(sc->data[SC_PROPERTYGROUND]
|| (sc->data[SC_EARTH_INSIGNIA] && sc->data[SC_EARTH_INSIGNIA]->val1 == 2) )
return ELE_EARTH;
- if(sc->data[SC_FIREWEAPON]
+ if(sc->data[SC_PROPERTYFIRE]
|| (sc->data[SC_FIRE_INSIGNIA] && sc->data[SC_FIRE_INSIGNIA]->val1 == 2) )
return ELE_FIRE;
- if(sc->data[SC_WINDWEAPON]
+ if(sc->data[SC_PROPERTYWIND]
|| (sc->data[SC_WIND_INSIGNIA] && sc->data[SC_WIND_INSIGNIA]->val1 == 2) )
return ELE_WIND;
- if(sc->data[SC_ENCPOISON])
+ if(sc->data[SC_ENCHANTPOISON])
return ELE_POISON;
if(sc->data[SC_ASPERSIO])
return ELE_HOLY;
- if(sc->data[SC_SHADOWWEAPON])
+ if(sc->data[SC_PROPERTYDARK])
return ELE_DARK;
- if(sc->data[SC_GHOSTWEAPON] || sc->data[SC__INVISIBILITY])
+ if(sc->data[SC_PROPERTYTELEKINESIS] || sc->data[SC__INVISIBILITY])
return ELE_GHOST;
if(sc->data[SC_TIDAL_WEAPON_OPTION] || sc->data[SC_TIDAL_WEAPON] )
return ELE_WATER;
@@ -5784,7 +5847,7 @@ int status_get_party_id(struct block_list *bl) {
struct mob_data *md=(TBL_MOB*)bl;
if( md->master_id > 0 ) {
struct map_session_data *msd;
- if (md->special_state.ai && (msd = map_id2sd(md->master_id)) != NULL)
+ if (md->special_state.ai && (msd = iMap->id2sd(md->master_id)) != NULL)
return msd->status.party_id;
return -md->master_id;
}
@@ -5822,7 +5885,7 @@ int status_get_guild_id(struct block_list *bl) {
struct mob_data *md = (struct mob_data *)bl;
if (md->guardian_data) //Guardian's guild [Skotlex]
return md->guardian_data->guild_id;
- if (md->special_state.ai && (msd = map_id2sd(md->master_id)) != NULL)
+ if (md->special_state.ai && (msd = iMap->id2sd(md->master_id)) != NULL)
return msd->status.guild_id; //Alchemist's mobs [Skotlex]
}
break;
@@ -5862,7 +5925,7 @@ int status_get_emblem_id(struct block_list *bl) {
struct mob_data *md = (struct mob_data *)bl;
if (md->guardian_data) //Guardian's guild [Skotlex]
return md->guardian_data->emblem_id;
- if (md->special_state.ai && (msd = map_id2sd(md->master_id)) != NULL)
+ if (md->special_state.ai && (msd = iMap->id2sd(md->master_id)) != NULL)
return msd->guild_emblem_id; //Alchemist's mobs [Skotlex]
}
break;
@@ -6079,14 +6142,15 @@ void status_set_viewdata(struct block_list *bl, int class_)
/// Returns the status_change data of bl or NULL if it doesn't exist.
struct status_change *status_get_sc(struct block_list *bl) {
- if( bl )
- switch (bl->type) {
- case BL_PC: return &((TBL_PC*)bl)->sc;
- case BL_MOB: return &((TBL_MOB*)bl)->sc;
- case BL_NPC: return &((TBL_NPC*)bl)->sc;
- case BL_HOM: return &((TBL_HOM*)bl)->sc;
- case BL_MER: return &((TBL_MER*)bl)->sc;
- case BL_ELEM: return &((TBL_ELEM*)bl)->sc;
+ if( bl ) {
+ switch (bl->type) {
+ case BL_PC: return &((TBL_PC*)bl)->sc;
+ case BL_MOB: return &((TBL_MOB*)bl)->sc;
+ case BL_NPC: return NULL;
+ case BL_HOM: return &((TBL_HOM*)bl)->sc;
+ case BL_MER: return &((TBL_MER*)bl)->sc;
+ case BL_ELEM: return &((TBL_ELEM*)bl)->sc;
+ }
}
return NULL;
}
@@ -6118,14 +6182,14 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti
//Status that are blocked by Golden Thief Bug card or Wand of Hermod
if (status_isimmune(bl))
switch (type) {
- case SC_DECREASEAGI:
+ case SC_DEC_AGI:
case SC_SILENCE:
case SC_COMA:
- case SC_INCREASEAGI:
+ case SC_INC_AGI:
case SC_BLESSING:
case SC_SLOWPOISON:
case SC_IMPOSITIO:
- case SC_AETERNA:
+ case SC_LEXAETERNA:
case SC_SUFFRAGIUM:
case SC_BENEDICTIO:
case SC_PROVIDENCE:
@@ -6136,11 +6200,11 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti
case SC_GLORIA:
case SC_WINDWALK:
case SC_MAGICROD:
- case SC_HALLUCINATION:
+ case SC_ILLUSION:
case SC_STONE:
case SC_QUAGMIRE:
- case SC_SUITON:
- case SC_SWINGDANCE:
+ case SC_NJ_SUITON:
+ case SC_SWING:
case SC__ENERVATION:
case SC__GROOMY:
case SC__IGNORANCE:
@@ -6163,7 +6227,7 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti
return tick;
case SC_DPOISON:
case SC_SILENCE:
- case SC_BLEEDING:
+ case SC_BLOODING:
sc_def = status->vit*100;
sc_def2 = status->luk*10;
break;
@@ -6171,11 +6235,11 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti
sc_def = status->int_*100;
sc_def2 = status->luk*10;
break;
- case SC_DEEPSLEEP:
+ case SC_DEEP_SLEEP:
sc_def = status->int_*50;
tick_def = status->int_*10 + status_get_lv(bl) * 65 / 10; //Seems to be -1 sec every 10 int and -5% chance every 10 int.
break;
- case SC_DECREASEAGI:
+ case SC_DEC_AGI:
case SC_ADORAMUS: //Arch Bishop
if (sd) tick>>=1; //Half duration for players.
case SC_STONE:
@@ -6204,13 +6268,13 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti
sc_def = (status->str + status->int_)*50;
sc_def2 = status->luk*10;
break;
- case SC_ANKLE:
+ case SC_ANKLESNARE:
if(status->mode&MD_BOSS) // Lasts 5 times less on bosses
tick /= 5;
sc_def = status->agi*50;
break;
case SC_MAGICMIRROR:
- case SC_ARMORCHANGE:
+ case SC_STONESKIN:
if (sd) //Duration greatly reduced for players.
tick /= 15;
sc_def2 = status_get_lv(bl)*20 + status->vit*25 + status->agi*10; // Lineal Reduction of Rate
@@ -6229,44 +6293,43 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti
else
tick -= (status->vit + status->luk) / 20 * 1000;
break;
- case SC_BURNING:
- // From iROwiki : http://forums.irowiki.org/showpost.php?p=577240&postcount=583
- tick -= 50*status->luk + 60*status->int_ + 170*status->vit;
- tick = max(tick,10000); // Minimum Duration 10s.
- break;
- case SC_FREEZING:
- tick -= 1000 * ((status->vit + status->dex) / 20);
- tick = max(tick,10000); // Minimum Duration 10s.
- break;
- case SC_OBLIVIONCURSE: // 100% - (100 - 0.8 x INT)
- sc_def = 100 - ( 100 - status->int_* 8 / 10 );
- sc_def = max(sc_def, 5); // minimum of 5%
- break;
- case SC_BITE: // {(Base Success chance) - (Target's AGI / 4)}
- rate -= status->agi*1000/4;
- rate = max(rate,50000); // minimum of 50%
- break;
- case SC_ELECTRICSHOCKER:
- if( bl->type == BL_MOB )
- tick -= 1000 * (status->agi/10);
- break;
- case SC_CRYSTALIZE:
- tick -= (1000*(status->vit/10))+(status_get_lv(bl)/50);
- break;
- case SC_MANDRAGORA:
- sc_def = (status->vit+status->luk)/5;
- break;
- case SC_KYOUGAKU:
- tick -= 30*status->int_;
- break;
- case SC_PARALYSIS:
- tick -= 50 * (status->vit + status->luk); //(1000/20);
- break;
- default:
- //Effect that cannot be reduced? Likely a buff.
- if (!(rnd()%10000 < rate))
- return 0;
- return tick?tick:1;
+ case SC_BURNING:
+ tick -= 75 * status->luk + 125 * status->agi;
+ tick = max(tick,5000); // Minimum Duration 5s.
+ break;
+ case SC_FROSTMISTY:
+ tick -= 1000 * ((status->vit + status->dex) / 20);
+ tick = max(tick,6000); // Minimum Duration 10s.
+ break;
+ case SC_OBLIVIONCURSE: // 100% - (100 - 0.8 x INT)
+ sc_def = 100 - ( 100 - status->int_* 8 / 10 );
+ sc_def = max(sc_def, 5); // minimum of 5%
+ break;
+ case SC_WUGBITE: // {(Base Success chance) - (Target's AGI / 4)}
+ rate -= status->agi*100/4;
+ rate = max(rate,5000); // minimum of 50%
+ break;
+ case SC_ELECTRICSHOCKER:
+ if( bl->type == BL_MOB )
+ tick -= 1000 * (status->agi/10);
+ break;
+ case SC_CRYSTALIZE:
+ tick -= (1000*(status->vit/10))+(status_get_lv(bl)/50);
+ break;
+ case SC_MANDRAGORA:
+ sc_def = (status->vit+status->luk)/5;
+ break;
+ case SC_KYOUGAKU:
+ tick -= 1000 * status_get_int(bl) / 20;
+ break;
+ case SC_NEEDLE_OF_PARALYZE:
+ tick -= 50 * (status->vit + status->luk); //(1000/20);
+ break;
+ default:
+ //Effect that cannot be reduced? Likely a buff.
+ if (!(rnd()%10000 < rate))
+ return 0;
+ return tick?tick:1;
}
if (sd) {
@@ -6319,7 +6382,7 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti
//Minimum chances
switch (type) {
- case SC_BITE:
+ case SC_WUGBITE:
rate = max(rate, 5000); //Minimum of 50%
break;
}
@@ -6329,8 +6392,8 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti
{
if( sd->reseff[type-SC_COMMON_MIN] > 0 )
rate -= rate*sd->reseff[type-SC_COMMON_MIN]/10000;
- if( sd->sc.data[SC_COMMONSC_RESIST] )
- rate -= rate*sd->sc.data[SC_COMMONSC_RESIST]->val1/100;
+ if( sd->sc.data[SC_TARGET_BLOOD] )
+ rate -= rate*sd->sc.data[SC_TARGET_BLOOD]->val1/100;
}
}
@@ -6349,13 +6412,13 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti
//Minimum durations
switch (type) {
- case SC_ANKLE:
+ case SC_ANKLESNARE:
case SC_MARSHOFABYSS:
case SC_STASIS:
tick = max(tick, 5000); //Minimum duration 5s
break;
case SC_BURNING:
- case SC_FREEZING:
+ case SC_FROSTMISTY:
tick = max(tick, 10000); //Minimum duration 10s
break;
default:
@@ -6458,32 +6521,31 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
if( type >= SC_COMMON_MIN && type <= SC_COMMON_MAX) // Confirmed.
return 0; // Immune to status ailements
switch( type ) {
- case SC_QUAGMIRE://Tester said it protects against this and decrease agi.
- case SC_DECREASEAGI:
- case SC_BURNING:
- case SC_FREEZING:
- //case SC_WHITEIMPRISON://Need confirm. Protected against this in the past. [Rytech]
- case SC_MARSHOFABYSS:
- case SC_TOXIN:
- case SC_PARALYSE:
- case SC_VENOMBLEED:
- case SC_MAGICMUSHROOM:
- case SC_DEATHHURT:
- case SC_PYREXIA:
- case SC_OBLIVIONCURSE:
- case SC_LEECHESEND:
- case SC_CRYSTALIZE: ////08/31/2011 - Class Balance Changes
- case SC_DEEPSLEEP:
- case SC_MANDRAGORA:
+ case SC_QUAGMIRE://Tester said it protects against this and decrease agi.
+ case SC_DEC_AGI:
+ case SC_BURNING:
+ case SC_FROSTMISTY:
+ //case SC_WHITEIMPRISON://Need confirm. Protected against this in the past. [Rytech]
+ case SC_MARSHOFABYSS:
+ case SC_TOXIN:
+ case SC_PARALYSE:
+ case SC_VENOMBLEED:
+ case SC_MAGICMUSHROOM:
+ case SC_DEATHHURT:
+ case SC_PYREXIA:
+ case SC_OBLIVIONCURSE:
+ case SC_LEECHESEND:
+ case SC_CRYSTALIZE: ////08/31/2011 - Class Balance Changes
+ case SC_DEEP_SLEEP:
+ case SC_MANDRAGORA:
return 0;
}
- }
- else if( sc->data[SC_INSPIRATION] ) {
+ } else if( sc->data[SC_INSPIRATION] ) {
if( type >= SC_COMMON_MIN && type <= SC_COMMON_MAX )
return 0; // Immune to status ailements
switch( type ) {
- case SC_DEEPSLEEP:
- case SC_SATURDAYNIGHTFEVER:
+ case SC_DEEP_SLEEP:
+ case SC_SATURDAY_NIGHT_FEVER:
case SC_PYREXIA:
case SC_DEATHHURT:
case SC_MAGICMUSHROOM:
@@ -6520,281 +6582,286 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
|| (type==SC_ANGRIFFS_MODUS && sc->data[SC_GOLDENE_FERSE])
)
return 0;
- case SC_STONE:
- if(sc->data[SC_POWER_OF_GAIA])
- return 0;
- case SC_FREEZE:
- //Undead are immune to Freeze/Stone
- if (undead_flag && !(flag&1))
- return 0;
- case SC_DEEPSLEEP:
- case SC_SLEEP:
- case SC_STUN:
- case SC_FREEZING:
- case SC_CRYSTALIZE:
- if (sc->opt1)
- return 0; //Cannot override other opt1 status changes. [Skotlex]
- if((type == SC_FREEZE || type == SC_FREEZING || type == SC_CRYSTALIZE) && sc->data[SC_WARMER])
- return 0; //Immune to Frozen and Freezing status if under Warmer status. [Jobbie]
- break;
-
- //There all like berserk, do not everlap each other
- case SC__BLOODYLUST:
- if(!sd) return 0; //should only affect player
- case SC_BERSERK:
- if (((type == SC_BERSERK) && (sc->data[SC_SATURDAYNIGHTFEVER] || sc->data[SC__BLOODYLUST]))
- || ((type == SC__BLOODYLUST) && (sc->data[SC_SATURDAYNIGHTFEVER] || sc->data[SC_BERSERK]))
- )
- return 0;
+ case SC_STONE:
+ if(sc->data[SC_POWER_OF_GAIA])
+ return 0;
+ case SC_FREEZE:
+ //Undead are immune to Freeze/Stone
+ if (undead_flag && !(flag&1))
+ return 0;
+ case SC_DEEP_SLEEP:
+ case SC_SLEEP:
+ case SC_STUN:
+ case SC_FROSTMISTY:
+ case SC_CRYSTALIZE:
+ if (sc->opt1)
+ return 0; //Cannot override other opt1 status changes. [Skotlex]
+ if((type == SC_FREEZE || type == SC_FROSTMISTY || type == SC_CRYSTALIZE) && sc->data[SC_WARMER])
+ return 0; //Immune to Frozen and Freezing status if under Warmer status. [Jobbie]
break;
- case SC_BURNING:
- if(sc->opt1 || sc->data[SC_FREEZING])
- return 0;
- break;
+ //There all like berserk, do not everlap each other
+ case SC__BLOODYLUST:
+ if(!sd) return 0; //should only affect player
+ case SC_BERSERK:
+ if (((type == SC_BERSERK) && (sc->data[SC_SATURDAY_NIGHT_FEVER] || sc->data[SC__BLOODYLUST]))
+ || ((type == SC__BLOODYLUST) && (sc->data[SC_SATURDAY_NIGHT_FEVER] || sc->data[SC_BERSERK]))
+ )
+ return 0;
+ break;
- case SC_SIGNUMCRUCIS:
- //Only affects demons and undead element (but not players)
- if((!undead_flag && status->race!=RC_DEMON) || bl->type == BL_PC)
- return 0;
- break;
- case SC_AETERNA:
- if( (sc->data[SC_STONE] && sc->opt1 == OPT1_STONE) || sc->data[SC_FREEZE] )
- return 0;
- break;
- case SC_KYRIE:
- if (bl->type == BL_MOB)
- return 0;
- break;
- case SC_OVERTHRUST:
- if (sc->data[SC_MAXOVERTHRUST])
- return 0; //Overthrust can't take effect if under Max Overthrust. [Skotlex]
- case SC_MAXOVERTHRUST:
- if( sc->option&OPTION_MADOGEAR )
- return 0;//Overthrust and Overthrust Max cannot be used on Mado Gear [Ind]
- break;
- case SC_ADRENALINE:
- if(sd && !pc_check_weapontype(sd,skill->get_weapontype(BS_ADRENALINE)))
- return 0;
- if (sc->data[SC_QUAGMIRE] ||
- sc->data[SC_DECREASEAGI] ||
- sc->option&OPTION_MADOGEAR //Adrenaline doesn't affect Mado Gear [Ind]
- )
- return 0;
- break;
- case SC_ADRENALINE2:
- if(sd && !pc_check_weapontype(sd,skill->get_weapontype(BS_ADRENALINE2)))
- return 0;
- if (sc->data[SC_QUAGMIRE] ||
- sc->data[SC_DECREASEAGI]
- )
- return 0;
- break;
- case SC_MAGNIFICAT:
- if( sc->option&OPTION_MADOGEAR ) //Mado is immune to magnificat
- return 0;
+ case SC_BURNING:
+ if(sc->opt1 || sc->data[SC_FROSTMISTY])
+ return 0;
break;
- case SC_ONEHAND:
- case SC_MERC_QUICKEN:
- case SC_TWOHANDQUICKEN:
- if(sc->data[SC_DECREASEAGI])
- return 0;
- case SC_INCREASEAGI:
- if(sd && pc_issit(sd)){
- pc_setstand(sd);
- }
-
- case SC_CONCENTRATE:
- case SC_SPEARQUICKEN:
- case SC_TRUESIGHT:
- case SC_WINDWALK:
- case SC_CARTBOOST:
- case SC_ASSNCROS:
- if (sc->data[SC_QUAGMIRE])
- return 0;
- if(sc->option&OPTION_MADOGEAR)
- return 0;//Mado is immune to increase agi, wind walk, cart boost, etc (others above) [Ind]
- break;
- case SC_CLOAKING:
- //Avoid cloaking with no wall and low skill level. [Skotlex]
- //Due to the cloaking card, we have to check the wall versus to known
- //skill level rather than the used one. [Skotlex]
- //if (sd && val1 < 3 && skill_check_cloaking(bl,NULL))
- if( sd && pc_checkskill(sd, AS_CLOAKING) < 3 && !skill->check_cloaking(bl,NULL) )
- return 0;
- break;
- case SC_MODECHANGE:
- {
- int mode;
- struct status_data *bstatus = status_get_base_status(bl);
- if (!bstatus) return 0;
- if (sc->data[type])
- { //Pile up with previous values.
- if(!val2) val2 = sc->data[type]->val2;
- val3 |= sc->data[type]->val3;
- val4 |= sc->data[type]->val4;
- }
- mode = val2?val2:bstatus->mode; //Base mode
- if (val4) mode&=~val4; //Del mode
- if (val3) mode|= val3; //Add mode
- if (mode == bstatus->mode) { //No change.
- if (sc->data[type]) //Abort previous status
- return status_change_end(bl, type, INVALID_TIMER);
- return 0;
- }
- }
- break;
- //Strip skills, need to divest something or it fails.
- case SC_STRIPWEAPON:
- if (sd && !(flag&4)) { //apply sc anyway if loading saved sc_data
- int i;
- opt_flag = 0; //Reuse to check success condition.
- if(sd->bonus.unstripable_equip&EQP_WEAPON)
+ case SC_CRUCIS:
+ //Only affects demons and undead element (but not players)
+ if((!undead_flag && status->race!=RC_DEMON) || bl->type == BL_PC)
return 0;
+ break;
+ case SC_LEXAETERNA:
+ if( (sc->data[SC_STONE] && sc->opt1 == OPT1_STONE) || sc->data[SC_FREEZE] )
+ return 0;
+ break;
+ case SC_KYRIE:
+ if (bl->type == BL_MOB)
+ return 0;
+ break;
+ case SC_OVERTHRUST:
+ if (sc->data[SC_OVERTHRUSTMAX])
+ return 0; //Overthrust can't take effect if under Max Overthrust. [Skotlex]
+ case SC_OVERTHRUSTMAX:
+ if( sc->option&OPTION_MADOGEAR )
+ return 0;//Overthrust and Overthrust Max cannot be used on Mado Gear [Ind]
+ break;
+ case SC_ADRENALINE:
+ if(sd && !pc_check_weapontype(sd,skill->get_weapontype(BS_ADRENALINE)))
+ return 0;
+ if (sc->data[SC_QUAGMIRE] ||
+ sc->data[SC_DEC_AGI] ||
+ sc->option&OPTION_MADOGEAR //Adrenaline doesn't affect Mado Gear [Ind]
+ )
+ return 0;
+ break;
+ case SC_ADRENALINE2:
+ if(sd && !pc_check_weapontype(sd,skill->get_weapontype(BS_ADRENALINE2)))
+ return 0;
+ if (sc->data[SC_QUAGMIRE] ||
+ sc->data[SC_DEC_AGI]
+ )
+ return 0;
+ break;
+ case SC_MAGNIFICAT:
+ if( sc->data[SC_OFFERTORIUM] || sc->option&OPTION_MADOGEAR ) //Mado is immune to magnificat
+ return 0;
+ break;
+ case SC_ONEHANDQUICKEN:
+ case SC_MER_QUICKEN:
+ case SC_TWOHANDQUICKEN:
+ if(sc->data[SC_DEC_AGI])
+ return 0;
+
+ case SC_INC_AGI:
+ if(sd && pc_issit(sd)){
+ pc->setstand(sd);
+ clif->standing(&sd->bl);
+ }
- i = sd->equip_index[EQI_HAND_R];
- if (i>=0 && sd->inventory_data[i] && sd->inventory_data[i]->type == IT_WEAPON) {
- opt_flag|=2;
- pc_unequipitem(sd,i,3);
+ case SC_CONCENTRATION:
+ case SC_SPEARQUICKEN:
+ case SC_TRUESIGHT:
+ case SC_WINDWALK:
+ case SC_CARTBOOST:
+ case SC_ASSNCROS:
+ if (sc->data[SC_QUAGMIRE])
+ return 0;
+ if(sc->option&OPTION_MADOGEAR)
+ return 0;//Mado is immune to increase agi, wind walk, cart boost, etc (others above) [Ind]
+ break;
+ case SC_CLOAKING:
+ //Avoid cloaking with no wall and low skill level. [Skotlex]
+ //Due to the cloaking card, we have to check the wall versus to known
+ //skill level rather than the used one. [Skotlex]
+ //if (sd && val1 < 3 && skill_check_cloaking(bl,NULL))
+ if( sd && pc->checkskill(sd, AS_CLOAKING) < 3 && !skill->check_cloaking(bl,NULL) )
+ return 0;
+ break;
+ case SC_MODECHANGE:
+ {
+ int mode;
+ struct status_data *bstatus = status_get_base_status(bl);
+ if (!bstatus) return 0;
+ if (sc->data[type])
+ { //Pile up with previous values.
+ if(!val2) val2 = sc->data[type]->val2;
+ val3 |= sc->data[type]->val3;
+ val4 |= sc->data[type]->val4;
+ }
+ mode = val2?val2:bstatus->mode; //Base mode
+ if (val4) mode&=~val4; //Del mode
+ if (val3) mode|= val3; //Add mode
+ if (mode == bstatus->mode) { //No change.
+ if (sc->data[type]) //Abort previous status
+ return status_change_end(bl, type, INVALID_TIMER);
+ return 0;
}
- if (!opt_flag) return 0;
}
- if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
- break;
- case SC_STRIPSHIELD:
- if( val2 == 1 ) val2 = 0; //GX effect. Do not take shield off..
- else
- if (sd && !(flag&4)) {
- int i;
- if(sd->bonus.unstripable_equip&EQP_SHIELD)
+ break;
+ //Strip skills, need to divest something or it fails.
+ case SC_NOEQUIPWEAPON:
+ if (sd && !(flag&4)) { //apply sc anyway if loading saved sc_data
+ int i;
+ opt_flag = 0; //Reuse to check success condition.
+ if(sd->bonus.unstripable_equip&EQP_WEAPON)
+ return 0;
+
+ i = sd->equip_index[EQI_HAND_R];
+ if (i>=0 && sd->inventory_data[i] && sd->inventory_data[i]->type == IT_WEAPON) {
+ opt_flag|=2;
+ pc->unequipitem(sd,i,3);
+ }
+ if (!opt_flag) return 0;
+ }
+ if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
+ break;
+ case SC_NOEQUIPSHIELD:
+ if( val2 == 1 ) val2 = 0; //GX effect. Do not take shield off..
+ else
+ if (sd && !(flag&4)) {
+ int i;
+ if(sd->bonus.unstripable_equip&EQP_SHIELD)
+ return 0;
+ i = sd->equip_index[EQI_HAND_L];
+ if ( i < 0 || !sd->inventory_data[i] || sd->inventory_data[i]->type != IT_ARMOR )
+ return 0;
+ pc->unequipitem(sd,i,3);
+ }
+ if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
+ break;
+ case SC_NOEQUIPARMOR:
+ if (sd && !(flag&4)) {
+ int i;
+ if(sd->bonus.unstripable_equip&EQP_ARMOR)
+ return 0;
+ i = sd->equip_index[EQI_ARMOR];
+ if ( i < 0 || !sd->inventory_data[i] )
+ return 0;
+ pc->unequipitem(sd,i,3);
+ }
+ if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
+ break;
+ case SC_NOEQUIPHELM:
+ if (sd && !(flag&4)) {
+ int i;
+ if(sd->bonus.unstripable_equip&EQP_HELM)
+ return 0;
+ i = sd->equip_index[EQI_HEAD_TOP];
+ if ( i < 0 || !sd->inventory_data[i] )
+ return 0;
+ pc->unequipitem(sd,i,3);
+ }
+ if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
+ break;
+ case SC_MER_FLEE:
+ case SC_MER_ATK:
+ case SC_MER_HP:
+ case SC_MER_SP:
+ case SC_MER_HIT:
+ if( bl->type != BL_MER )
+ return 0; // Stats only for Mercenaries
+ break;
+ case SC_FOOD_STR:
+ if (sc->data[SC_FOOD_STR_CASH] && sc->data[SC_FOOD_STR_CASH]->val1 > val1)
return 0;
- i = sd->equip_index[EQI_HAND_L];
- if ( i < 0 || !sd->inventory_data[i] || sd->inventory_data[i]->type != IT_ARMOR )
+ break;
+ case SC_FOOD_AGI:
+ if (sc->data[SC_FOOD_AGI_CASH] && sc->data[SC_FOOD_AGI_CASH]->val1 > val1)
return 0;
- pc_unequipitem(sd,i,3);
- }
- if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
- break;
- case SC_STRIPARMOR:
- if (sd && !(flag&4)) {
- int i;
- if(sd->bonus.unstripable_equip&EQP_ARMOR)
+ break;
+ case SC_FOOD_VIT:
+ if (sc->data[SC_FOOD_VIT_CASH] && sc->data[SC_FOOD_VIT_CASH]->val1 > val1)
return 0;
- i = sd->equip_index[EQI_ARMOR];
- if ( i < 0 || !sd->inventory_data[i] )
+ break;
+ case SC_FOOD_INT:
+ if (sc->data[SC_FOOD_INT_CASH] && sc->data[SC_FOOD_INT_CASH]->val1 > val1)
return 0;
- pc_unequipitem(sd,i,3);
- }
- if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
- break;
- case SC_STRIPHELM:
- if (sd && !(flag&4)) {
- int i;
- if(sd->bonus.unstripable_equip&EQP_HELM)
+ break;
+ case SC_FOOD_DEX:
+ if (sc->data[SC_FOOD_DEX_CASH] && sc->data[SC_FOOD_DEX_CASH]->val1 > val1)
return 0;
- i = sd->equip_index[EQI_HEAD_TOP];
- if ( i < 0 || !sd->inventory_data[i] )
+ break;
+ case SC_FOOD_LUK:
+ if (sc->data[SC_FOOD_LUK_CASH] && sc->data[SC_FOOD_LUK_CASH]->val1 > val1)
return 0;
- pc_unequipitem(sd,i,3);
- }
- if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
- break;
- case SC_MERC_FLEEUP:
- case SC_MERC_ATKUP:
- case SC_MERC_HPUP:
- case SC_MERC_SPUP:
- case SC_MERC_HITUP:
- if( bl->type != BL_MER )
- return 0; // Stats only for Mercenaries
- break;
- case SC_STRFOOD:
- if (sc->data[SC_FOOD_STR_CASH] && sc->data[SC_FOOD_STR_CASH]->val1 > val1)
- return 0;
- break;
- case SC_AGIFOOD:
- if (sc->data[SC_FOOD_AGI_CASH] && sc->data[SC_FOOD_AGI_CASH]->val1 > val1)
- return 0;
- break;
- case SC_VITFOOD:
- if (sc->data[SC_FOOD_VIT_CASH] && sc->data[SC_FOOD_VIT_CASH]->val1 > val1)
- return 0;
- break;
- case SC_INTFOOD:
- if (sc->data[SC_FOOD_INT_CASH] && sc->data[SC_FOOD_INT_CASH]->val1 > val1)
- return 0;
- break;
- case SC_DEXFOOD:
- if (sc->data[SC_FOOD_DEX_CASH] && sc->data[SC_FOOD_DEX_CASH]->val1 > val1)
- return 0;
- break;
- case SC_LUKFOOD:
- if (sc->data[SC_FOOD_LUK_CASH] && sc->data[SC_FOOD_LUK_CASH]->val1 > val1)
- return 0;
- break;
- case SC_FOOD_STR_CASH:
- if (sc->data[SC_STRFOOD] && sc->data[SC_STRFOOD]->val1 > val1)
- return 0;
- break;
- case SC_FOOD_AGI_CASH:
- if (sc->data[SC_AGIFOOD] && sc->data[SC_AGIFOOD]->val1 > val1)
- return 0;
- break;
- case SC_FOOD_VIT_CASH:
- if (sc->data[SC_VITFOOD] && sc->data[SC_VITFOOD]->val1 > val1)
- return 0;
- break;
- case SC_FOOD_INT_CASH:
- if (sc->data[SC_INTFOOD] && sc->data[SC_INTFOOD]->val1 > val1)
- return 0;
- break;
- case SC_FOOD_DEX_CASH:
- if (sc->data[SC_DEXFOOD] && sc->data[SC_DEXFOOD]->val1 > val1)
- return 0;
- break;
- case SC_FOOD_LUK_CASH:
- if (sc->data[SC_LUKFOOD] && sc->data[SC_LUKFOOD]->val1 > val1)
- return 0;
- break;
- case SC_CAMOUFLAGE:
- if( sd && pc_checkskill(sd, RA_CAMOUFLAGE) < 3 && !skill->check_camouflage(bl,NULL) )
- return 0;
- break;
- case SC__STRIPACCESSORY:
- if( sd ) {
- int i = -1;
- if( !(sd->bonus.unstripable_equip&EQI_ACC_L) ) {
- i = sd->equip_index[EQI_ACC_L];
- if( i >= 0 && sd->inventory_data[i] && sd->inventory_data[i]->type == IT_ARMOR )
- pc_unequipitem(sd,i,3); //L-Accessory
- } if( !(sd->bonus.unstripable_equip&EQI_ACC_R) ) {
- i = sd->equip_index[EQI_ACC_R];
- if( i >= 0 && sd->inventory_data[i] && sd->inventory_data[i]->type == IT_ARMOR )
- pc_unequipitem(sd,i,3); //R-Accessory
- }
- if( i < 0 )
+ break;
+ case SC_FOOD_STR_CASH:
+ if (sc->data[SC_FOOD_STR] && sc->data[SC_FOOD_STR]->val1 > val1)
+ return 0;
+ break;
+ case SC_FOOD_AGI_CASH:
+ if (sc->data[SC_FOOD_AGI] && sc->data[SC_FOOD_AGI]->val1 > val1)
+ return 0;
+ break;
+ case SC_FOOD_VIT_CASH:
+ if (sc->data[SC_FOOD_VIT] && sc->data[SC_FOOD_VIT]->val1 > val1)
+ return 0;
+ break;
+ case SC_FOOD_INT_CASH:
+ if (sc->data[SC_FOOD_INT] && sc->data[SC_FOOD_INT]->val1 > val1)
return 0;
- }
- if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
- break;
- case SC_TOXIN:
- case SC_PARALYSE:
- case SC_VENOMBLEED:
- case SC_MAGICMUSHROOM:
- case SC_DEATHHURT:
- case SC_PYREXIA:
- case SC_OBLIVIONCURSE:
- case SC_LEECHESEND:
- { // it doesn't stack or even renewed
- int i = SC_TOXIN;
- for(; i<= SC_LEECHESEND; i++)
- if(sc->data[i]) return 0;
- }
- break;
- case SC_SATURDAYNIGHTFEVER:
- if (sc->data[SC_BERSERK] || sc->data[SC_INSPIRATION] || sc->data[SC__BLOODYLUST])
- return 0;
break;
+ case SC_FOOD_DEX_CASH:
+ if (sc->data[SC_FOOD_DEX] && sc->data[SC_FOOD_DEX]->val1 > val1)
+ return 0;
+ break;
+ case SC_FOOD_LUK_CASH:
+ if (sc->data[SC_FOOD_LUK] && sc->data[SC_FOOD_LUK]->val1 > val1)
+ return 0;
+ break;
+ case SC_CAMOUFLAGE:
+ if( sd && pc->checkskill(sd, RA_CAMOUFLAGE) < 3 && !skill->check_camouflage(bl,NULL) )
+ return 0;
+ break;
+ case SC__STRIPACCESSARY:
+ if( sd ) {
+ int i = -1;
+ if( !(sd->bonus.unstripable_equip&EQI_ACC_L) ) {
+ i = sd->equip_index[EQI_ACC_L];
+ if( i >= 0 && sd->inventory_data[i] && sd->inventory_data[i]->type == IT_ARMOR )
+ pc->unequipitem(sd,i,3); //L-Accessory
+ } if( !(sd->bonus.unstripable_equip&EQI_ACC_R) ) {
+ i = sd->equip_index[EQI_ACC_R];
+ if( i >= 0 && sd->inventory_data[i] && sd->inventory_data[i]->type == IT_ARMOR )
+ pc->unequipitem(sd,i,3); //R-Accessory
+ }
+ if( i < 0 )
+ return 0;
+ }
+ if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC
+ break;
+ case SC_TOXIN:
+ case SC_PARALYSE:
+ case SC_VENOMBLEED:
+ case SC_MAGICMUSHROOM:
+ case SC_DEATHHURT:
+ case SC_PYREXIA:
+ case SC_OBLIVIONCURSE:
+ case SC_LEECHESEND:
+ { // it doesn't stack or even renewed
+ int i = SC_TOXIN;
+ for(; i<= SC_LEECHESEND; i++)
+ if(sc->data[i]) return 0;
+ }
+ break;
+ case SC_SATURDAY_NIGHT_FEVER:
+ if (sc->data[SC_BERSERK] || sc->data[SC_INSPIRATION] || sc->data[SC__BLOODYLUST])
+ return 0;
+ break;
+ case SC_OFFERTORIUM:
+ if (sc->data[SC_MAGNIFICAT])
+ return 0;
+ break;
}
//Check for BOSS resistances
@@ -6803,20 +6870,20 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
return 0;
switch (type) {
case SC_BLESSING:
- case SC_DECREASEAGI:
+ case SC_DEC_AGI:
case SC_PROVOKE:
case SC_COMA:
case SC_GRAVITATION:
- case SC_SUITON:
+ case SC_NJ_SUITON:
case SC_RICHMANKIM:
case SC_ROKISWEIL:
case SC_FOGWALL:
- case SC_FREEZING:
+ case SC_FROSTMISTY:
case SC_BURNING:
case SC_MARSHOFABYSS:
case SC_ADORAMUS:
- case SC_PARALYSIS:
- case SC_DEEPSLEEP:
+ case SC_NEEDLE_OF_PARALYZE:
+ case SC_DEEP_SLEEP:
case SC_CRYSTALIZE:
// Exploit prevention - kRO Fix
@@ -6830,7 +6897,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_LEECHESEND:
// Ranger Effects
- case SC_BITE:
+ case SC_WUGBITE:
case SC_ELECTRICSHOCKER:
case SC_MAGNETICFIELD:
@@ -6840,255 +6907,259 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
//Before overlapping fail, one must check for status cured.
switch (type) {
- case SC_BLESSING:
- //TO-DO Blessing and Agi up should do 1 damage against players on Undead Status, even on PvM
- //but cannot be plagiarized (this requires aegis investigation on packets and official behavior) [Brainstorm]
- if ((!undead_flag && status->race!=RC_DEMON) || bl->type == BL_PC) {
- status_change_end(bl, SC_CURSE, INVALID_TIMER);
- if (sc->data[SC_STONE] && sc->opt1 == OPT1_STONE)
- status_change_end(bl, SC_STONE, INVALID_TIMER);
- }
- break;
- case SC_INCREASEAGI:
- status_change_end(bl, SC_DECREASEAGI, INVALID_TIMER);
- break;
- case SC_QUAGMIRE:
- status_change_end(bl, SC_CONCENTRATE, INVALID_TIMER);
- status_change_end(bl, SC_TRUESIGHT, INVALID_TIMER);
- status_change_end(bl, SC_WINDWALK, INVALID_TIMER);
- //Also blocks the ones below...
- case SC_DECREASEAGI:
- status_change_end(bl, SC_CARTBOOST, INVALID_TIMER);
- //Also blocks the ones below...
- case SC_DONTFORGETME:
- status_change_end(bl, SC_INCREASEAGI, INVALID_TIMER);
- status_change_end(bl, SC_ADRENALINE, INVALID_TIMER);
- status_change_end(bl, SC_ADRENALINE2, INVALID_TIMER);
- status_change_end(bl, SC_SPEARQUICKEN, INVALID_TIMER);
- status_change_end(bl, SC_TWOHANDQUICKEN, INVALID_TIMER);
- status_change_end(bl, SC_ONEHAND, INVALID_TIMER);
- status_change_end(bl, SC_MERC_QUICKEN, INVALID_TIMER);
- status_change_end(bl, SC_ACCELERATION, INVALID_TIMER);
- break;
- case SC_ONEHAND:
- //Removes the Aspd potion effect, as reported by Vicious. [Skotlex]
- status_change_end(bl, SC_ASPDPOTION0, INVALID_TIMER);
- status_change_end(bl, SC_ASPDPOTION1, INVALID_TIMER);
- status_change_end(bl, SC_ASPDPOTION2, INVALID_TIMER);
- status_change_end(bl, SC_ASPDPOTION3, INVALID_TIMER);
- break;
- case SC_MAXOVERTHRUST:
- //Cancels Normal Overthrust. [Skotlex]
- status_change_end(bl, SC_OVERTHRUST, INVALID_TIMER);
- break;
- case SC_KYRIE:
- //Cancels Assumptio
- status_change_end(bl, SC_ASSUMPTIO, INVALID_TIMER);
- break;
- case SC_DELUGE:
- if (sc->data[SC_FOGWALL] && sc->data[SC_BLIND])
- status_change_end(bl, SC_BLIND, INVALID_TIMER);
- break;
- case SC_SILENCE:
- if (sc->data[SC_GOSPEL] && sc->data[SC_GOSPEL]->val4 == BCT_SELF)
- status_change_end(bl, SC_GOSPEL, INVALID_TIMER);
- break;
- case SC_HIDING:
- status_change_end(bl, SC_CLOSECONFINE, INVALID_TIMER);
- status_change_end(bl, SC_CLOSECONFINE2, INVALID_TIMER);
- break;
- case SC__BLOODYLUST:
- case SC_BERSERK:
- if(battle_config.berserk_cancels_buffs) {
- status_change_end(bl, SC_ONEHAND, INVALID_TIMER);
- status_change_end(bl, SC_TWOHANDQUICKEN, INVALID_TIMER);
+ case SC_BLESSING:
+ //TO-DO Blessing and Agi up should do 1 damage against players on Undead Status, even on PvM
+ //but cannot be plagiarized (this requires aegis investigation on packets and official behavior) [Brainstorm]
+ if ((!undead_flag && status->race!=RC_DEMON) || bl->type == BL_PC) {
+ status_change_end(bl, SC_CURSE, INVALID_TIMER);
+ if (sc->data[SC_STONE] && sc->opt1 == OPT1_STONE)
+ status_change_end(bl, SC_STONE, INVALID_TIMER);
+ }
+ break;
+ case SC_INC_AGI:
+ status_change_end(bl, SC_DEC_AGI, INVALID_TIMER);
+ break;
+ case SC_QUAGMIRE:
status_change_end(bl, SC_CONCENTRATION, INVALID_TIMER);
- status_change_end(bl, SC_PARRYING, INVALID_TIMER);
- status_change_end(bl, SC_AURABLADE, INVALID_TIMER);
- status_change_end(bl, SC_MERC_QUICKEN, INVALID_TIMER);
- }
-#ifdef RENEWAL
- else {
+ status_change_end(bl, SC_TRUESIGHT, INVALID_TIMER);
+ status_change_end(bl, SC_WINDWALK, INVALID_TIMER);
+ //Also blocks the ones below...
+ case SC_DEC_AGI:
+ status_change_end(bl, SC_CARTBOOST, INVALID_TIMER);
+ //Also blocks the ones below...
+ case SC_DONTFORGETME:
+ status_change_end(bl, SC_INC_AGI, INVALID_TIMER);
+ status_change_end(bl, SC_ADRENALINE, INVALID_TIMER);
+ status_change_end(bl, SC_ADRENALINE2, INVALID_TIMER);
+ status_change_end(bl, SC_SPEARQUICKEN, INVALID_TIMER);
status_change_end(bl, SC_TWOHANDQUICKEN, INVALID_TIMER);
- }
-#endif
- break;
- case SC_ASSUMPTIO:
- status_change_end(bl, SC_KYRIE, INVALID_TIMER);
- status_change_end(bl, SC_KAITE, INVALID_TIMER);
- break;
- case SC_KAITE:
- status_change_end(bl, SC_ASSUMPTIO, INVALID_TIMER);
- break;
- case SC_CARTBOOST:
- if(sc->data[SC_DECREASEAGI])
- { //Cancel Decrease Agi, but take no further effect [Skotlex]
- status_change_end(bl, SC_DECREASEAGI, INVALID_TIMER);
- return 0;
- }
- break;
- case SC_FUSION:
- status_change_end(bl, SC_SPIRIT, INVALID_TIMER);
- break;
- case SC_ADJUSTMENT:
- status_change_end(bl, SC_MADNESSCANCEL, INVALID_TIMER);
- break;
- case SC_MADNESSCANCEL:
- status_change_end(bl, SC_ADJUSTMENT, INVALID_TIMER);
- break;
- //NPC_CHANGEUNDEAD will debuff Blessing and Agi Up
- case SC_CHANGEUNDEAD:
- status_change_end(bl, SC_BLESSING, INVALID_TIMER);
- status_change_end(bl, SC_INCREASEAGI, INVALID_TIMER);
- break;
- case SC_STRFOOD:
- status_change_end(bl, SC_FOOD_STR_CASH, INVALID_TIMER);
- break;
- case SC_AGIFOOD:
- status_change_end(bl, SC_FOOD_AGI_CASH, INVALID_TIMER);
- break;
- case SC_VITFOOD:
- status_change_end(bl, SC_FOOD_VIT_CASH, INVALID_TIMER);
- break;
- case SC_INTFOOD:
- status_change_end(bl, SC_FOOD_INT_CASH, INVALID_TIMER);
- break;
- case SC_DEXFOOD:
- status_change_end(bl, SC_FOOD_DEX_CASH, INVALID_TIMER);
- break;
- case SC_LUKFOOD:
- status_change_end(bl, SC_FOOD_LUK_CASH, INVALID_TIMER);
- break;
- case SC_FOOD_STR_CASH:
- status_change_end(bl, SC_STRFOOD, INVALID_TIMER);
- break;
- case SC_FOOD_AGI_CASH:
- status_change_end(bl, SC_AGIFOOD, INVALID_TIMER);
- break;
- case SC_FOOD_VIT_CASH:
- status_change_end(bl, SC_VITFOOD, INVALID_TIMER);
- break;
- case SC_FOOD_INT_CASH:
- status_change_end(bl, SC_INTFOOD, INVALID_TIMER);
- break;
- case SC_FOOD_DEX_CASH:
- status_change_end(bl, SC_DEXFOOD, INVALID_TIMER);
- break;
- case SC_FOOD_LUK_CASH:
- status_change_end(bl, SC_LUKFOOD, INVALID_TIMER);
- break;
- case SC_FIGHTINGSPIRIT:
- status_change_end(bl, type, INVALID_TIMER); // Remove previous one.
- break;
- case SC_MARSHOFABYSS:
- status_change_end(bl, SC_INCAGI, INVALID_TIMER);
- status_change_end(bl, SC_WINDWALK, INVALID_TIMER);
- status_change_end(bl, SC_ASPDPOTION0, INVALID_TIMER);
- status_change_end(bl, SC_ASPDPOTION1, INVALID_TIMER);
- status_change_end(bl, SC_ASPDPOTION2, INVALID_TIMER);
- status_change_end(bl, SC_ASPDPOTION3, INVALID_TIMER);
- break;
- case SC_SWINGDANCE:
- case SC_SYMPHONYOFLOVER:
- case SC_MOONLITSERENADE:
- case SC_RUSHWINDMILL:
- case SC_ECHOSONG:
- case SC_HARMONIZE: //group A doesn't overlap
- if (type != SC_SWINGDANCE) status_change_end(bl, SC_SWINGDANCE, INVALID_TIMER);
- if (type != SC_SYMPHONYOFLOVER) status_change_end(bl, SC_SYMPHONYOFLOVER, INVALID_TIMER);
- if (type != SC_MOONLITSERENADE) status_change_end(bl, SC_MOONLITSERENADE, INVALID_TIMER);
- if (type != SC_RUSHWINDMILL) status_change_end(bl, SC_RUSHWINDMILL, INVALID_TIMER);
- if (type != SC_ECHOSONG) status_change_end(bl, SC_ECHOSONG, INVALID_TIMER);
- if (type != SC_HARMONIZE) status_change_end(bl, SC_HARMONIZE, INVALID_TIMER);
- break;
- case SC_VOICEOFSIREN:
- case SC_DEEPSLEEP:
- case SC_GLOOMYDAY:
- case SC_SONGOFMANA:
- case SC_DANCEWITHWUG:
- case SC_SATURDAYNIGHTFEVER:
- case SC_LERADSDEW:
- case SC_MELODYOFSINK:
- case SC_BEYONDOFWARCRY:
- case SC_UNLIMITEDHUMMINGVOICE: //group B
- if (type != SC_VOICEOFSIREN) status_change_end(bl, SC_VOICEOFSIREN, INVALID_TIMER);
- if (type != SC_DEEPSLEEP) status_change_end(bl, SC_DEEPSLEEP, INVALID_TIMER);
- if (type != SC_LERADSDEW) status_change_end(bl, SC_LERADSDEW, INVALID_TIMER);
- if (type != SC_MELODYOFSINK) status_change_end(bl, SC_MELODYOFSINK, INVALID_TIMER);
- if (type != SC_BEYONDOFWARCRY) status_change_end(bl, SC_BEYONDOFWARCRY, INVALID_TIMER);
- if (type != SC_UNLIMITEDHUMMINGVOICE) status_change_end(bl, SC_UNLIMITEDHUMMINGVOICE, INVALID_TIMER);
- if (type != SC_GLOOMYDAY) {
- status_change_end(bl, SC_GLOOMYDAY, INVALID_TIMER);
- status_change_end(bl, SC_GLOOMYDAY_SK, INVALID_TIMER);
- }
- if (type != SC_SONGOFMANA) status_change_end(bl, SC_SONGOFMANA, INVALID_TIMER);
- if (type != SC_DANCEWITHWUG) status_change_end(bl, SC_DANCEWITHWUG, INVALID_TIMER);
- if (type != SC_SATURDAYNIGHTFEVER) {
- if (sc->data[SC_SATURDAYNIGHTFEVER]) {
- sc->data[SC_SATURDAYNIGHTFEVER]->val2 = 0; //mark to not lose hp
- status_change_end(bl, SC_SATURDAYNIGHTFEVER, INVALID_TIMER);
- }
- }
- break;
- case SC_REFLECTSHIELD:
- status_change_end(bl, SC_REFLECTDAMAGE, INVALID_TIMER);
- break;
- case SC_REFLECTDAMAGE:
- status_change_end(bl, SC_REFLECTSHIELD, INVALID_TIMER);
- break;
- case SC_SHIELDSPELL_DEF:
- case SC_SHIELDSPELL_MDEF:
- case SC_SHIELDSPELL_REF:
- status_change_end(bl, SC_MAGNIFICAT, INVALID_TIMER);
- if( type != SC_SHIELDSPELL_DEF )
- status_change_end(bl, SC_SHIELDSPELL_DEF, INVALID_TIMER);
- if( type != SC_SHIELDSPELL_MDEF )
- status_change_end(bl, SC_SHIELDSPELL_MDEF, INVALID_TIMER);
- if( type != SC_SHIELDSPELL_REF )
- status_change_end(bl, SC_SHIELDSPELL_REF, INVALID_TIMER);
- break;
- case SC_GT_ENERGYGAIN:
- case SC_GT_CHANGE:
- case SC_GT_REVITALIZE:
- if( type != SC_GT_REVITALIZE )
- status_change_end(bl, SC_GT_REVITALIZE, INVALID_TIMER);
- if( type != SC_GT_ENERGYGAIN )
- status_change_end(bl, SC_GT_ENERGYGAIN, INVALID_TIMER);
- if( type != SC_GT_CHANGE )
- status_change_end(bl, SC_GT_CHANGE, INVALID_TIMER);
- break;
- case SC_INVINCIBLE:
- status_change_end(bl, SC_INVINCIBLEOFF, INVALID_TIMER);
- break;
- case SC_INVINCIBLEOFF:
- status_change_end(bl, SC_INVINCIBLE, INVALID_TIMER);
- break;
- case SC_MAGICPOWER:
- status_change_end(bl, type, INVALID_TIMER);
- break;
+ status_change_end(bl, SC_ONEHANDQUICKEN, INVALID_TIMER);
+ status_change_end(bl, SC_MER_QUICKEN, INVALID_TIMER);
+ status_change_end(bl, SC_ACCELERATION, INVALID_TIMER);
+ break;
+ case SC_ONEHANDQUICKEN:
+ //Removes the Aspd potion effect, as reported by Vicious. [Skotlex]
+ status_change_end(bl, SC_ATTHASTE_POTION1, INVALID_TIMER);
+ status_change_end(bl, SC_ATTHASTE_POTION2, INVALID_TIMER);
+ status_change_end(bl, SC_ATTHASTE_POTION3, INVALID_TIMER);
+ status_change_end(bl, SC_ATTHASTE_INFINITY, INVALID_TIMER);
+ break;
+ case SC_OVERTHRUSTMAX:
+ //Cancels Normal Overthrust. [Skotlex]
+ status_change_end(bl, SC_OVERTHRUST, INVALID_TIMER);
+ break;
+ case SC_KYRIE:
+ //Cancels Assumptio
+ status_change_end(bl, SC_ASSUMPTIO, INVALID_TIMER);
+ break;
+ case SC_DELUGE:
+ if (sc->data[SC_FOGWALL] && sc->data[SC_BLIND])
+ status_change_end(bl, SC_BLIND, INVALID_TIMER);
+ break;
+ case SC_SILENCE:
+ if (sc->data[SC_GOSPEL] && sc->data[SC_GOSPEL]->val4 == BCT_SELF)
+ status_change_end(bl, SC_GOSPEL, INVALID_TIMER);
+ break;
+ case SC_HIDING:
+ status_change_end(bl, SC_RG_CCONFINE_M, INVALID_TIMER);
+ status_change_end(bl, SC_RG_CCONFINE_S, INVALID_TIMER);
+ break;
+ case SC__BLOODYLUST:
+ case SC_BERSERK:
+ if(battle_config.berserk_cancels_buffs) {
+ status_change_end(bl, SC_ONEHANDQUICKEN, INVALID_TIMER);
+ status_change_end(bl, SC_TWOHANDQUICKEN, INVALID_TIMER);
+ status_change_end(bl, SC_LKCONCENTRATION, INVALID_TIMER);
+ status_change_end(bl, SC_PARRYING, INVALID_TIMER);
+ status_change_end(bl, SC_AURABLADE, INVALID_TIMER);
+ status_change_end(bl, SC_MER_QUICKEN, INVALID_TIMER);
+ }
+ #ifdef RENEWAL
+ else {
+ status_change_end(bl, SC_TWOHANDQUICKEN, INVALID_TIMER);
+ }
+ #endif
+ break;
+ case SC_ASSUMPTIO:
+ status_change_end(bl, SC_KYRIE, INVALID_TIMER);
+ status_change_end(bl, SC_KAITE, INVALID_TIMER);
+ break;
+ case SC_KAITE:
+ status_change_end(bl, SC_ASSUMPTIO, INVALID_TIMER);
+ break;
+ case SC_CARTBOOST:
+ if(sc->data[SC_DEC_AGI])
+ { //Cancel Decrease Agi, but take no further effect [Skotlex]
+ status_change_end(bl, SC_DEC_AGI, INVALID_TIMER);
+ return 0;
+ }
+ break;
+ case SC_FUSION:
+ status_change_end(bl, SC_SOULLINK, INVALID_TIMER);
+ break;
+ case SC_GS_ADJUSTMENT:
+ status_change_end(bl, SC_GS_MADNESSCANCEL, INVALID_TIMER);
+ break;
+ case SC_GS_MADNESSCANCEL:
+ status_change_end(bl, SC_GS_ADJUSTMENT, INVALID_TIMER);
+ break;
+ //NPC_CHANGEUNDEAD will debuff Blessing and Agi Up
+ case SC_PROPERTYUNDEAD:
+ status_change_end(bl, SC_BLESSING, INVALID_TIMER);
+ status_change_end(bl, SC_INC_AGI, INVALID_TIMER);
+ break;
+ case SC_FOOD_STR:
+ status_change_end(bl, SC_FOOD_STR_CASH, INVALID_TIMER);
+ break;
+ case SC_FOOD_AGI:
+ status_change_end(bl, SC_FOOD_AGI_CASH, INVALID_TIMER);
+ break;
+ case SC_FOOD_VIT:
+ status_change_end(bl, SC_FOOD_VIT_CASH, INVALID_TIMER);
+ break;
+ case SC_FOOD_INT:
+ status_change_end(bl, SC_FOOD_INT_CASH, INVALID_TIMER);
+ break;
+ case SC_FOOD_DEX:
+ status_change_end(bl, SC_FOOD_DEX_CASH, INVALID_TIMER);
+ break;
+ case SC_FOOD_LUK:
+ status_change_end(bl, SC_FOOD_LUK_CASH, INVALID_TIMER);
+ break;
+ case SC_FOOD_STR_CASH:
+ status_change_end(bl, SC_FOOD_STR, INVALID_TIMER);
+ break;
+ case SC_FOOD_AGI_CASH:
+ status_change_end(bl, SC_FOOD_AGI, INVALID_TIMER);
+ break;
+ case SC_FOOD_VIT_CASH:
+ status_change_end(bl, SC_FOOD_VIT, INVALID_TIMER);
+ break;
+ case SC_FOOD_INT_CASH:
+ status_change_end(bl, SC_FOOD_INT, INVALID_TIMER);
+ break;
+ case SC_FOOD_DEX_CASH:
+ status_change_end(bl, SC_FOOD_DEX, INVALID_TIMER);
+ break;
+ case SC_FOOD_LUK_CASH:
+ status_change_end(bl, SC_FOOD_LUK, INVALID_TIMER);
+ break;
+ case SC_ENDURE:
+ if( val4 )
+ status_change_end(bl, SC_LKCONCENTRATION, INVALID_TIMER);
+ break;
+ case SC_FIGHTINGSPIRIT:
+ status_change_end(bl, type, INVALID_TIMER); // Remove previous one.
+ break;
+ case SC_MARSHOFABYSS:
+ status_change_end(bl, SC_INCAGI, INVALID_TIMER);
+ status_change_end(bl, SC_WINDWALK, INVALID_TIMER);
+ status_change_end(bl, SC_ATTHASTE_POTION1, INVALID_TIMER);
+ status_change_end(bl, SC_ATTHASTE_POTION2, INVALID_TIMER);
+ status_change_end(bl, SC_ATTHASTE_POTION3, INVALID_TIMER);
+ status_change_end(bl, SC_ATTHASTE_INFINITY, INVALID_TIMER);
+ break;
+ case SC_SWING:
+ case SC_SYMPHONY_LOVE:
+ case SC_MOONLIT_SERENADE:
+ case SC_RUSH_WINDMILL:
+ case SC_ECHOSONG:
+ case SC_HARMONIZE: //group A doesn't overlap
+ if (type != SC_SWING) status_change_end(bl, SC_SWING, INVALID_TIMER);
+ if (type != SC_SYMPHONY_LOVE) status_change_end(bl, SC_SYMPHONY_LOVE, INVALID_TIMER);
+ if (type != SC_MOONLIT_SERENADE) status_change_end(bl, SC_MOONLIT_SERENADE, INVALID_TIMER);
+ if (type != SC_RUSH_WINDMILL) status_change_end(bl, SC_RUSH_WINDMILL, INVALID_TIMER);
+ if (type != SC_ECHOSONG) status_change_end(bl, SC_ECHOSONG, INVALID_TIMER);
+ if (type != SC_HARMONIZE) status_change_end(bl, SC_HARMONIZE, INVALID_TIMER);
+ break;
+ case SC_SIREN:
+ case SC_DEEP_SLEEP:
+ case SC_GLOOMYDAY:
+ case SC_SONG_OF_MANA:
+ case SC_DANCE_WITH_WUG:
+ case SC_SATURDAY_NIGHT_FEVER:
+ case SC_LERADS_DEW:
+ case SC_MELODYOFSINK:
+ case SC_BEYOND_OF_WARCRY:
+ case SC_UNLIMITED_HUMMING_VOICE: //group B
+ if (type != SC_SIREN) status_change_end(bl, SC_SIREN, INVALID_TIMER);
+ if (type != SC_DEEP_SLEEP) status_change_end(bl, SC_DEEP_SLEEP, INVALID_TIMER);
+ if (type != SC_LERADS_DEW) status_change_end(bl, SC_LERADS_DEW, INVALID_TIMER);
+ if (type != SC_MELODYOFSINK) status_change_end(bl, SC_MELODYOFSINK, INVALID_TIMER);
+ if (type != SC_BEYOND_OF_WARCRY) status_change_end(bl, SC_BEYOND_OF_WARCRY, INVALID_TIMER);
+ if (type != SC_UNLIMITED_HUMMING_VOICE) status_change_end(bl, SC_UNLIMITED_HUMMING_VOICE, INVALID_TIMER);
+ if (type != SC_GLOOMYDAY) {
+ status_change_end(bl, SC_GLOOMYDAY, INVALID_TIMER);
+ status_change_end(bl, SC_GLOOMYDAY_SK, INVALID_TIMER);
+ }
+ if (type != SC_SONG_OF_MANA) status_change_end(bl, SC_SONG_OF_MANA, INVALID_TIMER);
+ if (type != SC_DANCE_WITH_WUG) status_change_end(bl, SC_DANCE_WITH_WUG, INVALID_TIMER);
+ if (type != SC_SATURDAY_NIGHT_FEVER) {
+ if (sc->data[SC_SATURDAY_NIGHT_FEVER]) {
+ sc->data[SC_SATURDAY_NIGHT_FEVER]->val2 = 0; //mark to not lose hp
+ status_change_end(bl, SC_SATURDAY_NIGHT_FEVER, INVALID_TIMER);
+ }
+ }
+ break;
+ case SC_REFLECTSHIELD:
+ status_change_end(bl, SC_LG_REFLECTDAMAGE, INVALID_TIMER);
+ break;
+ case SC_LG_REFLECTDAMAGE:
+ status_change_end(bl, SC_REFLECTSHIELD, INVALID_TIMER);
+ break;
+ case SC_SHIELDSPELL_DEF:
+ case SC_SHIELDSPELL_MDEF:
+ case SC_SHIELDSPELL_REF:
+ status_change_end(bl, SC_MAGNIFICAT, INVALID_TIMER);
+ if( type != SC_SHIELDSPELL_DEF )
+ status_change_end(bl, SC_SHIELDSPELL_DEF, INVALID_TIMER);
+ if( type != SC_SHIELDSPELL_MDEF )
+ status_change_end(bl, SC_SHIELDSPELL_MDEF, INVALID_TIMER);
+ if( type != SC_SHIELDSPELL_REF )
+ status_change_end(bl, SC_SHIELDSPELL_REF, INVALID_TIMER);
+ break;
+ case SC_GENTLETOUCH_ENERGYGAIN:
+ case SC_GENTLETOUCH_CHANGE:
+ case SC_GENTLETOUCH_REVITALIZE:
+ if( type != SC_GENTLETOUCH_REVITALIZE )
+ status_change_end(bl, SC_GENTLETOUCH_REVITALIZE, INVALID_TIMER);
+ if( type != SC_GENTLETOUCH_ENERGYGAIN )
+ status_change_end(bl, SC_GENTLETOUCH_ENERGYGAIN, INVALID_TIMER);
+ if( type != SC_GENTLETOUCH_CHANGE )
+ status_change_end(bl, SC_GENTLETOUCH_CHANGE, INVALID_TIMER);
+ break;
+ case SC_INVINCIBLE:
+ status_change_end(bl, SC_INVINCIBLEOFF, INVALID_TIMER);
+ break;
+ case SC_INVINCIBLEOFF:
+ status_change_end(bl, SC_INVINCIBLE, INVALID_TIMER);
+ break;
+ case SC_MAGICPOWER:
+ status_change_end(bl, type, INVALID_TIMER);
+ break;
}
//Check for overlapping fails
if( (sce = sc->data[type]) ) {
switch( type ) {
- case SC_MERC_FLEEUP:
- case SC_MERC_ATKUP:
- case SC_MERC_HPUP:
- case SC_MERC_SPUP:
- case SC_MERC_HITUP:
+ case SC_MER_FLEE:
+ case SC_MER_ATK:
+ case SC_MER_HP:
+ case SC_MER_SP:
+ case SC_MER_HIT:
if( sce->val1 > val1 )
val1 = sce->val1;
break;
case SC_ADRENALINE:
case SC_ADRENALINE2:
- case SC_WEAPONPERFECTION:
+ case SC_WEAPONPERFECT:
case SC_OVERTHRUST:
if (sce->val2 > val2)
return 0;
break;
case SC_S_LIFEPOTION:
case SC_L_LIFEPOTION:
- case SC_BOSSMAPINFO:
+ case SC_CASH_BOSS_ALARM:
case SC_STUN:
case SC_SLEEP:
case SC_POISON:
@@ -7096,13 +7167,13 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_SILENCE:
case SC_CONFUSION:
case SC_BLIND:
- case SC_BLEEDING:
+ case SC_BLOODING:
case SC_DPOISON:
- case SC_CLOSECONFINE2: //Can't be re-closed in.
+ case SC_RG_CCONFINE_S: //Can't be re-closed in.
+ case SC_MARIONETTE_MASTER:
case SC_MARIONETTE:
- case SC_MARIONETTE2:
case SC_NOCHAT:
- case SC_CHANGE: //Otherwise your Hp/Sp would get refilled while still within effect of the last invocation.
+ case SC_HLIF_CHANGE: //Otherwise your Hp/Sp would get refilled while still within effect of the last invocation.
case SC__INVISIBILITY:
case SC__ENERVATION:
case SC__GROOMY:
@@ -7111,17 +7182,17 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC__WEAKNESS:
case SC__UNLUCKY:
return 0;
- case SC_COMBO:
+ case SC_COMBOATTACK:
case SC_DANCING:
case SC_DEVOTION:
- case SC_ASPDPOTION0:
- case SC_ASPDPOTION1:
- case SC_ASPDPOTION2:
- case SC_ASPDPOTION3:
- case SC_ATKPOTION:
- case SC_MATKPOTION:
+ case SC_ATTHASTE_POTION1:
+ case SC_ATTHASTE_POTION2:
+ case SC_ATTHASTE_POTION3:
+ case SC_ATTHASTE_INFINITY:
+ case SC_PLUSATTACKPOWER:
+ case SC_PLUSMAGICPOWER:
case SC_ENCHANTARMS:
- case SC_ARMOR_ELEMENT:
+ case SC_ARMORPROPERTY:
case SC_ARMOR_RESIST:
break;
case SC_GOSPEL:
@@ -7141,7 +7212,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
//Kaahi overwrites previous level regardless of existing level.
//Delete timer if it exists.
if (sce->val4 != INVALID_TIMER) {
- delete_timer(sce->val4,kaahi_heal_timer);
+ iTimer->delete_timer(sce->val4,kaahi_heal_timer);
sce->val4 = INVALID_TIMER;
}
break;
@@ -7151,7 +7222,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
val3 = sce->val3;
val4 = sce->val4;
break;
- case SC_LERADSDEW:
+ case SC_LERADS_DEW:
if (sc && (sc->data[SC_BERSERK] || sc->data[SC__BLOODYLUST]))
return 0;
case SC_SHAPESHIFT:
@@ -7176,8 +7247,8 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
calc_flag = StatusChangeFlagTable[type];
if(!(flag&4)) { //&4 - Do not parse val settings when loading SCs
switch(type) {
- case SC_DECREASEAGI:
- case SC_INCREASEAGI:
+ case SC_DEC_AGI:
+ case SC_INC_AGI:
val2 = 2 + val1; //Agi change
break;
case SC_ENDURE:
@@ -7190,7 +7261,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
int i;
for( i = 0; i < 5; i++ )
{
- if( sd->devotion[i] && (tsd = map_id2sd(sd->devotion[i])) )
+ if( sd->devotion[i] && (tsd = iMap->id2sd(sd->devotion[i])) )
status_change_start(&tsd->bl, type, 10000, val1, val2, val3, val4, tick, 1);
}
}
@@ -7207,7 +7278,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
sc_start4(bl,SC_PROVOKE,100,10,1,0,0,60000);
tick = -1;
break;
- case SC_SIGNUMCRUCIS:
+ case SC_CRUCIS:
val2 = 10 + 4*val1; //Def reduction
tick = -1;
clif->emotion(bl,E_SWT);
@@ -7218,11 +7289,14 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
break;
case SC_EDP: // [Celest]
val2 = val1 + 2; //Chance to Poison enemies.
- #ifndef RENEWAL_EDP
+ #ifdef RENEWAL_EDP
+ val3 = 50*(val1+3);
+ val4 = 100 * ((val1 + 1)/2 + 2);
+ #else
val3 = 50*(val1+1); //Damage increase (+50 +50*lv%)
#endif
if( sd )//[Ind] - iROwiki says each level increases its duration by 3 seconds
- tick += pc_checkskill(sd,GC_RESEARCHNEWPOISON)*3000;
+ tick += pc->checkskill(sd,GC_RESEARCHNEWPOISON)*3000;
break;
case SC_POISONREACT:
val2=(val1+1)/2 + val1/10; // Number of counters [Skotlex]
@@ -7245,18 +7319,18 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
val2 = 5; //Lasts 5 hits
tick = -1;
break;
- case SC_ENCPOISON:
+ case SC_ENCHANTPOISON:
val2= 250+50*val1; //Poisoning Chance (2.5+0.5%) in 1/10000 rate
case SC_ASPERSIO:
- case SC_FIREWEAPON:
- case SC_WATERWEAPON:
- case SC_WINDWEAPON:
- case SC_EARTHWEAPON:
- case SC_SHADOWWEAPON:
- case SC_GHOSTWEAPON:
+ case SC_PROPERTYFIRE:
+ case SC_PROPERTYWATER:
+ case SC_PROPERTYWIND:
+ case SC_PROPERTYGROUND:
+ case SC_PROPERTYDARK:
+ case SC_PROPERTYTELEKINESIS:
skill->enchant_elemental_end(bl,type);
break;
- case SC_ELEMENTALCHANGE:
+ case SC_ARMOR_PROPERTY:
// val1 : Element Lvl (if called by skill lvl 1, takes random value between 1 and 4)
// val2 : Element (When no element, random one is picked)
// val3 : 0 = called by skill 1 = called by script (fixed level)
@@ -7281,7 +7355,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
int i;
for( i = 0; i < 5; i++ )
{
- if( sd->devotion[i] && (tsd = map_id2sd(sd->devotion[i])) )
+ if( sd->devotion[i] && (tsd = iMap->id2sd(sd->devotion[i])) )
status_change_start(&tsd->bl, type, 10000, val1, val2, 0, 0, tick, 1);
}
}
@@ -7289,19 +7363,19 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
status_change_start(&tsd->bl, type, 10000, val1, val2, 0, 0, tick, 1);
}
break;
- case SC_STRIPWEAPON:
+ case SC_NOEQUIPWEAPON:
if (!sd) //Watk reduction
val2 = 25;
break;
- case SC_STRIPSHIELD:
+ case SC_NOEQUIPSHIELD:
if (!sd) //Def reduction
val2 = 15;
break;
- case SC_STRIPARMOR:
+ case SC_NOEQUIPARMOR:
if (!sd) //Vit reduction
val2 = 40;
break;
- case SC_STRIPHELM:
+ case SC_NOEQUIPHELM:
if (!sd) //Int reduction
val2 = 40;
break;
@@ -7332,7 +7406,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
val2 = 0;
#endif
break;
- case SC_SUITON:
+ case SC_NJ_SUITON:
if (!val2 || (sd && (sd->class_&MAPID_BASEMASK) == MAPID_NINJA)) {
//No penalties.
val2 = 0; //Agi penalty
@@ -7343,13 +7417,13 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
val2 = 3*((val1+1)/3);
if (val1 > 4) val2--;
break;
- case SC_ONEHAND:
+ case SC_ONEHANDQUICKEN:
case SC_TWOHANDQUICKEN:
val2 = 300;
if (val1 > 10) //For boss casted skills [Skotlex]
val2 += 20*(val1-10);
break;
- case SC_MERC_QUICKEN:
+ case SC_MER_QUICKEN:
val2 = 300;
break;
#ifndef RENEWAL_ASPD
@@ -7363,24 +7437,28 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
//val3 : Brings the skill_lv (merged into val1 here)
//val4 : Partner
if (val1 == CG_MOONLIT)
- clif->status_change(bl,SI_MOONLIT,1,tick,0, 0, 0);
+ clif->status_change(bl,SI_MOON,1,tick,0, 0, 0);
val1|= (val3<<16);
val3 = tick/1000; //Tick duration
tick_time = 1000; // [GodLesZ] tick time
break;
case SC_LONGING:
+ #ifdef RENEWAL
+ val2 = 50 + 10 * val1;
+ #else
val2 = 500-100*val1; //Aspd penalty.
+ #endif
break;
case SC_EXPLOSIONSPIRITS:
val2 = 75 + 25*val1; //Cri bonus
break;
- case SC_ASPDPOTION0:
- case SC_ASPDPOTION1:
- case SC_ASPDPOTION2:
- case SC_ASPDPOTION3:
- val2 = 50*(2+type-SC_ASPDPOTION0);
- break;
+ case SC_ATTHASTE_POTION1:
+ case SC_ATTHASTE_POTION2:
+ case SC_ATTHASTE_POTION3:
+ case SC_ATTHASTE_INFINITY:
+ val2 = 50*(2+type-SC_ATTHASTE_POTION1);
+ break;
case SC_WEDDING:
case SC_XMAS:
@@ -7405,7 +7483,8 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
val3 = tick/1000; //Petrified HP-damage iterations.
if(val3 < 1) val3 = 1;
tick = val4; //Petrifying time.
- tick = max(tick, 1000); //Min time
+ if(val4 > 500) // not with WL_SIENNAEXECRATE
+ tick = max(tick, 1000); //Min time
calc_flag = 0; //Actual status changes take effect on petrified state.
break;
@@ -7416,7 +7495,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
if (status->hp - diff < status->max_hp>>2)
diff = status->hp - (status->max_hp>>2);
if( val2 && bl->type == BL_MOB ) {
- struct block_list* src = map_id2bl(val2);
+ struct block_list* src = iMap->id2bl(val2);
if( src )
mob_log_damage((TBL_MOB*)bl,src,diff);
}
@@ -7437,7 +7516,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_CONFUSION:
clif->emotion(bl,E_WHAT);
break;
- case SC_BLEEDING:
+ case SC_BLOODING:
val4 = tick/10000;
if (!val4) val4 = 1;
tick_time = 10000; // [GodLesZ] tick time
@@ -7453,10 +7532,10 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
val4 = 1;
tick_time = val2 * 1000; // [GodLesZ] tick time
break;
- case SC_BOSSMAPINFO:
+ case SC_CASH_BOSS_ALARM:
if( sd != NULL )
{
- struct mob_data *boss_md = map_getmob_boss(bl->m); // Search for Boss on this Map
+ struct mob_data *boss_md = iMap->getmob_boss(bl->m); // Search for Boss on this Map
if( boss_md == NULL || boss_md->bl.prev == NULL )
{ // No MVP on this map - MVP is dead
clif->bossmapinfo(sd->fd, boss_md, 1);
@@ -7477,7 +7556,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_CHASEWALK:
val2 = tick>0?tick:10000; //Interval at which SP is drained.
val3 = 35 - 5 * val1; //Speed adjustment.
- if (sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_ROGUE)
+ if (sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_ROGUE)
val3 -= 40;
val4 = 10+val1*2; //SP cost.
if (map_flag_gvg(bl->m) || map[bl->m].flag.battleground) val4 *= 5;
@@ -7498,24 +7577,24 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
break;
case SC_SIGHT: /* splash status */
case SC_RUWACH:
- case SC_SIGHTBLASTER:
+ case SC_WZ_SIGHTBLASTER:
val3 = skill->get_splash(val2, val1); //Val2 should bring the skill-id.
val2 = tick/250;
tick_time = 10; // [GodLesZ] tick time
break;
//Permanent effects.
- case SC_AETERNA:
+ case SC_LEXAETERNA:
case SC_MODECHANGE:
- case SC_WEIGHT50:
- case SC_WEIGHT90:
+ case SC_WEIGHTOVER50:
+ case SC_WEIGHTOVER90:
case SC_BROKENWEAPON:
case SC_BROKENARMOR:
- case SC_READYSTORM:
- case SC_READYDOWN:
- case SC_READYCOUNTER:
- case SC_READYTURN:
- case SC_DODGE:
+ case SC_STORMKICK_READY:
+ case SC_DOWNKICK_READY:
+ case SC_COUNTERKICK_READY:
+ case SC_TURNKICK_READY:
+ case SC_DODGE_READY:
case SC_PUSH_CART:
case SC_ALL_RIDING:
tick = -1;
@@ -7538,7 +7617,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
{
for( i = 0; i < 5; i++ )
{
- if( sd->devotion[i] && (tsd = map_id2sd(sd->devotion[i])) )
+ if( sd->devotion[i] && (tsd = iMap->id2sd(sd->devotion[i])) )
status_change_start(&tsd->bl, type, 10000, val1, val2, 0, 0, tick, 1);
}
}
@@ -7561,7 +7640,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
int i;
for (i = 0; i < 5; i++)
{ //See if there are devoted characters, and pass the status to them. [Skotlex]
- if (sd->devotion[i] && (tsd = map_id2sd(sd->devotion[i])))
+ if (sd->devotion[i] && (tsd = iMap->id2sd(sd->devotion[i])))
status_change_start(&tsd->bl,type,10000,val1,5+val1*5,val3,val4,tick,1);
}
}
@@ -7589,7 +7668,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_JOINTBEAT:
if( val2&BREAK_NECK )
- sc_start2(bl,SC_BLEEDING,100,val1,val3,skill->get_time2(status_sc2skill(type),val1));
+ sc_start2(bl,SC_BLOODING,100,val1,val3,skill->get_time2(status_sc2skill(type),val1));
break;
case SC_BERSERK:
@@ -7612,7 +7691,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
}
break;
- case SC_MARIONETTE:
+ case SC_MARIONETTE_MASTER:
{
int stat;
@@ -7626,13 +7705,13 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
stat = ( sd ? sd->status.luk : status_get_base_status(bl)->luk ) / 2; val4 |= cap_value(stat,0,0xFF);
break;
}
- case SC_MARIONETTE2:
+ case SC_MARIONETTE:
{
int stat,max_stat;
// fetch caster information
- struct block_list *pbl = map_id2bl(val1);
+ struct block_list *pbl = iMap->id2bl(val1);
struct status_change *psc = pbl?status_get_sc(pbl):NULL;
- struct status_change_entry *psce = psc?psc->data[SC_MARIONETTE]:NULL;
+ struct status_change_entry *psce = psc?psc->data[SC_MARIONETTE_MASTER]:NULL;
// fetch target's stats
struct status_data* status = status_get_status_data(bl); // battle status
@@ -7650,7 +7729,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
stat = (psce->val4 >> 0)&0xFF; stat = min(stat, max_stat - status->luk ); val4 |= cap_value(stat,0,0xFF);
break;
}
- case SC_REJECTSWORD:
+ case SC_SWORDREJECT:
val2 = 15*val1; //Reflect chance
val3 = 3; //Reflections
tick = -1;
@@ -7665,7 +7744,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
val2 = 50*val1; //aspd reduction
break;
- case SC_REGENERATION:
+ case SC_GDSKILL_REGENERATION:
if (val1 == 1)
val2 = 2;
else
@@ -7679,7 +7758,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
struct block_list *d_bl;
struct status_change *d_sc;
- if( (d_bl = map_id2bl(val1)) && (d_sc = status_get_sc(d_bl)) && d_sc->count )
+ if( (d_bl = iMap->id2bl(val1)) && (d_sc = status_get_sc(d_bl)) && d_sc->count )
{ // Inherits Status From Source
const enum sc_type types[] = { SC_AUTOGUARD, SC_DEFENDER, SC_REFLECTSHIELD, SC_ENDURE };
enum sc_type type2;
@@ -7697,25 +7776,25 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_COMA: //Coma. Sends a char to 1HP. If val2, do not zap sp
if( val3 && bl->type == BL_MOB ) {
- struct block_list* src = map_id2bl(val3);
+ struct block_list* src = iMap->id2bl(val3);
if( src )
mob_log_damage((TBL_MOB*)bl,src,status->hp - 1);
}
status_zap(bl, status->hp-1, val2?0:status->sp);
return 1;
break;
- case SC_CLOSECONFINE2:
+ case SC_RG_CCONFINE_S:
{
- struct block_list *src = val2?map_id2bl(val2):NULL;
+ struct block_list *src = val2?iMap->id2bl(val2):NULL;
struct status_change *sc2 = src?status_get_sc(src):NULL;
- struct status_change_entry *sce2 = sc2?sc2->data[SC_CLOSECONFINE]:NULL;
+ struct status_change_entry *sce2 = sc2?sc2->data[SC_RG_CCONFINE_M]:NULL;
if (src && sc2) {
if (!sce2) //Start lock on caster.
- sc_start4(src,SC_CLOSECONFINE,100,val1,1,0,0,tick+1000);
+ sc_start4(src,SC_RG_CCONFINE_M,100,val1,1,0,0,tick+1000);
else { //Increase count of locked enemies and refresh time.
(sce2->val2)++;
- delete_timer(sce2->timer, status_change_timer);
- sce2->timer = add_timer(gettick()+tick+1000, status_change_timer, src->id, SC_CLOSECONFINE);
+ iTimer->delete_timer(sce2->timer, status_change_timer);
+ sce2->timer = iTimer->add_timer(iTimer->gettick()+tick+1000, status_change_timer, src->id, SC_RG_CCONFINE_M);
}
} else //Status failed.
return 0;
@@ -7740,7 +7819,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
}
break;
- case SC_COMBO: {
+ case SC_COMBOATTACK: {
//val1: Skill ID
//val2: When given, target (for autotargetting skills)
//val3: When set, this combo time should NOT delay attack/movement
@@ -7749,8 +7828,8 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
struct unit_data *ud = unit_bl2ud(bl);
if (ud && !val3) {
tick += 300 * battle_config.combo_delay_rate/100;
- ud->attackabletime = gettick()+tick;
- unit_set_walkdelay(bl, gettick(), tick, 1);
+ ud->attackabletime = iTimer->gettick()+tick;
+ unit_set_walkdelay(bl, iTimer->gettick(), tick, 1);
}
val3 = 0;
val4 = tick;
@@ -7760,7 +7839,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
val2 = 11-val1; //Chance to consume: 11-skill_lv%
break;
case SC_RUN:
- val4 = gettick(); //Store time at which you started running.
+ val4 = iTimer->gettick(); //Store time at which you started running.
tick = -1;
break;
case SC_KAAHI:
@@ -7778,7 +7857,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
if (vd) vd->dead_sit = 1;
tick = -1;
break;
- case SC_CONCENTRATE:
+ case SC_CONCENTRATION:
val2 = 2 + val1;
if (sd) { //Store the card-bonus data that should not count in the %
val3 = sd->param_bonus[1]; //Agi
@@ -7787,26 +7866,27 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
val3 = val4 = 0;
}
break;
- case SC_MAXOVERTHRUST:
+ case SC_OVERTHRUSTMAX:
val2 = 20*val1; //Power increase
break;
case SC_OVERTHRUST:
//val2 holds if it was casted on self, or is bonus received from others
val3 = 5*val1; //Power increase
- if(sd && pc_checkskill(sd,BS_HILTBINDING)>0)
+ if(sd && pc->checkskill(sd,BS_HILTBINDING)>0)
tick += tick / 10;
break;
case SC_ADRENALINE2:
case SC_ADRENALINE:
val3 = (val2) ? 300 : 200; // aspd increase
- case SC_WEAPONPERFECTION:
- if(sd && pc_checkskill(sd,BS_HILTBINDING)>0)
+ case SC_WEAPONPERFECT:
+ if(sd && pc->checkskill(sd,BS_HILTBINDING)>0)
tick += tick / 10;
break;
- case SC_CONCENTRATION:
+ case SC_LKCONCENTRATION:
val2 = 5*val1; //Batk/Watk Increase
val3 = 10*val1; //Hit Increase
val4 = 5*val1; //Def reduction
+ sc_start(bl, SC_ENDURE, 100, 1, tick); //Endure effect
break;
case SC_ANGELUS:
val2 = 5*val1; //def increase
@@ -7836,7 +7916,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
break;
// gs_something1 [Vicious]
- case SC_GATLINGFEVER:
+ case SC_GS_GATLINGFEVER:
val2 = 20*val1; //Aspd increase
val3 = 20+10*val1; //Batk increase
val4 = 5*val1; //Flee decrease
@@ -7854,18 +7934,18 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
val3 = 2+3*val1; //Atk increase
val4 = 5+5*val1; //Def reduction.
break;
- case SC_AVOID:
+ case SC_HLIF_AVOID:
//val2 = 10*val1; //Speed change rate.
break;
- case SC_DEFENCE:
+ case SC_HAMI_DEFENCE:
val2 = 2*val1; //Def bonus
break;
- case SC_BLOODLUST:
+ case SC_HAMI_BLOODLUST:
val2 = 20+10*val1; //Atk rate change.
val3 = 3*val1; //Leech chance
val4 = 20; //Leech percent
break;
- case SC_FLEET:
+ case SC_HLIF_FLEET:
val2 = 30*val1; //Aspd change
val3 = 5+5*val1; //bAtk/wAtk rate change
break;
@@ -7888,7 +7968,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
int pos = (bl->x&0xFFFF)|(bl->y<<16), //Current Coordinates
map = sd->mapindex; //Current Map
//1. Place in Jail (val2 -> Jail Map, val3 -> x, val4 -> y
- pc_setpos(sd,(unsigned short)val2,val3,val4, CLR_TELEPORT);
+ pc->setpos(sd,(unsigned short)val2,val3,val4, CLR_TELEPORT);
//2. Set restore point (val3 -> return map, val4 return coords
val3 = map;
val4 = pos;
@@ -7899,14 +7979,14 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
}
}
break;
- case SC_UTSUSEMI:
+ case SC_NJ_UTSUSEMI:
val2=(val1+1)/2; // number of hits blocked
val3=skill->get_blewcount(NJ_UTSUSEMI, val1); //knockback value.
break;
- case SC_BUNSINJYUTSU:
+ case SC_NJ_BUNSINJYUTSU:
val2=(val1+1)/2; // number of hits blocked
break;
- case SC_CHANGE:
+ case SC_HLIF_CHANGE:
val2= 30*val1; //Vit increase
val3= 20*val1; //Int increase
break;
@@ -7942,7 +8022,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
val2 = 20*val1; //Magic reflection/cast rate
break;
- case SC_ARMORCHANGE:
+ case SC_STONESKIN:
if (val2 == NPC_ANTIMAGIC)
{ //Boost mdef
val2 =-20;
@@ -7954,32 +8034,32 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
val2*=val1; //20% per level
val3*=val1;
break;
- case SC_EXPBOOST:
- case SC_JEXPBOOST:
+ case SC_CASH_PLUSEXP:
+ case SC_CASH_PLUSONLYJOBEXP:
if (val1 < 0)
val1 = 0;
break;
- case SC_INCFLEE2:
- case SC_INCCRI:
+ case SC_PLUSAVOIDVALUE:
+ case SC_CRITICALPERCENT:
val2 = val1*10; //Actual boost (since 100% = 1000)
break;
case SC_SUFFRAGIUM:
val2 = 15 * val1; //Speed cast decrease
break;
- case SC_INCHEALRATE:
+ case SC_HEALPLUS:
if (val1 < 1)
val1 = 1;
break;
- case SC_HALLUCINATION:
+ case SC_ILLUSION:
val2 = 5+val1; //Factor by which displayed damage is increased by
break;
- case SC_DOUBLECAST:
+ case SC_DOUBLECASTING:
val2 = 30+10*val1; //Trigger rate
break;
case SC_KAIZEL:
val2 = 10*val1; //% of life to be revived with
break;
- // case SC_ARMOR_ELEMENT:
+ // case SC_ARMORPROPERTY:
// case SC_ARMOR_RESIST:
// Mod your resistance against elements:
// val1 = water | val2 = earth | val3 = fire | val4 = wind
@@ -7989,13 +8069,13 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
//associated, and yet are not wrong/unknown. [Skotlex]
//break;
- case SC_MERC_FLEEUP:
- case SC_MERC_ATKUP:
- case SC_MERC_HITUP:
+ case SC_MER_FLEE:
+ case SC_MER_ATK:
+ case SC_MER_HIT:
val2 = 15 * val1;
break;
- case SC_MERC_HPUP:
- case SC_MERC_SPUP:
+ case SC_MER_HP:
+ case SC_MER_SP:
val2 = 5 * val1;
break;
case SC_REBIRTH:
@@ -8021,8 +8101,8 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
tick_time = 1000; // [GodLesZ] tick time
break;
case SC_BURNING:
- val4 = tick / 2000; // Total Ticks to Burn!!
- tick_time = 2000; // [GodLesZ] tick time
+ val4 = tick / 3000; // Total Ticks to Burn!!
+ tick_time = 3000; // [GodLesZ] tick time
break;
/**
* Rune Knight
@@ -8032,7 +8112,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
break;
case SC_STONEHARDSKIN:
if( sd )
- val1 = sd->status.job_level * pc_checkskill(sd, RK_RUNEMASTERY) / 4; //DEF/MDEF Increase
+ val1 = sd->status.job_level * pc->checkskill(sd, RK_RUNEMASTERY) / 4; //DEF/MDEF Increase
break;
case SC_FIGHTINGSPIRIT:
val_flag |= 1|2;
@@ -8108,24 +8188,27 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
break;
case SC_WHITEIMPRISON:
status_change_end(bl, SC_BURNING, INVALID_TIMER);
- status_change_end(bl, SC_FREEZING, INVALID_TIMER);
+ status_change_end(bl, SC_FROSTMISTY, INVALID_TIMER);
status_change_end(bl, SC_FREEZE, INVALID_TIMER);
status_change_end(bl, SC_STONE, INVALID_TIMER);
break;
- case SC_FREEZING:
+ case SC_MARSHOFABYSS:
+ val2 = 6 * val1;
+ if( sd ) // half on players
+ val2 >>= 1;
+ break;
+ case SC_FROSTMISTY:
status_change_end(bl, SC_BURNING, INVALID_TIMER);
break;
case SC_READING_SB:
// val2 = sp reduction per second
tick_time = 5000; // [GodLesZ] tick time
break;
- case SC_SPHERE_1:
- case SC_SPHERE_2:
- case SC_SPHERE_3:
- case SC_SPHERE_4:
- case SC_SPHERE_5:
- if( !sd )
- return 0; // Should only work on players.
+ case SC_SUMMON1:
+ case SC_SUMMON2:
+ case SC_SUMMON3:
+ case SC_SUMMON4:
+ case SC_SUMMON5:
val4 = tick / 1000;
if( val4 < 1 )
val4 = 1;
@@ -8154,11 +8237,11 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
tick_time = 1000; // [GodLesZ] tick time
break;
case SC_WUGDASH:
- val4 = gettick(); //Store time at which you started running.
+ val4 = iTimer->gettick(); //Store time at which you started running.
tick = -1;
break;
case SC__SHADOWFORM: {
- struct map_session_data * s_sd = map_id2sd(val2);
+ struct map_session_data * s_sd = iMap->id2sd(val2);
if( s_sd )
s_sd->shadowform_id = bl->id;
val4 = tick / 1000;
@@ -8166,7 +8249,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
tick_time = 1000; // [GodLesZ] tick time
}
break;
- case SC__STRIPACCESSORY:
+ case SC__STRIPACCESSARY:
if (!sd)
val2 = 20;
break;
@@ -8180,18 +8263,18 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC__ENERVATION:
val2 = 20 + 10 * val1; // ATK Reduction
val_flag |= 1|2;
- if( sd ) pc_delspiritball(sd,sd->spiritball,0);
+ if( sd ) pc->delspiritball(sd,sd->spiritball,0);
break;
case SC__GROOMY:
val2 = 20 + 10 * val1; //ASPD. Need to confirm if Movement Speed reduction is the same. [Jobbie]
val3 = 20 * val1; //HIT
val_flag |= 1|2|4;
if( sd ) { // Removes Animals
- if( pc_isriding(sd) ) pc_setriding(sd, 0);
- if( pc_isridingdragon(sd) ) pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
- if( pc_iswug(sd) ) pc_setoption(sd, sd->sc.option&~OPTION_WUG);
- if( pc_isridingwug(sd) ) pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
- if( pc_isfalcon(sd) ) pc_setoption(sd, sd->sc.option&~OPTION_FALCON);
+ if( pc_isriding(sd) ) pc->setriding(sd, 0);
+ if( pc_isridingdragon(sd) ) pc->setoption(sd, sd->sc.option&~OPTION_DRAGON);
+ if( pc_iswug(sd) ) pc->setoption(sd, sd->sc.option&~OPTION_WUG);
+ if( pc_isridingwug(sd) ) pc->setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
+ if( pc_isfalcon(sd) ) pc->setoption(sd, sd->sc.option&~OPTION_FALCON);
if( sd->status.pet_id > 0 ) pet_menu(sd, 3);
if( homun_alive(sd->hd) ) homun->vaporize(sd,1);
if( sd->md ) merc_delete(sd->md,3);
@@ -8210,8 +8293,8 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
val2 = 10 * val1;
val_flag |= 1|2;
// bypasses coating protection and MADO
- sc_start(bl,SC_STRIPWEAPON,100,val1,tick);
- sc_start(bl,SC_STRIPSHIELD,100,val1,tick);
+ sc_start(bl,SC_NOEQUIPWEAPON,100,val1,tick);
+ sc_start(bl,SC_NOEQUIPSHIELD,100,val1,tick);
break;
break;
case SC_GN_CARTBOOST:
@@ -8228,7 +8311,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
break;
case SC_WARMER:
status_change_end(bl, SC_FREEZE, INVALID_TIMER);
- status_change_end(bl, SC_FREEZING, INVALID_TIMER);
+ status_change_end(bl, SC_FROSTMISTY, INVALID_TIMER);
status_change_end(bl, SC_CRYSTALIZE, INVALID_TIMER);
break;
case SC_STRIKING:
@@ -8236,36 +8319,42 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
val4 = tick / 1000;
tick_time = 1000; // [GodLesZ] tick time
break;
- case SC_BLOODSUCKER:
- val4 = tick / 1000;
- tick_time = 1000; // [GodLesZ] tick time
+ case SC_BLOOD_SUCKER:
+ {
+ struct block_list *src = iMap->id2bl(val2);
+ val3 = 1;
+ if(src)
+ val3 = 200 + 100 * val1 + status_get_int(src);
+ val4 = tick / 1000;
+ tick_time = 1000; // [GodLesZ] tick time
+ }
break;
case SC_VACUUM_EXTREME:
tick -= (status->str / 20) * 1000;
val4 = val3 = tick / 100;
tick_time = 100; // [GodLesZ] tick time
break;
- case SC_SWINGDANCE:
+ case SC_SWING:
val2 = 4 * val1; // Walk speed and aspd reduction.
break;
- case SC_SYMPHONYOFLOVER:
- case SC_RUSHWINDMILL:
+ case SC_SYMPHONY_LOVE:
+ case SC_RUSH_WINDMILL:
case SC_ECHOSONG:
val2 = 6 * val1;
val2 += val3; //Adding 1% * Lesson Bonus
val2 += (int)(val4*2/10); //Adding 0.2% per JobLevel
break;
- case SC_MOONLITSERENADE:
+ case SC_MOONLIT_SERENADE:
val2 = 10 * val1;
break;
case SC_HARMONIZE:
val2 = 5 + 5 * val1;
break;
- case SC_VOICEOFSIREN:
+ case SC_SIREN:
val4 = tick / 2000;
tick_time = 2000; // [GodLesZ] tick time
break;
- case SC_DEEPSLEEP:
+ case SC_DEEP_SLEEP:
val4 = tick / 2000;
tick_time = 2000; // [GodLesZ] tick time
break;
@@ -8275,12 +8364,12 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
val4 = tick / 1000;
tick_time = 1000; // [GodLesZ] tick time
break;
- case SC_SONGOFMANA:
+ case SC_SONG_OF_MANA:
val3 = 10 + (2 * val2);
val4 = tick/3000;
tick_time = 3000; // [GodLesZ] tick time
break;
- case SC_SATURDAYNIGHTFEVER:
+ case SC_SATURDAY_NIGHT_FEVER:
if (!val4) val4 = skill->get_time2(status_sc2skill(type),val1);
if (!val4) val4 = 3000;
val3 = tick/val4;
@@ -8291,16 +8380,16 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
val3 = 15 + 5 * val1; // ASPD reduction.
if( sd && rand()%100 < val1 ){ // (Skill Lv) %
val4 = 1; // reduce walk speed by half.
- if( pc_isriding(sd) ) pc_setriding(sd, 0);
- if( pc_isridingdragon(sd) ) pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
+ if( pc_isriding(sd) ) pc->setriding(sd, 0);
+ if( pc_isridingdragon(sd) ) pc->setoption(sd, sd->sc.option&~OPTION_DRAGON);
}
break;
case SC_GLOOMYDAY_SK:
// Random number between [15 ~ (Voice Lesson Skill Level x 5) + (Skill Level x 10)] %.
- val2 = 15 + rand()%( (sd?pc_checkskill(sd, WM_LESSON)*5:0) + val1*10 );
+ val2 = 15 + rand()%( (sd?pc->checkskill(sd, WM_LESSON)*5:0) + val1*10 );
break;
case SC_SITDOWN_FORCE:
- case SC_BANANA_BOMB_SITDOWN:
+ case SC_BANANA_BOMB_SITDOWN_POSTDELAY:
if( sd && !pc_issit(sd) )
{
pc_setsit(sd);
@@ -8308,19 +8397,19 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
clif->sitting(bl);
}
break;
- case SC_DANCEWITHWUG:
+ case SC_DANCE_WITH_WUG:
val3 = (5 * val1) + (1 * val2); //Still need official value.
break;
- case SC_LERADSDEW:
+ case SC_LERADS_DEW:
val3 = (5 * val1) + (1 * val2);
break;
case SC_MELODYOFSINK:
val3 = (5 * val1) + (1 * val2);
break;
- case SC_BEYONDOFWARCRY:
+ case SC_BEYOND_OF_WARCRY:
val3 = (5 * val1) + (1 * val2);
break;
- case SC_UNLIMITEDHUMMINGVOICE:
+ case SC_UNLIMITED_HUMMING_VOICE:
{
struct unit_data *ud = unit_bl2ud(bl);
if( ud == NULL ) return 0;
@@ -8328,7 +8417,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
val3 = 15 - (2 * val2);
}
break;
- case SC_REFLECTDAMAGE:
+ case SC_LG_REFLECTDAMAGE:
val2 = 15 + 5 * val1;
val3 = (val1==5)?20:(val1+4)*2; // SP consumption
val4 = tick/10000;
@@ -8354,7 +8443,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
val2 = ((status->int_ + status->luk) / 6) + 5; // Chance to evade magic damage.
val1 *= 15; // Defence added
if( sd )
- val1 += 10 * pc_checkskill(sd,CR_DEFENDER);
+ val1 += 10 * pc->checkskill(sd,CR_DEFENDER);
val_flag |= 1|2;
break;
case SC_BANDING:
@@ -8396,19 +8485,21 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
val3 = tick / 5000;
tick_time = 5000; // [GodLesZ] tick time
break;
- case SC_GT_CHANGE:
+ case SC_GENTLETOUCH_CHANGE:
{// take note there is no def increase as skill desc says. [malufett]
struct block_list * src;
val3 = status->agi * val1 / 60; // ASPD increase: [(Target AGI x Skill Level) / 60] %
- if( (src = map_id2bl(val2)) )
+ if( (src = iMap->id2bl(val2)) ){
val4 = ( 200/status_get_int(src) ) * val1;// MDEF decrease: MDEF [(200 / Caster INT) x Skill Level]
+ val2 = ( status_get_dex(src)/4 + status_get_str(src)/2 ) * val1 / 5; // ATK increase: ATK [{(Caster DEX / 4) + (Caster STR / 2)} x Skill Level / 5]
+ }
}
break;
- case SC_GT_REVITALIZE:
+ case SC_GENTLETOUCH_REVITALIZE:
{// take note there is no vit,aspd,speed increase as skill desc says. [malufett]
struct block_list * src;
val3 = val1 * 30 + 150; // Natural HP recovery increase: [(Skill Level x 30) + 50] %
- if( (src = map_id2bl(val2)) ) // the stat def is not shown in the status window and it is process differently
+ if( (src = iMap->id2bl(val2)) ) // the stat def is not shown in the status window and it is process differently
val4 = ( status_get_vit(src)/4 ) * val1; // STAT DEF increase: [(Caster VIT / 4) x Skill Level]
}
break;
@@ -8517,8 +8608,8 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
tick_time = 10000; // [GodLesZ] tick time
break;
case SC_KYOUGAKU:
- val2 = 2*val1 + rand()%val1;
- clif->status_change(bl,SI_ACTIVE_MONSTER_TRANSFORM,1,0,1002,0,0);
+ val2 = 2*val1 + rand()%(3 * val1);
+ clif->status_change(bl, SI_ACTIVE_MONSTER_TRANSFORM, 1, 0, 1002, 0, 0); // Poring in disguise
break;
case SC_KAGEMUSYA:
val3 = val1 * 2;
@@ -8527,80 +8618,105 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
tick_time = 1000;
break;
case SC_ZANGETSU:
- if( (status_get_hp(bl)+status_get_sp(bl)) % 2 == 0)
- val2 = status_get_lv(bl) / 2 + 50;
- else
- val2 -= 50;
+ val2 = status_get_lv(bl) / 3 + 20 * val1;
+ val3 = status_get_lv(bl) / 2 + 30 * val1;
+ val2 = (!(status_get_hp(bl)%2) ? val2 : -val3);
+ val3 = (!(status_get_sp(bl)%2) ? val2 : -val3);
break;
case SC_GENSOU:
{
- int hp = status_get_hp(bl), lv = 5;
- short per = 100 / (status_get_max_hp(bl) / hp);
-
- if( per <= 15 )
- lv = 1;
- else if( per <= 30 )
- lv = 2;
- else if( per <= 50 )
- lv = 3;
- else if( per <= 75 )
- lv = 4;
- if( hp % 2 == 0)
- status_heal(bl, hp * (6-lv) * 4 / 100, status_get_sp(bl) * (6-lv) * 3 / 100, 1);
- else
- status_zap(bl, hp * (lv*4) / 100, status_get_sp(bl) * (lv*3) / 100);
+ int hp = status_get_hp(bl), sp = status_get_sp(bl), lv = 5;
+ #define PER( a ) { if( a <= 15 )lv = 1;else if( a <= 30 )lv = 2;else if( a <= 50 )lv = 3;else if( a <= 75 )lv = 4;}
+
+ if( rand()%100 > (25 + 10 * val1) - status_get_int(bl) / 2)
+ return 0;
+
+ PER( 100 / (status_get_max_hp(bl) / hp) );
+ status_heal(bl, (!(hp%2) ? (6-lv) *4 / 100 : -(lv*4) / 100), 0, 1);
+
+ PER( 100 / (status_get_max_sp(bl) / sp) );
+ status_heal(bl, 0,(!(sp%2) ? (6-lv) *3 / 100 : -(lv*3) / 100), 1);
}
break;
- case SC_ANGRIFFS_MODUS:
- val2 = 50 + 20 * val1; //atk bonus
- val3 = 40 + 20 * val1; // Flee reduction.
- val4 = tick/1000; // hp/sp reduction timer
- tick_time = 1000;
- break;
- case SC_NEUTRALBARRIER:
- tick_time = tick;
- tick = -1;
- break;
- case SC_GOLDENE_FERSE:
- val2 = 10 + 10*val1; //max hp bonus
- val3 = 6 + 4 * val1; // Aspd Bonus
- val4 = 2 + 2 * val1; // Chance of holy attack
- break;
- case SC_OVERED_BOOST:
- val2 = 300 + 40*val1; //flee bonus
- val3 = 179 + 2*val1; //aspd bonus
- break;
- case SC_GRANITIC_ARMOR:
- val2 = 2*val1; //dmg reduction
- val3 = 6*val1; //dmg on status end
- break;
- case SC_MAGMA_FLOW:
- val2 = 3*val1; //activation chance
- break;
- case SC_PYROCLASTIC:
- val2 += 10*val1; //atk bonus
- break;
- case SC_PARALYSIS: //[Lighta] need real info
- val2 = 2*val1; //def reduction
- val3 = 500*val1; //varcast augmentation
- break;
- case SC_PAIN_KILLER: //[Lighta] need real info
- val2 = 2*val1; //aspd reduction %
- val3 = 2*val1; //dmg reduction %
- if(sc->data[SC_PARALYSIS])
- sc_start(bl, SC_ENDURE, 100, val1, tick); //start endure for same duration
- break;
- case SC_STYLE_CHANGE: //[Lighta] need real info
- tick = -1;
- if(val2 == MH_MD_FIGHTING) val2 = MH_MD_GRAPPLING;
- else val2 = MH_MD_FIGHTING;
- break;
- default:
- if( calc_flag == SCB_NONE && StatusSkillChangeTable[type] == 0 && StatusIconChangeTable[type] == 0 )
- { //Status change with no calc, no icon, and no skill associated...?
- ShowError("UnknownStatusChange [%d]\n", type);
- return 0;
- }
+ case SC_ANGRIFFS_MODUS:
+ val2 = 50 + 20 * val1; //atk bonus
+ val3 = 40 + 20 * val1; // Flee reduction.
+ val4 = tick/1000; // hp/sp reduction timer
+ tick_time = 1000;
+ break;
+ case SC_NEUTRALBARRIER:
+ tick_time = tick;
+ tick = -1;
+ break;
+ case SC_GOLDENE_FERSE:
+ val2 = 10 + 10*val1; //max hp bonus
+ val3 = 6 + 4 * val1; // Aspd Bonus
+ val4 = 2 + 2 * val1; // Chance of holy attack
+ break;
+ case SC_OVERED_BOOST:
+ val2 = 300 + 40*val1; //flee bonus
+ val3 = 179 + 2*val1; //aspd bonus
+ break;
+ case SC_GRANITIC_ARMOR:
+ val2 = 2*val1; //dmg reduction
+ val3 = 6*val1; //dmg on status end
+ break;
+ case SC_MAGMA_FLOW:
+ val2 = 3*val1; //activation chance
+ break;
+ case SC_PYROCLASTIC:
+ val2 += 10*val1; //atk bonus
+ break;
+ case SC_NEEDLE_OF_PARALYZE: //[Lighta] need real info
+ val2 = 2*val1; //def reduction
+ val3 = 500*val1; //varcast augmentation
+ break;
+ case SC_PAIN_KILLER: //[Lighta] need real info
+ val2 = 2*val1; //aspd reduction %
+ val3 = 2*val1; //dmg reduction %
+ if(sc->data[SC_NEEDLE_OF_PARALYZE])
+ sc_start(bl, SC_ENDURE, 100, val1, tick); //start endure for same duration
+ break;
+ case SC_STYLE_CHANGE: //[Lighta] need real info
+ tick = -1;
+ if(val2 == MH_MD_FIGHTING) val2 = MH_MD_GRAPPLING;
+ else val2 = MH_MD_FIGHTING;
+ break;
+ case SC_FULL_THROTTLE:
+ status_percent_heal(bl,100,0);
+ val2 = 7 - val1;
+ tick_time = 1000;
+ val4 = tick / tick_time;
+ break;
+ case SC_KINGS_GRACE:
+ val2 = 3 + val1;
+ tick_time = 1000;
+ val4 = tick / tick_time;
+ break;
+ case SC_TELEKINESIS_INTENSE:
+ val2 = 10 * val1;
+ val3 = 40 * val1;
+ break;
+ case SC_OFFERTORIUM:
+ val2 = 30 * val1;
+ break;
+ case SC_FRIGG_SONG:
+ val2 = 5 * val1;
+ val3 = 1000 + 100 * val1;
+ tick_time = 10000;
+ val4 = tick / tick_time;
+ break;
+ case SC_MONSTER_TRANSFORM:
+ if( !mobdb_checkid(val1) )
+ val1 = 1002; // default poring
+ val_flag |= 1;
+ break;
+ default:
+ if( calc_flag == SCB_NONE && StatusSkillChangeTable[type] == 0 && StatusIconChangeTable[type] == 0 )
+ { //Status change with no calc, no icon, and no skill associated...?
+ ShowError("UnknownStatusChange [%d]\n", type);
+ return 0;
+ }
}
} else { //Special considerations when loading SC data.
switch( type ) {
@@ -8617,6 +8733,17 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_KAAHI:
val4 = INVALID_TIMER;
break;
+ case SC_SUMMON1:
+ case SC_SUMMON2:
+ case SC_SUMMON3:
+ case SC_SUMMON4:
+ case SC_SUMMON5:
+ case SC_MONSTER_TRANSFORM:
+ val_flag |= 1;
+ break;
+ case SC_KYOUGAKU:
+ clif->status_change(bl, SI_ACTIVE_MONSTER_TRANSFORM, 1, 0, 1002, 0, 0); // Poring in disguise
+ break;
}
}
@@ -8640,9 +8767,9 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_STUN:
case SC_SLEEP:
case SC_STONE:
- case SC_DEEPSLEEP:
+ case SC_DEEP_SLEEP:
if (sd && pc_issit(sd)) //Avoid sprite sync problems.
- pc_setstand(sd);
+ pc->setstand(sd);
case SC_TRICKDEAD:
status_change_end(bl, SC_DANCING, INVALID_TIMER);
// Cancel cast when get status [LuzZza]
@@ -8652,12 +8779,12 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
unit_stop_attack(bl);
case SC_STOP:
case SC_CONFUSION:
- case SC_CLOSECONFINE:
- case SC_CLOSECONFINE2:
+ case SC_RG_CCONFINE_M:
+ case SC_RG_CCONFINE_S:
case SC_SPIDERWEB:
case SC_ELECTRICSHOCKER:
- case SC_BITE:
- case SC_THORNSTRAP:
+ case SC_WUGBITE:
+ case SC_THORNS_TRAP:
case SC__MANHOLE:
case SC_CRYSTALIZE:
case SC_CURSEDCIRCLE_ATKER:
@@ -8666,10 +8793,11 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_NETHERWORLD:
case SC_MEIKYOUSISUI:
case SC_KYOUGAKU:
- case SC_PARALYSIS:
+ case SC_NEEDLE_OF_PARALYZE:
+ case SC_DEATHBOUND:
unit_stop_walking(bl,1);
break;
- case SC_ANKLE:
+ case SC_ANKLESNARE:
if( battle_config.skill_trap_type || !map_flag_gvg(bl->m) )
unit_stop_walking(bl,1);
break;
@@ -8677,15 +8805,36 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_CLOAKING:
case SC_CLOAKINGEXCEED:
case SC_CHASEWALK:
- case SC_WEIGHT90:
+ case SC_WEIGHTOVER90:
case SC_CAMOUFLAGE:
- case SC_VOICEOFSIREN:
+ case SC_SIREN:
unit_stop_attack(bl);
break;
case SC_SILENCE:
if (battle_config.sc_castcancel&bl->type)
unit_skillcastcancel(bl, 0);
break;
+ /* */
+ case SC_ITEMSCRIPT:
+ if( sd ) {
+ switch( val1 ) {
+ //case 4121://Phree
+ //case 4047://Ghostring
+ case 4302://Gunka
+ clif->status_change(bl,SI_MVPCARD_TAOGUNKA,1,tick,0,0,0);
+ break;
+ case 4132://Mistress
+ clif->status_change(bl,SI_MVPCARD_MISTRESS,1,tick,0,0,0);
+ break;
+ case 4143://Orc Hero
+ clif->status_change(bl,SI_MVPCARD_ORCHERO,1,tick,0,0,0);
+ break;
+ case 4135://Orc Lord
+ clif->status_change(bl,SI_MVPCARD_ORCLORD,1,tick,0,0,0);
+ break;
+ }
+ }
+ break;
}
// Set option as needed.
@@ -8695,7 +8844,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_STONE: sc->opt1 = OPT1_STONEWAIT; break;
case SC_FREEZE: sc->opt1 = OPT1_FREEZE; break;
case SC_STUN: sc->opt1 = OPT1_STUN; break;
- case SC_DEEPSLEEP: opt_flag = 0;
+ case SC_DEEP_SLEEP: opt_flag = 0;
case SC_SLEEP: sc->opt1 = OPT1_SLEEP; break;
case SC_BURNING: sc->opt1 = OPT1_BURNING; break; // Burning need this to be showed correctly. [pakpil]
case SC_WHITEIMPRISON: sc->opt1 = OPT1_IMPRISON; break;
@@ -8705,24 +8854,24 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_CURSE: sc->opt2 |= OPT2_CURSE; break;
case SC_SILENCE: sc->opt2 |= OPT2_SILENCE; break;
- case SC_SIGNUMCRUCIS:
+ case SC_CRUCIS:
sc->opt2 |= OPT2_SIGNUMCRUCIS;
break;
case SC_BLIND: sc->opt2 |= OPT2_BLIND; break;
case SC_ANGELUS: sc->opt2 |= OPT2_ANGELUS; break;
- case SC_BLEEDING: sc->opt2 |= OPT2_BLEEDING; break;
+ case SC_BLOODING: sc->opt2 |= OPT2_BLEEDING; break;
case SC_DPOISON: sc->opt2 |= OPT2_DPOISON; break;
//OPT3
case SC_TWOHANDQUICKEN:
- case SC_ONEHAND:
+ case SC_ONEHANDQUICKEN:
case SC_SPEARQUICKEN:
- case SC_CONCENTRATION:
- case SC_MERC_QUICKEN:
+ case SC_LKCONCENTRATION:
+ case SC_MER_QUICKEN:
sc->opt3 |= OPT3_QUICKEN;
opt_flag = 0;
break;
- case SC_MAXOVERTHRUST:
+ case SC_OVERTHRUSTMAX:
case SC_OVERTHRUST:
case SC_SWOO: //Why does it shares the same opt as Overthrust? Perhaps we'll never know...
sc->opt3 |= OPT3_OVERTHRUST;
@@ -8770,8 +8919,8 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
sc->opt3 |= OPT3_MOONLIT;
opt_flag = 0;
break;
+ case SC_MARIONETTE_MASTER:
case SC_MARIONETTE:
- case SC_MARIONETTE2:
sc->opt3 |= OPT3_MARIONETTE;
opt_flag = 0;
break;
@@ -8787,15 +8936,15 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
sc->opt3 |= OPT3_KAITE;
opt_flag = 0;
break;
- case SC_BUNSINJYUTSU:
+ case SC_NJ_BUNSINJYUTSU:
sc->opt3 |= OPT3_BUNSIN;
opt_flag = 0;
break;
- case SC_SPIRIT:
+ case SC_SOULLINK:
sc->opt3 |= OPT3_SOULLINK;
opt_flag = 0;
break;
- case SC_CHANGEUNDEAD:
+ case SC_PROPERTYUNDEAD:
sc->opt3 |= OPT3_UNDEAD;
opt_flag = 0;
break;
@@ -8880,7 +9029,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
//Don't trust the previous sce assignment, in case the SC ended somewhere between there and here.
if((sce=sc->data[type])) {// reuse old sc
if( sce->timer != INVALID_TIMER )
- delete_timer(sce->timer, status_change_timer);
+ iTimer->delete_timer(sce->timer, status_change_timer);
} else {// new sc
++(sc->count);
sce = sc->data[type] = ers_alloc(sc_data_ers, struct status_change_entry);
@@ -8890,7 +9039,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
sce->val3 = val3;
sce->val4 = val4;
if (tick >= 0)
- sce->timer = add_timer(gettick() + tick, status_change_timer, bl->id, type);
+ sce->timer = iTimer->add_timer(iTimer->gettick() + tick, status_change_timer, bl->id, type);
else
sce->timer = INVALID_TIMER; //Infinite duration
@@ -8909,7 +9058,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
}
sce->val2 = 5 * status->max_hp / 100;
break;
- case SC_CHANGE:
+ case SC_HLIF_CHANGE:
status_percent_heal(bl, 100, 100);
break;
case SC_RUN:
@@ -8919,13 +9068,13 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
ud->state.running = unit_run(bl);
}
break;
- case SC_BOSSMAPINFO:
- clif->bossmapinfo(sd->fd, map_id2boss(sce->val1), 0); // First Message
+ case SC_CASH_BOSS_ALARM:
+ clif->bossmapinfo(sd->fd, iMap->id2boss(sce->val1), 0); // First Message
break;
- case SC_MERC_HPUP:
+ case SC_MER_HP:
status_percent_heal(bl, 100, 0); // Recover Full HP
break;
- case SC_MERC_SPUP:
+ case SC_MER_SP:
status_percent_heal(bl, 0, 100); // Recover Full SP
break;
/**
@@ -8938,7 +9087,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
ud->state.running = unit_wugdash(bl, sd);
}
break;
- case SC_COMBO:
+ case SC_COMBOATTACK:
switch (sce->val1) {
case TK_STORMKICK:
clif->skill_nodamage(bl,bl,TK_READYSTORM,1,1);
@@ -8963,7 +9112,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
clif->skillinfo(sd,TK_JUMPKICK, INF_SELF_SKILL);
break;
case MO_TRIPLEATTACK:
- if (sd && pc_checkskill(sd, SR_DRAGONCOMBO) > 0)
+ if (sd && pc->checkskill(sd, SR_DRAGONCOMBO) > 0)
clif->skillinfo(sd,SR_DRAGONCOMBO, INF_SELF_SKILL);
break;
case SR_FALLENEMPIRE:
@@ -9006,68 +9155,25 @@ int status_change_clear(struct block_list* bl, int type) {
for(i = 0; i < SC_MAX; i++) {
if(!sc->data[i])
continue;
-
- if(type == 0) {
- switch (i) { //Type 0: PC killed -> Place here statuses that do not dispel on death.
- case SC_ELEMENTALCHANGE://Only when its Holy or Dark that it doesn't dispell on death
- if( sc->data[i]->val2 != ELE_HOLY && sc->data[i]->val2 != ELE_DARK )
- break;
- case SC_WEIGHT50:
- case SC_WEIGHT90:
- case SC_EDP:
- case SC_MELTDOWN:
- case SC_XMAS:
- case SC_SUMMER:
- case SC_HANBOK:
- case SC_NOCHAT:
- case SC_FUSION:
- case SC_EARTHSCROLL:
- case SC_READYSTORM:
- case SC_READYDOWN:
- case SC_READYCOUNTER:
- case SC_READYTURN:
- case SC_DODGE:
- case SC_JAILED:
- case SC_EXPBOOST:
- case SC_ITEMBOOST:
- case SC_HELLPOWER:
- case SC_JEXPBOOST:
- case SC_AUTOTRADE:
- case SC_WHISTLE:
- case SC_ASSNCROS:
- case SC_POEMBRAGI:
- case SC_APPLEIDUN:
- case SC_HUMMING:
- case SC_DONTFORGETME:
- case SC_FORTUNE:
- case SC_SERVICE4U:
- case SC_FOOD_STR_CASH:
- case SC_FOOD_AGI_CASH:
- case SC_FOOD_VIT_CASH:
- case SC_FOOD_DEX_CASH:
- case SC_FOOD_INT_CASH:
- case SC_FOOD_LUK_CASH:
- case SC_DEF_RATE:
- case SC_MDEF_RATE:
- case SC_INCHEALRATE:
- case SC_INCFLEE2:
- case SC_INCHIT:
- case SC_ATKPOTION:
- case SC_MATKPOTION:
- case SC_S_LIFEPOTION:
- case SC_L_LIFEPOTION:
- case SC_PUSH_CART:
- case SC_ALL_RIDING:
- continue;
+
+ if(type == 0){
+ if( status_get_sc_type(i)&SC_NO_REM_DEATH ){
+ switch (i) {
+ case SC_ARMOR_PROPERTY://Only when its Holy or Dark that it doesn't dispell on death
+ if( sc->data[i]->val2 != ELE_HOLY && sc->data[i]->val2 != ELE_DARK )
+ break;
+ default:
+ continue;
+ }
}
}
-
if( type == 3 ) {
switch (i) {// TODO: This list may be incomplete
- case SC_WEIGHT50:
- case SC_WEIGHT90:
+ case SC_WEIGHTOVER50:
+ case SC_WEIGHTOVER90:
case SC_NOCHAT:
case SC_PUSH_CART:
+ case SC_JAILED:
case SC_ALL_RIDING:
continue;
}
@@ -9079,7 +9185,7 @@ int status_change_clear(struct block_list* bl, int type) {
//If for some reason status_change_end decides to still keep the status when quitting. [Skotlex]
(sc->count)--;
if (sc->data[i]->timer != INVALID_TIMER)
- delete_timer(sc->data[i]->timer, status_change_timer);
+ iTimer->delete_timer(sc->data[i]->timer, status_change_timer);
ers_free(sc_data_ers, sc->data[i]);
sc->data[i] = NULL;
}
@@ -9092,6 +9198,7 @@ int status_change_clear(struct block_list* bl, int type) {
#ifndef RENEWAL
sc->sg_counter = 0;
#endif
+
if( type == 0 || type == 2 )
clif->changeoption(bl);
@@ -9127,26 +9234,26 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
//Do not end infinite endure.
return 0;
if (sce->timer != INVALID_TIMER) //Could be a SC with infinite duration
- delete_timer(sce->timer,status_change_timer);
+ iTimer->delete_timer(sce->timer,status_change_timer);
if (sc->opt1)
- switch (type) {
- //"Ugly workaround" [Skotlex]
- //delays status change ending so that a skill that sets opt1 fails to
- //trigger when it also removed one
- case SC_STONE:
- sce->val3 = 0; //Petrify time counter.
- case SC_FREEZE:
- case SC_STUN:
- case SC_SLEEP:
- if (sce->val1) {
- //Removing the 'level' shouldn't affect anything in the code
- //since these SC are not affected by it, and it lets us know
- //if we have already delayed this attack or not.
- sce->val1 = 0;
- sce->timer = add_timer(gettick()+10, status_change_timer, bl->id, type);
- return 1;
+ switch (type) {
+ //"Ugly workaround" [Skotlex]
+ //delays status change ending so that a skill that sets opt1 fails to
+ //trigger when it also removed one
+ case SC_STONE:
+ sce->val3 = 0; //Petrify time counter.
+ case SC_FREEZE:
+ case SC_STUN:
+ case SC_SLEEP:
+ if (sce->val1) {
+ //Removing the 'level' shouldn't affect anything in the code
+ //since these SC are not affected by it, and it lets us know
+ //if we have already delayed this attack or not.
+ sce->val1 = 0;
+ sce->timer = iTimer->add_timer(iTimer->gettick()+10, status_change_timer, bl->id, type);
+ return 1;
+ }
}
- }
}
(sc->count)--;
@@ -9159,7 +9266,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
vd = status_get_viewdata(bl);
calc_flag = StatusChangeFlagTable[type];
- switch(type){
+ switch(type) {
case SC_GRANITIC_ARMOR:{
int dammage = status->max_hp*sce->val3/100;
if(status->hp < dammage) //to not kill him
@@ -9183,10 +9290,10 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
unit_stop_walking(bl,1);
}
if (begin_spurt && sce->val1 >= 7 &&
- DIFF_TICK(gettick(), sce->val4) <= 1000 &&
+ DIFF_TICK(iTimer->gettick(), sce->val4) <= 1000 &&
(!sd || (sd->weapontype1 == 0 && sd->weapontype2 == 0))
)
- sc_start(bl,SC_SPURT,100,sce->val1,skill->get_time2(status_sc2skill(type), sce->val1));
+ sc_start(bl,SC_STRUP,100,sce->val1,skill->get_time2(status_sc2skill(type), sce->val1));
}
break;
case SC_AUTOBERSERK:
@@ -9205,7 +9312,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
int i;
for( i = 0; i < 5; i++ )
{
- if( sd->devotion[i] && (tsd = map_id2sd(sd->devotion[i])) && tsd->sc.data[type] )
+ if( sd->devotion[i] && (tsd = iMap->id2sd(sd->devotion[i])) && tsd->sc.data[type] )
status_change_end(&tsd->bl, type, INVALID_TIMER);
}
}
@@ -9219,7 +9326,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
break;
case SC_DEVOTION:
{
- struct block_list *d_bl = map_id2bl(sce->val1);
+ struct block_list *d_bl = iMap->id2bl(sce->val1);
if( d_bl )
{
if( d_bl->type == BL_PC )
@@ -9240,7 +9347,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
if(sce->val4)
{
int tid = sce->val4;
- struct block_list *tbl = map_id2bl(tid);
+ struct block_list *tbl = iMap->id2bl(tid);
struct status_change *tsc = status_get_sc(tbl);
sce->val4 = 0;
if(tbl && tsc && tsc->data[SC_BLADESTOP])
@@ -9274,7 +9381,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
sd->delunit_prevline = line;
}
- if(sce->val4 && sce->val4 != BCT_SELF && (dsd=map_id2sd(sce->val4)))
+ if(sce->val4 && sce->val4 != BCT_SELF && (dsd=iMap->id2sd(sce->val4)))
{// end status on partner as well
dsc = dsd->sc.data[SC_DANCING];
if(dsc) {
@@ -9305,7 +9412,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
}
if((sce->val1&0xFFFF) == CG_MOONLIT)
- clif->sc_end(bl,bl->id,AREA,SI_MOONLIT);
+ clif->sc_end(bl,bl->id,AREA,SI_MOON);
status_change_end(bl, SC_LONGING, INVALID_TIMER);
}
@@ -9321,33 +9428,33 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
break;
case SC_SPLASHER:
{
- struct block_list *src=map_id2bl(sce->val3);
+ struct block_list *src=iMap->id2bl(sce->val3);
if(src && tid != INVALID_TIMER)
- skill->castend_damage_id(src, bl, sce->val2, sce->val1, gettick(), SD_LEVEL );
+ skill->castend_damage_id(src, bl, sce->val2, sce->val1, iTimer->gettick(), SD_LEVEL );
}
break;
- case SC_CLOSECONFINE2:
+ case SC_RG_CCONFINE_S:
{
- struct block_list *src = sce->val2?map_id2bl(sce->val2):NULL;
+ struct block_list *src = sce->val2?iMap->id2bl(sce->val2):NULL;
struct status_change *sc2 = src?status_get_sc(src):NULL;
- if (src && sc2 && sc2->data[SC_CLOSECONFINE]) {
+ if (src && sc2 && sc2->data[SC_RG_CCONFINE_M]) {
//If status was already ended, do nothing.
//Decrease count
- if (--(sc2->data[SC_CLOSECONFINE]->val1) <= 0) //No more holds, free him up.
- status_change_end(src, SC_CLOSECONFINE, INVALID_TIMER);
+ if (--(sc2->data[SC_RG_CCONFINE_M]->val1) <= 0) //No more holds, free him up.
+ status_change_end(src, SC_RG_CCONFINE_M, INVALID_TIMER);
}
}
- case SC_CLOSECONFINE:
+ case SC_RG_CCONFINE_M:
if (sce->val2 > 0) {
//Caster has been unlocked... nearby chars need to be unlocked.
int range = 1
+skill->get_range2(bl, status_sc2skill(type), sce->val1)
+skill->get_range2(bl, TF_BACKSLIDING, 1); //Since most people use this to escape the hold....
- map_foreachinarea(status_change_timer_sub,
- bl->m, bl->x-range, bl->y-range, bl->x+range,bl->y+range,BL_CHAR,bl,sce,type,gettick());
+ iMap->foreachinarea(status_change_timer_sub,
+ bl->m, bl->x-range, bl->y-range, bl->x+range,bl->y+range,BL_CHAR,bl,sce,type,iTimer->gettick());
}
break;
- case SC_COMBO:
+ case SC_COMBOATTACK:
if( sd )
switch (sce->val1) {
case MO_COMBOFINISH:
@@ -9359,7 +9466,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
clif->skillinfo(sd, TK_JUMPKICK, 0);
break;
case MO_TRIPLEATTACK:
- if (pc_checkskill(sd, SR_DRAGONCOMBO) > 0)
+ if (pc->checkskill(sd, SR_DRAGONCOMBO) > 0)
clif->skillinfo(sd, SR_DRAGONCOMBO, 0);
break;
case SR_FALLENEMPIRE:
@@ -9369,12 +9476,12 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
}
break;
- case SC_MARIONETTE:
- case SC_MARIONETTE2: /// Marionette target
+ case SC_MARIONETTE_MASTER:
+ case SC_MARIONETTE: /// Marionette target
if (sce->val1)
{ // check for partner and end their marionette status as well
- enum sc_type type2 = (type == SC_MARIONETTE) ? SC_MARIONETTE2 : SC_MARIONETTE;
- struct block_list *pbl = map_id2bl(sce->val1);
+ enum sc_type type2 = (type == SC_MARIONETTE_MASTER) ? SC_MARIONETTE : SC_MARIONETTE_MASTER;
+ struct block_list *pbl = iMap->id2bl(sce->val1);
struct status_change* sc2 = pbl?status_get_sc(pbl):NULL;
if (sc2 && sc2->data[type2])
@@ -9386,7 +9493,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
break;
case SC_BERSERK:
- case SC_SATURDAYNIGHTFEVER:
+ case SC_SATURDAY_NIGHT_FEVER:
//If val2 is removed, no HP penalty (dispelled?) [Skotlex]
if (status->hp > 100 && sce->val2)
status_set_hp(bl, 100, 0);
@@ -9396,8 +9503,8 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
status_change_end(bl, SC_ENDURE, INVALID_TIMER);
}
case SC__BLOODYLUST:
- sc_start4(bl, SC_REGENERATION, 100, 10,0,0,(RGN_HP|RGN_SP), skill->get_time(LK_BERSERK, sce->val1));
- if( type == SC_SATURDAYNIGHTFEVER ) //Sit down force of Saturday Night Fever has the duration of only 3 seconds.
+ sc_start4(bl, SC_GDSKILL_REGENERATION, 100, 10,0,0,(RGN_HP|RGN_SP), skill->get_time(LK_BERSERK, sce->val1));
+ if( type == SC_SATURDAY_NIGHT_FEVER ) //Sit down force of Saturday Night Fever has the duration of only 3 seconds.
sc_start(bl,SC_SITDOWN_FORCE,100,sce->val1,skill->get_time2(WM_SATURDAY_NIGHT_FEVER,sce->val1));
break;
case SC_GOSPEL:
@@ -9429,16 +9536,16 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
case SC_KAAHI:
//Delete timer if it exists.
if (sce->val4 != INVALID_TIMER)
- delete_timer(sce->val4,kaahi_heal_timer);
+ iTimer->delete_timer(sce->val4,kaahi_heal_timer);
break;
case SC_JAILED:
if(tid == INVALID_TIMER)
break;
//natural expiration.
if(sd && sd->mapindex == sce->val2)
- pc_setpos(sd,(unsigned short)sce->val3,sce->val4&0xFFFF, sce->val4>>16, CLR_TELEPORT);
+ pc->setpos(sd,(unsigned short)sce->val3,sce->val4&0xFFFF, sce->val4>>16, CLR_TELEPORT);
break; //guess hes not in jail :P
- case SC_CHANGE:
+ case SC_HLIF_CHANGE:
if (tid == INVALID_TIMER)
break;
// "lose almost all their HP and SP" on natural expiration.
@@ -9450,20 +9557,23 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
break;
// Note: vending/buying is closed by unit_remove_map, no
// need to do it here.
- map_quit(sd);
- // Because map_quit calls status_change_end with tid -1
+ iMap->quit(sd);
+ // Because iMap->quit calls status_change_end with tid -1
// from here it's not neccesary to continue
return 1;
break;
case SC_STOP:
if( sce->val2 )
{
- struct block_list* tbl = map_id2bl(sce->val2);
+ struct block_list* tbl = iMap->id2bl(sce->val2);
sce->val2 = 0;
if( tbl && (sc = status_get_sc(tbl)) && sc->data[SC_STOP] && sc->data[SC_STOP]->val2 == bl->id )
status_change_end(tbl, SC_STOP, INVALID_TIMER);
}
break;
+ case SC_LKCONCENTRATION:
+ status_change_end(bl, SC_ENDURE, INVALID_TIMER);
+ break;
/**
* 3rd Stuff
**/
@@ -9475,10 +9585,10 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
break;
case SC_WHITEIMPRISON:
{
- struct block_list* src = map_id2bl(sce->val2);
+ struct block_list* src = iMap->id2bl(sce->val2);
if( tid == -1 || !src)
break; // Terminated by Damage
- status_fix_damage(src,bl,400*sce->val1,clif->damage(bl,bl,gettick(),0,0,400*sce->val1,0,0,0));
+ status_fix_damage(src,bl,400*sce->val1,clif->damage(bl,bl,iTimer->gettick(),0,0,400*sce->val1,0,0,0));
}
break;
case SC_WUGDASH:
@@ -9495,7 +9605,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
status_change_end(bl, SC_BLIND, INVALID_TIMER);
break;
case SC__SHADOWFORM: {
- struct map_session_data *s_sd = map_id2sd(sce->val2);
+ struct map_session_data *s_sd = iMap->id2sd(sce->val2);
if( !s_sd )
break;
s_sd->shadowform_id = 0;
@@ -9503,7 +9613,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
break;
case SC_SITDOWN_FORCE:
if( sd && pc_issit(sd) ) {
- pc_setstand(sd);
+ pc->setstand(sd);
clif->standing(bl);
}
break;
@@ -9526,23 +9636,23 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
break;
case SC_CURSEDCIRCLE_ATKER:
if( sce->val2 ) // used the default area size cause there is a chance the caster could knock back and can't clear the target.
- map_foreachinrange(status_change_timer_sub, bl, battle_config.area_size,BL_CHAR, bl, sce, SC_CURSEDCIRCLE_TARGET, gettick());
+ iMap->foreachinrange(status_change_timer_sub, bl, battle_config.area_size,BL_CHAR, bl, sce, SC_CURSEDCIRCLE_TARGET, iTimer->gettick());
break;
case SC_RAISINGDRAGON:
if( sd && sce->val2 && !pc_isdead(sd) ) {
int i;
i = min(sd->spiritball,5);
- pc_delspiritball(sd, sd->spiritball, 0);
+ pc->delspiritball(sd, sd->spiritball, 0);
status_change_end(bl, SC_EXPLOSIONSPIRITS, INVALID_TIMER);
while( i > 0 ) {
- pc_addspiritball(sd, skill->get_time(MO_CALLSPIRITS, pc_checkskill(sd,MO_CALLSPIRITS)), 5);
+ pc->addspiritball(sd, skill->get_time(MO_CALLSPIRITS, pc->checkskill(sd,MO_CALLSPIRITS)), 5);
--i;
}
}
break;
case SC_CURSEDCIRCLE_TARGET:
{
- struct block_list *src = map_id2bl(sce->val2);
+ struct block_list *src = iMap->id2bl(sce->val2);
struct status_change *sc = status_get_sc(src);
if( sc && sc->data[SC_CURSEDCIRCLE_ATKER] && --(sc->data[SC_CURSEDCIRCLE_ATKER]->val2) == 0 ){
status_change_end(src, SC_CURSEDCIRCLE_ATKER, INVALID_TIMER);
@@ -9550,9 +9660,9 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
}
}
break;
- case SC_BLOODSUCKER:
+ case SC_BLOOD_SUCKER:
if( sce->val2 ){
- struct block_list *src = map_id2bl(sce->val2);
+ struct block_list *src = iMap->id2bl(sce->val2);
if(src){
struct status_change *sc = status_get_sc(src);
sc->bs_counter--;
@@ -9560,13 +9670,35 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
}
break;
case SC_KYOUGAKU:
- clif->sc_end(&sd->bl,sd->bl.id,AREA,SI_KYOUGAKU);
clif->sc_end(&sd->bl,sd->bl.id,AREA,SI_ACTIVE_MONSTER_TRANSFORM);
break;
- case SC_INTRAVISION:
+ case SC_CLAIRVOYANCE:
calc_flag = SCB_ALL;/* required for overlapping */
break;
- }
+ case SC_FULL_THROTTLE:
+ sc_start(bl,SC_REBOUND,100,sce->val1,skill->get_time2(ALL_FULL_THROTTLE,sce->val1));
+ break;
+ case SC_ITEMSCRIPT:
+ if( sd ) {
+ switch( sce->val1 ) {
+ //case 4121://Phree
+ //case 4047://Ghostring
+ case 4302://Gunka
+ clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_MVPCARD_TAOGUNKA);
+ break;
+ case 4132://Mistress
+ clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_MVPCARD_MISTRESS);
+ break;
+ case 4143://Orc Hero
+ clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_MVPCARD_ORCHERO);
+ break;
+ case 4135://Orc Lord
+ clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_MVPCARD_ORCLORD);
+ break;
+ }
+ }
+ break;
+ }
opt_flag = 1;
switch(type){
@@ -9574,7 +9706,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
case SC_FREEZE:
case SC_STUN:
case SC_SLEEP:
- case SC_DEEPSLEEP:
+ case SC_DEEP_SLEEP:
case SC_BURNING:
case SC_WHITEIMPRISON:
case SC_CRYSTALIZE:
@@ -9590,7 +9722,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
case SC_DPOISON:
sc->opt2 &= ~OPT2_DPOISON;
break;
- case SC_SIGNUMCRUCIS:
+ case SC_CRUCIS:
sc->opt2 &= ~OPT2_SIGNUMCRUCIS;
break;
@@ -9639,15 +9771,15 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
break;
//opt3
case SC_TWOHANDQUICKEN:
- case SC_ONEHAND:
+ case SC_ONEHANDQUICKEN:
case SC_SPEARQUICKEN:
case SC_CONCENTRATION:
- case SC_MERC_QUICKEN:
+ case SC_MER_QUICKEN:
sc->opt3 &= ~OPT3_QUICKEN;
opt_flag = 0;
break;
case SC_OVERTHRUST:
- case SC_MAXOVERTHRUST:
+ case SC_OVERTHRUSTMAX:
case SC_SWOO:
sc->opt3 &= ~OPT3_OVERTHRUST;
if( type == SC_SWOO )
@@ -9698,7 +9830,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
opt_flag = 0;
break;
case SC_MARIONETTE:
- case SC_MARIONETTE2:
+ case SC_MARIONETTE_MASTER:
sc->opt3 &= ~OPT3_MARIONETTE;
opt_flag = 0;
break;
@@ -9714,15 +9846,15 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
sc->opt3 &= ~OPT3_KAITE;
opt_flag = 0;
break;
- case SC_BUNSINJYUTSU:
+ case SC_NJ_BUNSINJYUTSU:
sc->opt3 &= ~OPT3_BUNSIN;
opt_flag = 0;
break;
- case SC_SPIRIT:
+ case SC_SOULLINK:
sc->opt3 &= ~OPT3_SOULLINK;
opt_flag = 0;
break;
- case SC_CHANGEUNDEAD:
+ case SC_PROPERTYUNDEAD:
sc->opt3 &= ~OPT3_UNDEAD;
opt_flag = 0;
break;
@@ -9760,9 +9892,9 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
status_calc_bl(bl,calc_flag);
if(opt_flag&4) //Out of hiding, invoke on place.
- skill->unit_move(bl,gettick(),1);
+ skill->unit_move(bl,iTimer->gettick(),1);
- if(opt_flag&2 && sd && map_getcell(bl->m,bl->x,bl->y,CELL_CHKNPC))
+ if(opt_flag&2 && sd && iMap->getcell(bl->m,bl->x,bl->y,CELL_CHKNPC))
npc_touch_areanpc(sd,bl->m,bl->x,bl->y); //Trigger on-touch event.
ers_free(sc_data_ers, sce);
@@ -9777,7 +9909,7 @@ int kaahi_heal_timer(int tid, unsigned int tick, int id, intptr_t data)
struct status_data *status;
int hp;
- if(!((bl=map_id2bl(id))&&
+ if(!((bl=iMap->id2bl(id))&&
(sc=status_get_sc(bl)) &&
(sce = sc->data[SC_KAAHI])))
return 0;
@@ -9816,7 +9948,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
struct status_change *sc;
struct status_change_entry *sce;
- bl = map_id2bl(id);
+ bl = iMap->id2bl(id);
if(!bl)
{
ShowDebug("status_change_timer: Null pointer id: %d data: %d\n", id, data);
@@ -9842,7 +9974,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
// set the next timer of the sce (don't assume the status still exists)
#define sc_timer_next(t,f,i,d) \
if( (sce=sc->data[type]) ) \
- sce->timer = add_timer(t,f,i,d); \
+ sce->timer = iTimer->add_timer(t,f,i,d); \
else \
ShowError("status_change_timer: Unexpected NULL status change id: %d data: %d\n", id, data)
@@ -9859,9 +9991,9 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if(!status_charge(bl, 0, sce->val4))
break; //Not enough SP to continue.
- if (!sc->data[SC_INCSTR]) {
- sc_start(bl, SC_INCSTR,100,1<<(sce->val1-1),
- (sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_ROGUE?10:1) //SL bonus -> x10 duration
+ if (!sc->data[SC_CHASEWALK2]) {
+ sc_start(bl, SC_CHASEWALK2,100,1<<(sce->val1-1),
+ (sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_ROGUE?10:1) //SL bonus -> x10 duration
*skill->get_time2(status_sc2skill(type),sce->val1));
}
sc_timer_next(sce->val2+tick, status_change_timer, bl->id, data);
@@ -9889,11 +10021,11 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
case SC_SIGHT:
case SC_RUWACH:
- case SC_SIGHTBLASTER:
- if(type == SC_SIGHTBLASTER)
- map_foreachinrange( status_change_timer_sub, bl, sce->val3, BL_CHAR|BL_SKILL, bl, sce, type, tick);
+ case SC_WZ_SIGHTBLASTER:
+ if(type == SC_WZ_SIGHTBLASTER)
+ iMap->foreachinrange( status_change_timer_sub, bl, sce->val3, BL_CHAR|BL_SKILL, bl, sce, type, tick);
else
- map_foreachinrange( status_change_timer_sub, bl, sce->val3, BL_CHAR, bl, sce, type, tick);
+ iMap->foreachinrange( status_change_timer_sub, bl, sce->val3, BL_CHAR, bl, sce, type, tick);
if( --(sce->val2)>0 ){
sce->val4 += 250; // use for Shadow Form 2 seconds checking.
@@ -9935,16 +10067,16 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if (--(sce->val3) > 0) {
if (!sc->data[SC_SLOWPOISON]) {
if( sce->val2 && bl->type == BL_MOB ) {
- struct block_list* src = map_id2bl(sce->val2);
+ struct block_list* src = iMap->id2bl(sce->val2);
if( src )
mob_log_damage((TBL_MOB*)bl,src,sce->val4);
}
- map_freeblock_lock();
+ iMap->freeblock_lock();
status_zap(bl, sce->val4, 0);
if (sc->data[type]) { // Check if the status still last ( can be dead since then ).
sc_timer_next(1000 + tick, status_change_timer, bl->id, data );
}
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
}
return 0;
}
@@ -9962,29 +10094,29 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if(bl->m == sd->feel_map[0].m ||
bl->m == sd->feel_map[1].m ||
bl->m == sd->feel_map[2].m)
- { //Timeout will be handled by pc_setpos
+ { //Timeout will be handled by pc->setpos
sce->timer = INVALID_TIMER;
return 0;
}
break;
- case SC_BLEEDING:
+ case SC_BLOODING:
if (--(sce->val4) >= 0) {
int hp = rnd()%600 + 200;
- struct block_list* src = map_id2bl(sce->val2);
+ struct block_list* src = iMap->id2bl(sce->val2);
if( src && bl && bl->type == BL_MOB ) {
mob_log_damage((TBL_MOB*)bl,src,sd||hp<status->hp?hp:status->hp-1);
}
- map_freeblock_lock();
+ iMap->freeblock_lock();
status_fix_damage(src, bl, sd||hp<status->hp?hp:status->hp-1, 1);
if( sc->data[type] ) {
if( status->hp == 1 ) {
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
break;
}
sc_timer_next(10000 + tick, status_change_timer, bl->id, data);
}
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
break;
@@ -10003,10 +10135,10 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
}
break;
- case SC_BOSSMAPINFO:
+ case SC_CASH_BOSS_ALARM:
if( sd && --(sce->val4) >= 0 )
{
- struct mob_data *boss_md = map_id2boss(sce->val1);
+ struct mob_data *boss_md = iMap->id2boss(sce->val1);
if( boss_md && sd->bl.m == boss_md->bl.m )
{
clif->bossmapinfo(sd->fd, boss_md, 1); // Update X - Y on minimap
@@ -10110,10 +10242,10 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
}
break;
+ case SC_MARIONETTE_MASTER:
case SC_MARIONETTE:
- case SC_MARIONETTE2:
{
- struct block_list *pbl = map_id2bl(sce->val1);
+ struct block_list *pbl = iMap->id2bl(sce->val1);
if( pbl && check_distance_bl(bl, pbl, 7) )
{
sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
@@ -10158,45 +10290,45 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
break;
case SC_PYREXIA:
- if( --(sce->val4) >= 0 ) {
- map_freeblock_lock();
+ if( --(sce->val4) > 0 ) {
+ iMap->freeblock_lock();
clif->damage(bl,bl,tick,status_get_amotion(bl),status_get_dmotion(bl)+500,100,0,0,0);
status_fix_damage(NULL,bl,100,0);
if( sc->data[type] ) {
sc_timer_next(3000+tick,status_change_timer,bl->id,data);
}
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
break;
case SC_LEECHESEND:
- if( --(sce->val4) >= 0 ) {
+ if( --(sce->val4) > 0 ) {
int damage = status->max_hp/100; // {Target VIT x (New Poison Research Skill Level - 3)} + (Target HP/100)
damage += status->vit * (sce->val1 - 3);
unit_skillcastcancel(bl,2);
- map_freeblock_lock();
+ iMap->freeblock_lock();
status_damage(bl, bl, damage, 0, clif->damage(bl,bl,tick,status_get_amotion(bl),status_get_dmotion(bl)+500,damage,1,0,0), 1);
if( sc->data[type] ) {
sc_timer_next(1000 + tick, status_change_timer, bl->id, data );
}
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
break;
case SC_MAGICMUSHROOM:
- if( --(sce->val4) >= 0 ) {
+ if( --(sce->val4) > 0 ) {
bool flag = 0;
int damage = status->max_hp * 3 / 100;
if( status->hp <= damage )
damage = status->hp - 1; // Cannot Kill
if( damage > 0 ) { // 3% Damage each 4 seconds
- map_freeblock_lock();
+ iMap->freeblock_lock();
status_zap(bl,damage,0);
flag = !sc->data[type]; // Killed? Should not
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
}
if( !flag ) { // Random Skill Cast
@@ -10231,21 +10363,21 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
break;
case SC_TOXIN:
- if( --(sce->val4) >= 0 )
+ if( --(sce->val4) > 0 )
{ //Damage is every 10 seconds including 3%sp drain.
- map_freeblock_lock();
+ iMap->freeblock_lock();
clif->damage(bl,bl,tick,status_get_amotion(bl),1,1,0,0,0);
status_damage(NULL, bl, 1, status->max_sp * 3 / 100, 0, 0); //cancel dmg only if cancelable
if( sc->data[type] ) {
sc_timer_next(10000 + tick, status_change_timer, bl->id, data );
}
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
break;
case SC_OBLIVIONCURSE:
- if( --(sce->val4) >= 0 )
+ if( --(sce->val4) > 0 )
{
clif->emotion(bl,E_WHAT);
sc_timer_next(3000 + tick, status_change_timer, bl->id, data );
@@ -10254,7 +10386,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
break;
case SC_WEAPONBLOCKING:
- if( --(sce->val4) >= 0 )
+ if( --(sce->val4) > 0 )
{
if( !status_charge(bl,0,3) )
break;
@@ -10270,7 +10402,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
return 0;
case SC_RENOVATIO:
- if( --(sce->val4) >= 0 )
+ if( --(sce->val4) > 0 )
{
int heal = status->max_hp * 3 / 100;
if( sc && sc->data[SC_AKAITSUKI] && heal )
@@ -10282,25 +10414,25 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
break;
case SC_BURNING:
- if( --(sce->val4) >= 0 )
+ if( --(sce->val4) > 0 )
{
- struct block_list *src = map_id2bl(sce->val3);
+ struct block_list *src = iMap->id2bl(sce->val3);
int damage = 1000 + 3 * status_get_max_hp(bl) / 100; // Deals fixed (1000 + 3%*MaxHP)
- map_freeblock_lock();
+ iMap->freeblock_lock();
clif->damage(bl,bl,tick,0,0,damage,1,9,0); //damage is like endure effect with no walk delay
status_damage(src, bl, damage, 0, 0, 1);
if( sc->data[type]){ // Target still lives. [LimitLine]
- sc_timer_next(2000 + tick, status_change_timer, bl->id, data);
+ sc_timer_next(3000 + tick, status_change_timer, bl->id, data);
}
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
break;
case SC_FEAR:
- if( --(sce->val4) >= 0 )
+ if( --(sce->val4) > 0 )
{
if( sce->val2 > 0 )
sce->val2--;
@@ -10309,12 +10441,12 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
}
break;
- case SC_SPHERE_1:
- case SC_SPHERE_2:
- case SC_SPHERE_3:
- case SC_SPHERE_4:
- case SC_SPHERE_5:
- if( --(sce->val4) >= 0 )
+ case SC_SUMMON1:
+ case SC_SUMMON2:
+ case SC_SUMMON3:
+ case SC_SUMMON4:
+ case SC_SUMMON5:
+ if( --(sce->val4) > 0 )
{
if( !status_charge(bl, 0, 1) )
break;
@@ -10326,7 +10458,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
case SC_READING_SB:
if( !status_charge(bl, 0, sce->val2) ){
int i;
- for(i = SC_SPELLBOOK1; i <= SC_MAXSPELLBOOK; i++) // Also remove stored spell as well.
+ for(i = SC_SPELLBOOK1; i <= SC_SPELLBOOK7; i++) // Also remove stored spell as well.
status_change_end(bl, (sc_type)i, INVALID_TIMER);
break;
}
@@ -10334,7 +10466,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
return 0;
case SC_ELECTRICSHOCKER:
- if( --(sce->val4) >= 0 )
+ if( --(sce->val4) > 0 )
{
status_charge(bl, 0, status->max_sp / 100 * sce->val1 );
sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
@@ -10357,7 +10489,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
return 0;
case SC__SHADOWFORM:
- if( --(sce->val4) >= 0 )
+ if( --(sce->val4) > 0 )
{
if( !status_charge(bl, 0, sce->val1 - (sce->val1 - 1)) )
break;
@@ -10367,7 +10499,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
break;
case SC__INVISIBILITY:
- if( --(sce->val4) >= 0 )
+ if( --(sce->val4) > 0 )
{
if( !status_charge(bl, 0, (status->sp * 6 - sce->val1) / 100) )// 6% - skill_lv.
break;
@@ -10377,7 +10509,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
break;
case SC_STRIKING:
- if( --(sce->val4) >= 0 )
+ if( --(sce->val4) > 0 )
{
if( !status_charge(bl,0, sce->val1 ) )
break;
@@ -10386,32 +10518,32 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
}
break;
case SC_VACUUM_EXTREME:
- if( --(sce->val4) >= 0 ){
+ if( --(sce->val4) > 0 ){
sc_timer_next(100 + tick, status_change_timer, bl->id, data);
return 0;
}
break;
- case SC_BLOODSUCKER:
- if( --(sce->val4) >= 0 ) {
- struct block_list *src = map_id2bl(sce->val2);
+ case SC_BLOOD_SUCKER:
+ if( --(sce->val4) > 0 ) {
+ struct block_list *src = iMap->id2bl(sce->val2);
int damage;
if( !src || (src && (status_isdead(src) || src->m != bl->m || distance_bl(src, bl) >= 12)) )
break;
- map_freeblock_lock();
- damage = 200 + 100 * sce->val1 + status_get_int(src);
+ iMap->freeblock_lock();
+ damage = sce->val3;
status_damage(src, bl, damage, 0, clif->damage(bl,bl,tick,status->amotion,status->dmotion+200,damage,1,0,0), 1);
unit_skillcastcancel(bl,1);
if ( sc->data[type] ) {
sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
}
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
status_heal(src, damage*(5 + 5 * sce->val1)/100, 0, 0); // 5 + 5% per level
return 0;
}
break;
- case SC_VOICEOFSIREN:
- if( --(sce->val4) >= 0 )
+ case SC_SIREN:
+ if( --(sce->val4) > 0 )
{
clif->emotion(bl,E_LV);
sc_timer_next(2000 + tick, status_change_timer, bl->id, data);
@@ -10419,8 +10551,8 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
}
break;
- case SC_DEEPSLEEP:
- if( --(sce->val4) >= 0 )
+ case SC_DEEP_SLEEP:
+ if( --(sce->val4) > 0 )
{ // Recovers 1% HP/SP every 2 seconds.
status_heal(bl, status->max_hp / 100, status->max_sp / 100, 2);
sc_timer_next(2000 + tick, status_change_timer, bl->id, data);
@@ -10429,7 +10561,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
break;
case SC_SIRCLEOFNATURE:
- if( --(sce->val4) >= 0 )
+ if( --(sce->val4) > 0 )
{
if( !status_charge(bl,0,sce->val2) )
break;
@@ -10439,8 +10571,8 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
}
break;
- case SC_SONGOFMANA:
- if( --(sce->val4) >= 0 )
+ case SC_SONG_OF_MANA:
+ if( --(sce->val4) > 0 )
{
status_heal(bl,0,sce->val3,3);
sc_timer_next(3000 + tick, status_change_timer, bl->id, data);
@@ -10449,9 +10581,9 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
break;
- case SC_SATURDAYNIGHTFEVER:
+ case SC_SATURDAY_NIGHT_FEVER:
// 1% HP/SP drain every val4 seconds [Jobbie]
- if( --(sce->val3) >= 0 )
+ if( --(sce->val3) > 0 )
{
int hp = status->hp / 100;
int sp = status->sp / 100;
@@ -10463,7 +10595,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
break;
case SC_CRYSTALIZE:
- if( --(sce->val4) >= 0 )
+ if( --(sce->val4) > 0 )
{ // Drains 2% of HP and 1% of SP every seconds.
if( bl->type != BL_MOB) // doesn't work on mobs
status_charge(bl, status->max_hp * 2 / 100, status->max_sp / 100);
@@ -10481,14 +10613,14 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
case SC_BANDING:
if( status_charge(bl, 0, 7 - sce->val1) )
{
- if( sd ) pc_banding(sd, sce->val1);
+ if( sd ) pc->banding(sd, sce->val1);
sc_timer_next(5000 + tick, status_change_timer, bl->id, data);
return 0;
}
break;
- case SC_REFLECTDAMAGE:
- if( --(sce->val4) >= 0 ) {
+ case SC_LG_REFLECTDAMAGE:
+ if( --(sce->val4) > 0 ) {
if( !status_charge(bl,0,sce->val3) )
break;
sc_timer_next(10000 + tick, status_change_timer, bl->id, data);
@@ -10506,12 +10638,12 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
{
int damage = status->max_hp / 100; // Suggestion 1% each second
if( damage >= status->hp ) damage = status->hp - 1; // Do not kill, just keep you with 1 hp minimum
- map_freeblock_lock();
+ iMap->freeblock_lock();
status_fix_damage(NULL,bl,damage,clif->damage(bl,bl,tick,0,0,damage,0,0,0));
if( sc->data[type] ) {
sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
}
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
}
break;
@@ -10526,7 +10658,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
}
else
{
- struct block_list *src = map_id2bl(sce->val2);
+ struct block_list *src = iMap->id2bl(sce->val2);
struct status_change *ssc;
if( !src || (ssc = status_get_sc(src)) == NULL || !ssc->data[SC_MAGNETICFIELD] )
break; // Source no more under Magnetic Field
@@ -10536,7 +10668,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
break;
case SC_INSPIRATION:
- if(--(sce->val4) >= 0)
+ if(--(sce->val4) > 0)
{
int hp = status->max_hp * (7-sce->val1) / 100;
int sp = status->max_sp * (9-sce->val1) / 100;
@@ -10613,12 +10745,36 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
}
break;
case SC_ANGRIFFS_MODUS:
- if(--(sce->val4) >= 0) { //drain hp/sp
+ if(--(sce->val4) > 0) { //drain hp/sp
if( !status_charge(bl,100,20) ) break;
sc_timer_next(1000+tick,status_change_timer,bl->id, data);
return 0;
}
break;
+ case SC_FULL_THROTTLE:
+ if( --(sce->val4) > 0 )
+ {
+ status_percent_damage(bl, bl, sce->val2, 0, false);
+ sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
+ return 0;
+ }
+ break;
+ case SC_KINGS_GRACE:
+ if( --(sce->val4) > 0 )
+ {
+ status_percent_heal(bl, sce->val2, 0);
+ sc_timer_next(1000 + tick, status_change_timer, bl->id, data);
+ return 0;
+ }
+ break;
+ case SC_FRIGG_SONG:
+ if( --(sce->val4) > 0 )
+ {
+ status_heal(bl, sce->val3, 0, 0);
+ sc_timer_next(10000 + tick, status_change_timer, bl->id, data);
+ return 0;
+ }
+ break;
}
// default for all non-handled control paths is to end the status
@@ -10648,7 +10804,7 @@ int status_change_timer_sub(struct block_list* bl, va_list ap)
if( tsc && tsc->data[SC__SHADOWFORM] && (sce && sce->val4 >0 && sce->val4%2000 == 0) && // for every 2 seconds do the checking
rnd()%100 < 100-tsc->data[SC__SHADOWFORM]->val1*10 ) // [100 - (Skill Level x 10)] %
status_change_end(bl, SC__SHADOWFORM, INVALID_TIMER);
- case SC_CONCENTRATE:
+ case SC_CONCENTRATION:
status_change_end(bl, SC_HIDING, INVALID_TIMER);
status_change_end(bl, SC_CLOAKING, INVALID_TIMER);
status_change_end(bl, SC_CLOAKINGEXCEED, INVALID_TIMER);
@@ -10671,7 +10827,7 @@ int status_change_timer_sub(struct block_list* bl, va_list ap)
rnd()%100 < 100-tsc->data[SC__SHADOWFORM]->val1*10 ) // [100 - (Skill Level x 10)] %
status_change_end(bl, SC__SHADOWFORM, INVALID_TIMER);
break;
- case SC_SIGHTBLASTER:
+ case SC_WZ_SIGHTBLASTER:
if (battle->check_target( src, bl, BCT_ENEMY ) > 0 &&
status_check_skilluse(src, bl, WZ_SIGHTBLASTER, 2))
{
@@ -10681,11 +10837,11 @@ int status_change_timer_sub(struct block_list* bl, va_list ap)
}
}
break;
- case SC_CLOSECONFINE:
+ case SC_RG_CCONFINE_M:
//Lock char has released the hold on everyone...
- if (tsc && tsc->data[SC_CLOSECONFINE2] && tsc->data[SC_CLOSECONFINE2]->val2 == src->id) {
- tsc->data[SC_CLOSECONFINE2]->val2 = 0;
- status_change_end(bl, SC_CLOSECONFINE2, INVALID_TIMER);
+ if (tsc && tsc->data[SC_RG_CCONFINE_S] && tsc->data[SC_RG_CCONFINE_S]->val2 == src->id) {
+ tsc->data[SC_RG_CCONFINE_S]->val2 = 0;
+ status_change_end(bl, SC_RG_CCONFINE_S, INVALID_TIMER);
}
break;
case SC_CURSEDCIRCLE_TARGET:
@@ -10698,6 +10854,130 @@ int status_change_timer_sub(struct block_list* bl, va_list ap)
return 0;
}
+#ifdef RENEWAL
+int status_get_total_def(struct block_list *src){ return status_get_status_data(src)->def2 + (short)status_get_def(src); }
+int status_get_total_mdef(struct block_list *src){ return status_get_status_data(src)->mdef2 + (short)status_get_mdef(src); }
+int status_get_weapon_atk(struct block_list *bl, struct weapon_atk *watk, int flag){
+ int min = 0, max = 0, dstr;
+ float strdex_bonus, variance;
+ struct status_change *sc = status_get_sc(bl);
+
+ if ( bl->type == BL_PC && watk->atk ){
+ if ( flag&16 )
+ dstr = status_get_dex(bl);
+ else
+ dstr = status_get_str(bl);
+
+ variance = 5.0f * watk->atk * watk->wlv / 100.0f;
+ strdex_bonus = watk->atk * dstr / 200.0f;
+
+ min = (watk->atk - (int)(variance + strdex_bonus)) + watk->atk2;
+ max = (watk->atk + (int)(variance + strdex_bonus)) + watk->atk2;
+ }else if( watk->atk ){
+ min = watk->atk * 80 / 100;
+ max = watk->atk * 120 / 100;
+ }
+
+ if( !(flag&1) ){
+ if( max > min )
+ max = min + rnd()%(max - min);
+ else
+ max = min;
+ }
+
+ if( bl->type == BL_PC && ((TBL_PC*)bl)->right_weapon.overrefine > 0)
+ max += rnd()%((TBL_PC*)bl)->right_weapon.overrefine + 1;
+
+ max = status_calc_watk(bl, sc, max, false);
+
+ return max;
+}
+#endif
+
+#define GETRANDMATK(){\
+ if( status->matk_max > status->matk_min )\
+ return status->matk_min + rnd()%(status->matk_max - status->matk_min);\
+ else\
+ return status->matk_min;\
+}
+
+/*==========================================
+ * flag [malufett]
+ * 0 - update matk values
+ * 1 - get matk w/o SC bonuses
+ * 2 - get modified matk
+ * 3 - get matk w/o eatk & SC bonuses
+ *------------------------------------------*/
+int status_get_matk(struct block_list *bl, int flag){
+ struct status_data *status;
+ struct status_change *sc;
+ struct map_session_data *sd;
+
+ if( bl == NULL )
+ return 1;
+
+ status = status_get_status_data(bl);
+ sc = status_get_sc(bl);
+ sd = BL_CAST(BL_PC, bl);
+
+ if( flag == 2 ) // just get matk
+ GETRANDMATK();
+
+#ifndef RENEWAL
+ status->matk_min = status_base_matk_min(status) + (sd?sd->bonus.ematk:0);
+ status->matk_max = status_base_matk_max(status) + (sd?sd->bonus.ematk:0);
+#else
+ /**
+ * RE MATK Formula (from irowiki:http://irowiki.org/wiki/MATK)
+ * MATK = (sMATK + wMATK + eMATK) * Multiplicative Modifiers
+ **/
+ status->matk_min = status_base_matk(status, status_get_lv(bl));
+
+ // Any +MATK you get from skills and cards, including cards in weapon, is added here.
+ if( sd && sd->bonus.ematk > 0 && flag != 3 )
+ status->matk_min += sd->bonus.ematk;
+ if( flag != 3 )
+ status->matk_min = status_calc_ematk(bl, sc, status->matk_min);
+
+ status->matk_max = status->matk_min;
+
+ //This is the only portion in MATK that varies depending on the weapon level and refinement rate.
+ if( bl->type&BL_PC && (status->rhw.matk + status->lhw.matk) > 0 ){
+ int wMatk = status->rhw.matk + status->lhw.matk; // Left and right matk stacks
+ int variance = wMatk * status->rhw.wlv / 10; // Only use right hand weapon level
+ status->matk_min += wMatk - variance;
+ status->matk_max += wMatk + variance;
+ }else if( bl->type&BL_MOB ){
+ status->matk_min = status->matk_max = status_get_int(bl) + status_get_lv(bl);
+ status->matk_min += 70 * ((TBL_MOB*)bl)->status.rhw.atk2 / 100;
+ status->matk_max += 130 * ((TBL_MOB*)bl)->status.rhw.atk2 / 100;
+ }
+#endif
+ if (bl->type&BL_PC && sd->matk_rate != 100) {
+ status->matk_max = status->matk_max * sd->matk_rate/100;
+ status->matk_min = status->matk_min * sd->matk_rate/100;
+ }
+
+ if ((bl->type&BL_HOM && battle_config.hom_setting&0x20) //Hom Min Matk is always the same as Max Matk
+ || (sc && sc->data[SC_RECOGNIZEDSPELL]))
+ status->matk_min = status->matk_max;
+
+#ifdef RENEWAL
+ if( sd && sd->right_weapon.overrefine > 0){
+ status->matk_min++;
+ status->matk_max += sd->right_weapon.overrefine - 1;
+ }
+#endif
+
+ if( flag ) // get unmodified from sc matk
+ GETRANDMATK();
+
+ status->matk_min = status_calc_matk(bl, sc, status->matk_min, true);
+ status->matk_max = status_calc_matk(bl, sc, status->matk_max, true);
+
+ return 0;
+}
+
/*==========================================
* Clears buffs/debuffs of a character.
* type&1 -> buffs, type&2 -> debuffs
@@ -10717,70 +10997,18 @@ int status_change_clear_buffs (struct block_list* bl, int type)
for( i = SC_COMMON_MAX+1; i < SC_MAX; i++ )
{
- if(!sc->data[i])
+ if( !sc->data[i] || !status_get_sc_type(i) )
continue;
- switch (i) {
- //Stuff that cannot be removed
- case SC_WEIGHT50:
- case SC_WEIGHT90:
- case SC_COMBO:
- case SC_SMA:
- case SC_DANCING:
- case SC_LEADERSHIP:
- case SC_GLORYWOUNDS:
- case SC_SOULCOLD:
- case SC_HAWKEYES:
- case SC_GUILDAURA:
- case SC_SAFETYWALL:
- case SC_PNEUMA:
- case SC_NOCHAT:
- case SC_JAILED:
- case SC_ANKLE:
- case SC_BLADESTOP:
- case SC_CP_WEAPON:
- case SC_CP_SHIELD:
- case SC_CP_ARMOR:
- case SC_CP_HELM:
- case SC_STRFOOD:
- case SC_AGIFOOD:
- case SC_VITFOOD:
- case SC_INTFOOD:
- case SC_DEXFOOD:
- case SC_LUKFOOD:
- case SC_HITFOOD:
- case SC_FLEEFOOD:
- case SC_BATKFOOD:
- case SC_WATKFOOD:
- case SC_MATKFOOD:
- case SC_FOOD_STR_CASH:
- case SC_FOOD_AGI_CASH:
- case SC_FOOD_VIT_CASH:
- case SC_FOOD_DEX_CASH:
- case SC_FOOD_INT_CASH:
- case SC_FOOD_LUK_CASH:
- case SC_EXPBOOST:
- case SC_JEXPBOOST:
- case SC_ITEMBOOST:
- case SC_ELECTRICSHOCKER:
- case SC__MANHOLE:
- case SC_GIANTGROWTH:
- case SC_MILLENNIUMSHIELD:
- case SC_REFRESH:
- case SC_STONEHARDSKIN:
- case SC_VITALITYACTIVATION:
- case SC_FIGHTINGSPIRIT:
- case SC_ABUNDANCE:
- case SC_CURSEDCIRCLE_ATKER:
- case SC_CURSEDCIRCLE_TARGET:
- case SC_PUSH_CART:
- case SC_ALL_RIDING:
- continue;
+ if( type&1 && !(status_get_sc_type(i)&SC_BUFF) )
+ continue;
- //Debuffs that can be removed.
- case SC_DEEPSLEEP:
- case SC_BURNING:
- case SC_FREEZING:
+ if( type&2 && !(status_get_sc_type(i)&SC_DEBUFF) )
+ continue;
+
+ switch (i) {
+ case SC_DEEP_SLEEP:
+ case SC_FROSTMISTY:
case SC_CRYSTALIZE:
case SC_TOXIN:
case SC_PARALYSE:
@@ -10795,40 +11023,13 @@ int status_change_clear_buffs (struct block_list* bl, int type)
if(!(type&4))
continue;
break;
- case SC_HALLUCINATION:
- case SC_QUAGMIRE:
- case SC_SIGNUMCRUCIS:
- case SC_DECREASEAGI:
- case SC_SLOWDOWN:
- case SC_MINDBREAKER:
- case SC_WINKCHARM:
- case SC_STOP:
- case SC_ORCISH:
- case SC_STRIPWEAPON:
- case SC_STRIPSHIELD:
- case SC_STRIPARMOR:
- case SC_STRIPHELM:
- case SC_BITE:
- case SC_ADORAMUS:
- case SC_VACUUM_EXTREME:
- case SC_FEAR:
- case SC_MAGNETICFIELD:
- case SC_NETHERWORLD:
- if (!(type&2))
- continue;
- break;
- //The rest are buffs that can be removed.
case SC__BLOODYLUST:
case SC_BERSERK:
- case SC_SATURDAYNIGHTFEVER:
- if (!(type&1))
+ case SC_SATURDAY_NIGHT_FEVER:
+ if(type&4)
continue;
sc->data[i]->val2 = 0;
break;
- default:
- if (!(type&1))
- continue;
- break;
}
status_change_end(bl, (sc_type)i, INVALID_TIMER);
}
@@ -10845,7 +11046,7 @@ int status_change_spread( struct block_list *src, struct block_list *bl ) {
if( !sc || !sc->count )
return 0;
- tick = gettick();
+ tick = iTimer->gettick();
for( i = SC_COMMON_MIN; i < SC_MAX; i++ ) {
if( !sc->data[i] || i == SC_COMMON_MAX )
@@ -10859,26 +11060,26 @@ int status_change_spread( struct block_list *src, struct block_list *bl ) {
case SC_CONFUSION:
case SC_BLIND:
case SC_NOCHAT:
- case SC_HALLUCINATION:
- case SC_SIGNUMCRUCIS:
- case SC_DECREASEAGI:
+ case SC_ILLUSION:
+ case SC_CRUCIS:
+ case SC_DEC_AGI:
case SC_SLOWDOWN:
case SC_MINDBREAKER:
- case SC_WINKCHARM:
+ case SC_DC_WINKCHARM:
case SC_STOP:
case SC_ORCISH:
- //case SC_STRIPWEAPON://Omg I got infected and had the urge to strip myself physically.
- //case SC_STRIPSHIELD://No this is stupid and shouldnt be spreadable at all.
- //case SC_STRIPARMOR:// Disabled until I can confirm if it does or not. [Rytech]
- //case SC_STRIPHELM:
- //case SC__STRIPACCESSORY:
- case SC_BITE:
- case SC_FREEZING:
+ //case SC_NOEQUIPWEAPON://Omg I got infected and had the urge to strip myself physically.
+ //case SC_NOEQUIPSHIELD://No this is stupid and shouldnt be spreadable at all.
+ //case SC_NOEQUIPARMOR:// Disabled until I can confirm if it does or not. [Rytech]
+ //case SC_NOEQUIPHELM:
+ //case SC__STRIPACCESSARY:
+ case SC_WUGBITE:
+ case SC_FROSTMISTY:
case SC_VENOMBLEED:
case SC_DEATHHURT:
case SC_PARALYSE:
if( sc->data[i]->timer != INVALID_TIMER ) {
- timer = get_timer(sc->data[i]->timer);
+ timer = iTimer->get_timer(sc->data[i]->timer);
if (timer == NULL || timer->func != status_change_timer || DIFF_TICK(timer->tick,tick) < 0)
continue;
data.tick = DIFF_TICK(timer->tick,tick);
@@ -10905,7 +11106,7 @@ int status_change_spread( struct block_list *src, struct block_list *bl ) {
data.tick = sc->data[i]->val4 * 4000;
break;
case SC_TOXIN:
- case SC_BLEEDING:
+ case SC_BLOODING:
data.tick = sc->data[i]->val4 * 10000;
break;
default:
@@ -10960,9 +11161,9 @@ static int status_natural_heal(struct block_list* bl, va_list args)
if (sd) {
if (sd->hp_loss.value || sd->sp_loss.value)
- pc_bleeding(sd, natural_heal_diff_tick);
+ pc->bleeding(sd, natural_heal_diff_tick);
if (sd->hp_regen.value || sd->sp_regen.value)
- pc_regen(sd, natural_heal_diff_tick);
+ pc->regen(sd, natural_heal_diff_tick);
}
if(flag&(RGN_SHP|RGN_SSP) && regen->ssregen &&
@@ -11097,7 +11298,7 @@ static int status_natural_heal(struct block_list* bl, va_list args)
if (sd && sd->state.doridori) {
val*=2;
sd->state.doridori = 0;
- if ((rate = pc_checkskill(sd,TK_SPTIME)))
+ if ((rate = pc->checkskill(sd,TK_SPTIME)))
sc_start(bl,status_skill2sc(TK_SPTIME),
100,rate,skill->get_time(TK_SPTIME, rate));
if (
@@ -11105,8 +11306,8 @@ static int status_natural_heal(struct block_list* bl, va_list args)
rnd()%10000 < battle_config.sg_angel_skill_ratio
) { //Angel of the Sun/Moon/Star
clif->feel_hate_reset(sd);
- pc_resethate(sd);
- pc_resetfeel(sd);
+ pc->resethate(sd);
+ pc->resetfeel(sd);
}
}
sregen->tick.sp -= battle_config.natural_heal_skill_interval;
@@ -11121,7 +11322,7 @@ static int status_natural_heal(struct block_list* bl, va_list args)
static int status_natural_heal_timer(int tid, unsigned int tick, int id, intptr_t data)
{
natural_heal_diff_tick = DIFF_TICK(tick,natural_heal_prev_tick);
- map_foreachregen(status_natural_heal);
+ iMap->map_foreachregen(status_natural_heal);
natural_heal_prev_tick = tick;
return 0;
}
@@ -11140,6 +11341,13 @@ int status_get_refine_chance(enum refine_type wlv, int refine) {
return refine_info[wlv].chance[refine];
}
+int status_get_sc_type(sc_type type) {
+
+ if( type <= SC_NONE || type >= SC_MAX )
+ return 0;
+
+ return sc_conf[type];
+}
/*------------------------------------------
* DB reading.
@@ -11160,7 +11368,7 @@ static bool status_readdb_job1(char* fields[], int columns, int current)
ShowWarning("status_readdb_job1: Invalid job class %d specified.\n", class_);
return false;
}
- idx = pc_class2idx(class_);
+ idx = pc->class2idx(class_);
max_weight_base[idx] = atoi(fields[1]);
hp_coefficient[idx] = atoi(fields[2]);
@@ -11188,7 +11396,7 @@ static bool status_readdb_job2(char* fields[], int columns, int current)
ShowWarning("status_readdb_job2: Invalid job class %d specified.\n", class_);
return false;
}
- idx = pc_class2idx(class_);
+ idx = pc->class2idx(class_);
for(i = 1; i < columns; i++)
{
@@ -11242,6 +11450,19 @@ static bool status_readdb_refine(char* fields[], int columns, int current)
return true;
}
+static bool status_readdb_scconfig(char* fields[], int columns, int current) {
+ int val = 0;
+ char* type = fields[0];
+
+ if( !script->get_constant(type, &val) ){
+ ShowWarning("status_readdb_sc_conf: Invalid status type %s specified.\n", type);
+ return false;
+ }
+
+ sc_conf[val] = (int)strtol(fields[1], NULL, 0);
+
+ return true;
+}
/*
* Read status db
* job1.txt
@@ -11286,13 +11507,14 @@ int status_readdb(void)
#ifdef RENEWAL_ASPD
- sv->readdb(db_path, "re/job_db1.txt", ',', 6+MAX_WEAPON_TYPE, 6+MAX_WEAPON_TYPE, -1, &status_readdb_job1);
+ sv->readdb(iMap->db_path, "re/job_db1.txt", ',', 6+MAX_WEAPON_TYPE, 6+MAX_WEAPON_TYPE, -1, &status_readdb_job1);
#else
- sv->readdb(db_path, "pre-re/job_db1.txt", ',', 5+MAX_WEAPON_TYPE, 5+MAX_WEAPON_TYPE, -1, &status_readdb_job1);
+ sv->readdb(iMap->db_path, "pre-re/job_db1.txt", ',', 5+MAX_WEAPON_TYPE, 5+MAX_WEAPON_TYPE, -1, &status_readdb_job1);
#endif
- sv->readdb(db_path, "job_db2.txt", ',', 1, 1+MAX_LEVEL, -1, &status_readdb_job2);
- sv->readdb(db_path, "size_fix.txt", ',', MAX_WEAPON_TYPE, MAX_WEAPON_TYPE, ARRAYLENGTH(atkmods), &status_readdb_sizefix);
- sv->readdb(db_path, DBPATH"refine_db.txt", ',', 4+MAX_REFINE, 4+MAX_REFINE, ARRAYLENGTH(refine_info), &status_readdb_refine);
+ sv->readdb(iMap->db_path, "job_db2.txt", ',', 1, 1+MAX_LEVEL, -1, &status_readdb_job2);
+ sv->readdb(iMap->db_path, "size_fix.txt", ',', MAX_WEAPON_TYPE, MAX_WEAPON_TYPE, ARRAYLENGTH(atkmods), &status_readdb_sizefix);
+ sv->readdb(iMap->db_path, DBPATH"refine_db.txt", ',', 4+MAX_REFINE, 4+MAX_REFINE, ARRAYLENGTH(refine_info), &status_readdb_refine);
+ sv->readdb(iMap->db_path, "sc_config.txt", ',', 2, 2, SC_MAX, &status_readdb_scconfig);
return 0;
}
@@ -11302,16 +11524,16 @@ int status_readdb(void)
*------------------------------------------*/
int do_init_status(void)
{
- add_timer_func_list(status_change_timer,"status_change_timer");
- add_timer_func_list(kaahi_heal_timer,"kaahi_heal_timer");
- add_timer_func_list(status_natural_heal_timer,"status_natural_heal_timer");
+ iTimer->add_timer_func_list(status_change_timer,"status_change_timer");
+ iTimer->add_timer_func_list(kaahi_heal_timer,"kaahi_heal_timer");
+ iTimer->add_timer_func_list(status_natural_heal_timer,"status_natural_heal_timer");
initChangeTables();
initDummyData();
status_readdb();
status_calc_sigma();
- natural_heal_prev_tick = gettick();
+ natural_heal_prev_tick = iTimer->gettick();
sc_data_ers = ers_new(sizeof(struct status_change_entry),"status.c::sc_data_ers",ERS_OPT_NONE);
- add_timer_interval(natural_heal_prev_tick + NATURAL_HEAL_INTERVAL, status_natural_heal_timer, 0, 0, NATURAL_HEAL_INTERVAL);
+ iTimer->add_timer_interval(natural_heal_prev_tick + NATURAL_HEAL_INTERVAL, status_natural_heal_timer, 0, 0, NATURAL_HEAL_INTERVAL);
return 0;
}
void do_final_status(void)
diff --git a/src/map/status.h b/src/map/status.h
index 4a7af884e..fbce95f17 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -31,6 +31,16 @@ enum refine_type {
REFINE_TYPE_MAX = 5
};
+typedef enum sc_conf_type {
+ SC_NO_REM_DEATH = 0x1,
+ SC_NO_SAVE = 0x2,
+ SC_NO_DISPELL = 0x4,
+ SC_NO_CLEARANCE = 0x8,
+ SC_BUFF = 0x10,
+ SC_DEBUFF = 0x20,
+ SC_MADO_NO_RESET = 0x40
+} sc_conf_type;
+
int status_get_refine_chance(enum refine_type wlv, int refine);
// Status changes listing. These code are for use by the server.
@@ -48,25 +58,26 @@ typedef enum sc_type {
SC_SILENCE,
SC_CONFUSION,
SC_BLIND,
- SC_BLEEDING,
- SC_DPOISON, //10
- SC_COMMON_MAX = 10, // end
+ SC_BLOODING,
+ SC_DPOISON,
+ SC_BURNING, //11
+ SC_COMMON_MAX = 11, // end
//Next up, we continue on 20, to leave enough room for additional "common" ailments in the future.
SC_PROVOKE = 20,
SC_ENDURE,
SC_TWOHANDQUICKEN,
- SC_CONCENTRATE,
+ SC_CONCENTRATION,
SC_HIDING,
SC_CLOAKING,
- SC_ENCPOISON,
+ SC_ENCHANTPOISON,
SC_POISONREACT,
SC_QUAGMIRE,
SC_ANGELUS,
SC_BLESSING, //30
- SC_SIGNUMCRUCIS,
- SC_INCREASEAGI,
- SC_DECREASEAGI,
+ SC_CRUCIS,
+ SC_INC_AGI,
+ SC_DEC_AGI,
SC_SLOWPOISON,
SC_IMPOSITIO ,
SC_SUFFRAGIUM,
@@ -75,40 +86,40 @@ typedef enum sc_type {
SC_KYRIE,
SC_MAGNIFICAT, //40
SC_GLORIA,
- SC_AETERNA,
+ SC_LEXAETERNA,
SC_ADRENALINE,
- SC_WEAPONPERFECTION,
+ SC_WEAPONPERFECT,
SC_OVERTHRUST,
SC_MAXIMIZEPOWER,
SC_TRICKDEAD,
- SC_LOUD,
+ SC_SHOUT,
SC_ENERGYCOAT,
SC_BROKENARMOR, //50 - NOTE: These two aren't used anywhere, and they have an icon...
SC_BROKENWEAPON,
- SC_HALLUCINATION,
- SC_WEIGHT50,
- SC_WEIGHT90,
- SC_ASPDPOTION0,
- SC_ASPDPOTION1,
- SC_ASPDPOTION2,
- SC_ASPDPOTION3,
- SC_SPEEDUP0,
- SC_SPEEDUP1, //60
- SC_ATKPOTION,
- SC_MATKPOTION,
+ SC_ILLUSION,
+ SC_WEIGHTOVER50,
+ SC_WEIGHTOVER90,
+ SC_ATTHASTE_POTION1,
+ SC_ATTHASTE_POTION2,
+ SC_ATTHASTE_POTION3,
+ SC_ATTHASTE_INFINITY,
+ SC_MOVHASTE_HORSE,
+ SC_MOVHASTE_INFINITY, //60
+ SC_PLUSATTACKPOWER,
+ SC_PLUSMAGICPOWER,
SC_WEDDING,
SC_SLOWDOWN,
- SC_ANKLE,
+ SC_ANKLESNARE,
SC_KEEPING,
SC_BARRIER,
- SC_STRIPWEAPON,
- SC_STRIPSHIELD,
- SC_STRIPARMOR, //70
- SC_STRIPHELM,
- SC_CP_WEAPON,
- SC_CP_SHIELD,
- SC_CP_ARMOR,
- SC_CP_HELM,
+ SC_NOEQUIPWEAPON,
+ SC_NOEQUIPSHIELD,
+ SC_NOEQUIPARMOR, //70
+ SC_NOEQUIPHELM,
+ SC_PROTECTWEAPON,
+ SC_PROTECTSHIELD,
+ SC_PROTECTARMOR,
+ SC_PROTECTHELM,
SC_AUTOGUARD,
SC_REFLECTSHIELD,
SC_SPLASHER,
@@ -126,24 +137,24 @@ typedef enum sc_type {
SC_RUWACH, //90
SC_EXTREMITYFIST,
SC_EXPLOSIONSPIRITS,
- SC_COMBO,
+ SC_COMBOATTACK,
SC_BLADESTOP_WAIT,
SC_BLADESTOP,
- SC_FIREWEAPON,
- SC_WATERWEAPON,
- SC_WINDWEAPON,
- SC_EARTHWEAPON,
+ SC_PROPERTYFIRE,
+ SC_PROPERTYWATER,
+ SC_PROPERTYWIND,
+ SC_PROPERTYGROUND,
SC_VOLCANO, //100,
SC_DELUGE,
SC_VIOLENTGALE,
SC_WATK_ELEMENT,
SC_ARMOR,
- SC_ARMOR_ELEMENT,
+ SC_ARMORPROPERTY,
SC_NOCHAT,
SC_BABY,
SC_AURABLADE,
SC_PARRYING,
- SC_CONCENTRATION, //110
+ SC_LKCONCENTRATION, //110
SC_TENSIONRELAX,
SC_BERSERK,
SC_FURY,
@@ -158,10 +169,10 @@ typedef enum sc_type {
SC_MELTDOWN,
SC_CARTBOOST,
SC_CHASEWALK,
- SC_REJECTSWORD,
+ SC_SWORDREJECT,
+ SC_MARIONETTE_MASTER,
SC_MARIONETTE,
- SC_MARIONETTE2,
- SC_CHANGEUNDEAD,
+ SC_PROPERTYUNDEAD,
SC_JOINTBEAT,
SC_MINDBREAKER, //130
SC_MEMORIZE,
@@ -171,39 +182,40 @@ typedef enum sc_type {
SC_SACRIFICE,
SC_STEELBODY,
SC_ORCISH,
- SC_READYSTORM,
- SC_READYDOWN,
- SC_READYTURN, //140
- SC_READYCOUNTER,
- SC_DODGE,
+ SC_STORMKICK_READY,
+ SC_DOWNKICK_READY,
+ SC_TURNKICK_READY, //140
+ SC_COUNTERKICK_READY,
+ SC_DODGE_READY,
SC_RUN,
- SC_SHADOWWEAPON,
+ SC_PROPERTYDARK,
SC_ADRENALINE2,
- SC_GHOSTWEAPON,
+ SC_PROPERTYTELEKINESIS,
SC_KAIZEL,
SC_KAAHI,
SC_KAUPE,
- SC_ONEHAND, //150
+ SC_ONEHANDQUICKEN, //150
SC_PRESERVE,
- SC_BATTLEORDERS,
- SC_REGENERATION,
- SC_DOUBLECAST,
+ SC_GDSKILL_BATTLEORDER,
+ SC_GDSKILL_REGENERATION,
+ SC_DOUBLECASTING,
SC_GRAVITATION,
- SC_MAXOVERTHRUST,
+ SC_OVERTHRUSTMAX,
SC_LONGING,
SC_HERMODE,
- SC_SHRINK,
- SC_SIGHTBLASTER, //160
- SC_WINKCHARM,
- SC_CLOSECONFINE,
- SC_CLOSECONFINE2,
+ SC_TAROTCARD,
+ SC_CR_SHRINK, //160
+ SC_WZ_SIGHTBLASTER,
+ SC_DC_WINKCHARM,
+ SC_RG_CCONFINE_M,
+ SC_RG_CCONFINE_S,
SC_DANCING,
- SC_ELEMENTALCHANGE,
+ SC_ARMOR_PROPERTY,
SC_RICHMANKIM,
SC_ETERNALCHAOS,
SC_DRUMBATTLE,
- SC_NIBELUNGEN,
- SC_ROKISWEIL, //170
+ SC_NIBELUNGEN, //170
+ SC_ROKISWEIL,
SC_INTOABYSS,
SC_SIEGFRIED,
SC_WHISTLE,
@@ -212,18 +224,18 @@ typedef enum sc_type {
SC_APPLEIDUN,
SC_MODECHANGE,
SC_HUMMING,
- SC_DONTFORGETME,
- SC_FORTUNE, //180
- SC_SERVICE4U,
+ SC_DONTFORGETME, //180
+ SC_FORTUNE,
+ SC_SERVICEFORYOU,
SC_STOP, //Prevents inflicted chars from walking. [Skotlex]
- SC_SPURT,
- SC_SPIRIT,
+ SC_STRUP,
+ SC_SOULLINK,
SC_COMA, //Not a real SC_, it makes a char's HP/SP hit 1.
- SC_INTRAVISION,
+ SC_CLAIRVOYANCE,
SC_INCALLSTATUS,
- SC_INCSTR,
- SC_INCAGI,
- SC_INCVIT, //190
+ SC_CHASEWALK2,
+ SC_INCAGI, //190
+ SC_INCVIT,
SC_INCINT,
SC_INCDEX,
SC_INCLUK,
@@ -232,18 +244,18 @@ typedef enum sc_type {
SC_INCFLEE,
SC_INCFLEERATE,
SC_INCMHPRATE,
- SC_INCMSPRATE,
- SC_INCATKRATE, //200
+ SC_INCMSPRATE, //200
+ SC_INCATKRATE,
SC_INCMATKRATE,
SC_INCDEFRATE,
- SC_STRFOOD,
- SC_AGIFOOD,
- SC_VITFOOD,
- SC_INTFOOD,
- SC_DEXFOOD,
- SC_LUKFOOD,
- SC_HITFOOD,
- SC_FLEEFOOD, //210
+ SC_FOOD_STR,
+ SC_FOOD_AGI,
+ SC_FOOD_VIT,
+ SC_FOOD_INT,
+ SC_FOOD_DEX,
+ SC_FOOD_LUK,
+ SC_FOOD_BASICHIT, //210
+ SC_FOOD_BASICAVOIDANCE,
SC_BATKFOOD,
SC_WATKFOOD,
SC_MATKFOOD,
@@ -252,8 +264,8 @@ typedef enum sc_type {
SC_WARM, //SG skills [Komurka]
SC_SUN_COMFORT,
SC_MOON_COMFORT,
- SC_STAR_COMFORT,
- SC_FUSION, //220
+ SC_STAR_COMFORT, //220
+ SC_FUSION,
SC_SKILLRATE_UP,
SC_SKE,
SC_KAITE,
@@ -261,82 +273,82 @@ typedef enum sc_type {
SC_SKA, // [marquis007]
SC_EARTHSCROLL,
SC_MIRACLE, //SG 'hidden' skill [Komurka]
- SC_MADNESSCANCEL,
- SC_ADJUSTMENT,
- SC_INCREASING, //230
- SC_GATLINGFEVER,
- SC_TATAMIGAESHI,
- SC_UTSUSEMI,
- SC_BUNSINJYUTSU,
- SC_KAENSIN,
- SC_SUITON,
- SC_NEN,
+ SC_GS_MADNESSCANCEL,
+ SC_GS_ADJUSTMENT, //230
+ SC_GS_ACCURACY,
+ SC_GS_GATLINGFEVER,
+ SC_NJ_TATAMIGAESHI,
+ SC_NJ_UTSUSEMI,
+ SC_NJ_BUNSINJYUTSU,
+ SC_NJ_KAENSIN,
+ SC_NJ_SUITON,
+ SC_NJ_NEN,
SC_KNOWLEDGE,
- SC_SMA,
- SC_FLING, //240
- SC_AVOID,
- SC_CHANGE,
- SC_BLOODLUST,
- SC_FLEET,
- SC_SPEED,
- SC_DEFENCE,
+ SC_SMA_READY, //240
+ SC_FLING,
+ SC_HLIF_AVOID,
+ SC_HLIF_CHANGE,
+ SC_HAMI_BLOODLUST,
+ SC_HLIF_FLEET,
+ SC_HLIF_SPEED,
+ SC_HAMI_DEFENCE,
SC_INCASPDRATE,
- SC_INCFLEE2 = 248,
- SC_JAILED,
- SC_ENCHANTARMS, //250
+ SC_PLUSAVOIDVALUE,
+ SC_JAILED, //250
+ SC_ENCHANTARMS,
SC_MAGICALATTACK,
- SC_ARMORCHANGE,
+ SC_STONESKIN,
SC_CRITICALWOUND,
SC_MAGICMIRROR,
SC_SLOWCAST,
SC_SUMMER,
- SC_EXPBOOST,
- SC_ITEMBOOST,
- SC_BOSSMAPINFO,
- SC_LIFEINSURANCE, //260
- SC_INCCRI,
+ SC_CASH_PLUSEXP,
+ SC_CASH_RECEIVEITEM,
+ SC_CASH_BOSS_ALARM, //260
+ SC_CASH_DEATHPENALTY,
+ SC_CRITICALPERCENT,
//SC_INCDEF,
- //SC_INCBASEATK = 263,
+ //SC_INCBASEATK = 264,
//SC_FASTCAST,
- SC_MDEF_RATE = 265,
+ SC_PROTECT_MDEF = 266,
//SC_HPREGEN,
- SC_INCHEALRATE = 267,
+ SC_HEALPLUS = 268,
SC_PNEUMA,
- SC_AUTOTRADE,
- SC_KSPROTECTED, //270
- SC_ARMOR_RESIST = 271,
- SC_SPCOST_RATE,
- SC_COMMONSC_RESIST,
- SC_SEVENWIND,
- SC_DEF_RATE,
+ SC_AUTOTRADE, //270
+ SC_KSPROTECTED,
+ SC_ARMOR_RESIST,
+ SC_ATKER_BLOOD,
+ SC_TARGET_BLOOD,
+ SC_TK_SEVENWIND,
+ SC_PROTECT_DEF,
//SC_SPREGEN,
- SC_WALKSPEED = 277,
+ SC_WALKSPEED = 278,
// Mercenary Only Bonus Effects
- SC_MERC_FLEEUP,
- SC_MERC_ATKUP,
- SC_MERC_HPUP, //280
- SC_MERC_SPUP,
- SC_MERC_HITUP,
- SC_MERC_QUICKEN,
+ SC_MER_FLEE,
+ SC_MER_ATK, //280
+ SC_MER_HP,
+ SC_MER_SP,
+ SC_MER_HIT,
+ SC_MER_QUICKEN,
SC_REBIRTH,
- //SC_SKILLCASTRATE, //285
+ //SC_SKILLCASTRATE, //286
//SC_DEFRATIOATK,
//SC_HPDRAIN,
//SC_SKILLATKBONUS,
- SC_ITEMSCRIPT = 289,
- SC_S_LIFEPOTION, //290
+ SC_ITEMSCRIPT = 290,
+ SC_S_LIFEPOTION,
SC_L_LIFEPOTION,
- SC_JEXPBOOST,
+ SC_CASH_PLUSONLYJOBEXP,
//SC_IGNOREDEF,
- SC_HELLPOWER = 294,
- SC_INVINCIBLE, //295
+ SC_HELLPOWER = 295,
+ SC_INVINCIBLE,
SC_INVINCIBLEOFF,
SC_MANU_ATK,
SC_MANU_DEF,
- SC_SPL_ATK,
- SC_SPL_DEF, //300
+ SC_SPL_ATK, //300
+ SC_SPL_DEF,
SC_MANU_MATK,
SC_SPL_MATK,
SC_FOOD_STR_CASH,
@@ -344,25 +356,24 @@ typedef enum sc_type {
SC_FOOD_VIT_CASH,
SC_FOOD_DEX_CASH,
SC_FOOD_INT_CASH,
- SC_FOOD_LUK_CASH,//308
+ SC_FOOD_LUK_CASH,
/**
* 3rd
**/
- SC_FEAR,//309
- SC_BURNING,//310
- SC_FREEZING,//311
+ SC_FEAR,
+ SC_FROSTMISTY,
/**
* Rune Knight
**/
- SC_ENCHANTBLADE,//312
- SC_DEATHBOUND,//313
+ SC_ENCHANTBLADE,
+ SC_DEATHBOUND,
SC_MILLENNIUMSHIELD,
- SC_CRUSHSTRIKE,//315
+ SC_CRUSHSTRIKE,
SC_REFRESH,
SC_REUSE_REFRESH,
SC_GIANTGROWTH,
SC_STONEHARDSKIN,
- SC_VITALITYACTIVATION,//320
+ SC_VITALITYACTIVATION,
SC_STORMBLAST,
SC_FIGHTINGSPIRIT,
SC_ABUNDANCE,
@@ -370,12 +381,12 @@ typedef enum sc_type {
* Arch Bishop
**/
SC_ADORAMUS,
- SC_EPICLESIS,//325
+ SC_EPICLESIS,
SC_ORATIO,
SC_LAUDAAGNUS,
SC_LAUDARAMUS,
SC_RENOVATIO,
- SC_EXPIATIO,//330
+ SC_EXPIATIO,
SC_DUPLELIGHT,
SC_SECRAMENT,
/**
@@ -383,38 +394,38 @@ typedef enum sc_type {
**/
SC_WHITEIMPRISON,
SC_MARSHOFABYSS,
- SC_RECOGNIZEDSPELL,//335
+ SC_RECOGNIZEDSPELL,
SC_STASIS,
- SC_SPHERE_1,
- SC_SPHERE_2,
- SC_SPHERE_3,
- SC_SPHERE_4,//340
- SC_SPHERE_5,
+ SC_SUMMON1,
+ SC_SUMMON2,
+ SC_SUMMON3,
+ SC_SUMMON4,
+ SC_SUMMON5,
SC_READING_SB,
- SC_FREEZINGSPELL,
+ SC_FREEZINGSP,
/**
* Ranger
**/
SC_FEARBREEZE,
- SC_ELECTRICSHOCKER,//345
+ SC_ELECTRICSHOCKER,
SC_WUGDASH,
- SC_BITE,
+ SC_WUGBITE,
SC_CAMOUFLAGE,
/**
* Mechanic
**/
SC_ACCELERATION,
- SC_HOVERING,//350
+ SC_HOVERING,
SC_SHAPESHIFT,
SC_INFRAREDSCAN,
SC_ANALYZE,
SC_MAGNETICFIELD,
- SC_NEUTRALBARRIER,//355
+ SC_NEUTRALBARRIER,
SC_NEUTRALBARRIER_MASTER,
SC_STEALTHFIELD,
SC_STEALTHFIELD_MASTER,
SC_OVERHEAT,
- SC_OVERHEAT_LIMITPOINT,//360
+ SC_OVERHEAT_LIMITPOINT,
/**
* Guillotine Cross
**/
@@ -422,30 +433,30 @@ typedef enum sc_type {
SC_POISONINGWEAPON,
SC_WEAPONBLOCKING,
SC_CLOAKINGEXCEED,
- SC_HALLUCINATIONWALK,//365
+ SC_HALLUCINATIONWALK,
SC_HALLUCINATIONWALK_POSTDELAY,
SC_ROLLINGCUTTER,
SC_TOXIN,
SC_PARALYSE,
- SC_VENOMBLEED,//370
+ SC_VENOMBLEED,
SC_MAGICMUSHROOM,
SC_DEATHHURT,
SC_PYREXIA,
SC_OBLIVIONCURSE,
- SC_LEECHESEND,//375
+ SC_LEECHESEND,
/**
* Royal Guard
**/
- SC_REFLECTDAMAGE,
+ SC_LG_REFLECTDAMAGE,
SC_FORCEOFVANGUARD,
SC_SHIELDSPELL_DEF,
SC_SHIELDSPELL_MDEF,
- SC_SHIELDSPELL_REF,//380
+ SC_SHIELDSPELL_REF,
SC_EXEEDBREAK,
SC_PRESTIGE,
SC_BANDING,
SC_BANDING_DEFENCE,
- SC_EARTHDRIVE,//385
+ SC_EARTHDRIVE,
SC_INSPIRATION,
/**
* Sorcerer
@@ -453,30 +464,30 @@ typedef enum sc_type {
SC_SPELLFIST,
SC_CRYSTALIZE,
SC_STRIKING,
- SC_WARMER,//390
+ SC_WARMER,
SC_VACUUM_EXTREME,
SC_PROPERTYWALK,
/**
* Minstrel / Wanderer
**/
- SC_SWINGDANCE,
- SC_SYMPHONYOFLOVER,
- SC_MOONLITSERENADE,//395
- SC_RUSHWINDMILL,
+ SC_SWING,
+ SC_SYMPHONY_LOVE,
+ SC_MOONLIT_SERENADE,
+ SC_RUSH_WINDMILL,
SC_ECHOSONG,
SC_HARMONIZE,
- SC_VOICEOFSIREN,
- SC_DEEPSLEEP,//400
+ SC_SIREN,
+ SC_DEEP_SLEEP,
SC_SIRCLEOFNATURE,
SC_GLOOMYDAY,
SC_GLOOMYDAY_SK,
- SC_SONGOFMANA,
- SC_DANCEWITHWUG,//405
- SC_SATURDAYNIGHTFEVER,
- SC_LERADSDEW,
+ SC_SONG_OF_MANA,
+ SC_DANCE_WITH_WUG,
+ SC_SATURDAY_NIGHT_FEVER,
+ SC_LERADS_DEW,
SC_MELODYOFSINK,
- SC_BEYONDOFWARCRY,
- SC_UNLIMITEDHUMMINGVOICE,//410
+ SC_BEYOND_OF_WARCRY,
+ SC_UNLIMITED_HUMMING_VOICE,
SC_SITDOWN_FORCE,
SC_NETHERWORLD,
/**
@@ -485,35 +496,35 @@ typedef enum sc_type {
SC_CRESCENTELBOW,
SC_CURSEDCIRCLE_ATKER,
SC_CURSEDCIRCLE_TARGET,
- SC_LIGHTNINGWALK,//416
+ SC_LIGHTNINGWALK,
SC_RAISINGDRAGON,
- SC_GT_ENERGYGAIN,
- SC_GT_CHANGE,
- SC_GT_REVITALIZE,
+ SC_GENTLETOUCH_ENERGYGAIN,
+ SC_GENTLETOUCH_CHANGE,
+ SC_GENTLETOUCH_REVITALIZE,
/**
* Genetic
**/
- SC_GN_CARTBOOST,//427
- SC_THORNSTRAP,
- SC_BLOODSUCKER,
- SC_SMOKEPOWDER,
- SC_TEARGAS,
- SC_MANDRAGORA,//426
+ SC_GN_CARTBOOST,
+ SC_THORNS_TRAP,
+ SC_BLOOD_SUCKER,
+ SC_FIRE_EXPANSION_SMOKE_POWDER,
+ SC_FIRE_EXPANSION_TEAR_GAS,
+ SC_MANDRAGORA,
SC_STOMACHACHE,
SC_MYSTERIOUS_POWDER,
SC_MELON_BOMB,
SC_BANANA_BOMB,
- SC_BANANA_BOMB_SITDOWN,//431
+ SC_BANANA_BOMB_SITDOWN_POSTDELAY,
SC_SAVAGE_STEAK,
SC_COCKTAIL_WARG_BLOOD,
SC_MINOR_BBQ,
SC_SIROMA_ICE_TEA,
- SC_DROCERA_HERB_STEAMED,//436
+ SC_DROCERA_HERB_STEAMED,
SC_PUTTI_TAILS_NOODLES,
SC_BOOST500,
SC_FULL_SWING_K,
SC_MANA_PLUS,
- SC_MUSTLE_M,//441
+ SC_MUSTLE_M,
SC_LIFE_FORCE_F,
SC_EXTRACT_WHITE_POTION_Z,
SC_VITATA_500,
@@ -521,21 +532,21 @@ typedef enum sc_type {
/**
* Shadow Chaser
**/
- SC__REPRODUCE,//446
+ SC__REPRODUCE,
SC__AUTOSHADOWSPELL,
SC__SHADOWFORM,
SC__BODYPAINT,
SC__INVISIBILITY,
- SC__DEADLYINFECT,//451
+ SC__DEADLYINFECT,
SC__ENERVATION,
SC__GROOMY,
SC__IGNORANCE,
SC__LAZINESS,
- SC__UNLUCKY,//456
+ SC__UNLUCKY,
SC__WEAKNESS,
- SC__STRIPACCESSORY,
+ SC__STRIPACCESSARY,
SC__MANHOLE,
- SC__BLOODYLUST,//460
+ SC__BLOODYLUST,
/**
* Elemental Spirits
**/
@@ -543,61 +554,60 @@ typedef enum sc_type {
SC_CIRCLE_OF_FIRE_OPTION,
SC_FIRE_CLOAK,
SC_FIRE_CLOAK_OPTION,
- SC_WATER_SCREEN,//465
+ SC_WATER_SCREEN,
SC_WATER_SCREEN_OPTION,
SC_WATER_DROP,
SC_WATER_DROP_OPTION,
SC_WATER_BARRIER,
- SC_WIND_STEP,//470
+ SC_WIND_STEP,
SC_WIND_STEP_OPTION,
SC_WIND_CURTAIN,
SC_WIND_CURTAIN_OPTION,
SC_ZEPHYR,
- SC_SOLID_SKIN,//475
+ SC_SOLID_SKIN,
SC_SOLID_SKIN_OPTION,
SC_STONE_SHIELD,
SC_STONE_SHIELD_OPTION,
SC_POWER_OF_GAIA,
- SC_PYROTECHNIC,//480
+ SC_PYROTECHNIC,
SC_PYROTECHNIC_OPTION,
SC_HEATER,
SC_HEATER_OPTION,
SC_TROPIC,
- SC_TROPIC_OPTION,//485
+ SC_TROPIC_OPTION,
SC_AQUAPLAY,
SC_AQUAPLAY_OPTION,
SC_COOLER,
SC_COOLER_OPTION,
- SC_CHILLY_AIR,//490
+ SC_CHILLY_AIR,
SC_CHILLY_AIR_OPTION,
SC_GUST,
SC_GUST_OPTION,
SC_BLAST,
- SC_BLAST_OPTION,//495
+ SC_BLAST_OPTION,
SC_WILD_STORM,
SC_WILD_STORM_OPTION,
SC_PETROLOGY,
SC_PETROLOGY_OPTION,
- SC_CURSED_SOIL,//500
+ SC_CURSED_SOIL,
SC_CURSED_SOIL_OPTION,
SC_UPHEAVAL,
SC_UPHEAVAL_OPTION,
SC_TIDAL_WEAPON,
- SC_TIDAL_WEAPON_OPTION,//505
+ SC_TIDAL_WEAPON_OPTION,
SC_ROCK_CRUSHER,
SC_ROCK_CRUSHER_ATK,
/* Guild Aura */
SC_LEADERSHIP,
SC_GLORYWOUNDS,
- SC_SOULCOLD, //508
+ SC_SOULCOLD,
SC_HAWKEYES,
/* ... */
SC_ODINS_POWER,
- SC_RAID,
/* Sorcerer .extra */
SC_FIRE_INSIGNIA,
SC_WATER_INSIGNIA,
- SC_WIND_INSIGNIA, //516
+ SC_WIND_INSIGNIA,
SC_EARTH_INSIGNIA,
/* new pushcart */
SC_PUSH_CART,
@@ -610,22 +620,22 @@ typedef enum sc_type {
SC_SPELLBOOK6,
/**
* In official server there are only 7 maximum number of spell books that can be memorized
- * To increase the maximum value just add another status type before SC_MAXSPELLBOOK (ex. SC_SPELLBOOK7, SC_SPELLBOOK8 and so on)
+ * To increase the maximum value just add another status type before SC_SPELLBOOK7 (ex. SC_SPELLBOOK8, SC_SPELLBOOK9 and so on)
**/
- SC_MAXSPELLBOOK,
+ SC_SPELLBOOK7,
/* Max HP & SP */
SC_INCMHP,
SC_INCMSP,
- SC_PARTYFLEE, // 531
+ SC_PARTYFLEE,
/**
* Kagerou & Oboro [malufett]
**/
SC_MEIKYOUSISUI,
- SC_JYUMONJIKIRI,
+ SC_KO_JYUMONJIKIRI,
SC_KYOUGAKU,
SC_IZAYOI,
SC_ZENKAI,
- SC_KAGEHUMI,
+ SC_KG_KAGEHUMI,
SC_KYOMU,
SC_KAGEMUSYA,
SC_ZANGETSU,
@@ -639,87 +649,96 @@ typedef enum sc_type {
SC_ERASER_CUTTER,
SC_OVERED_BOOST,
SC_LIGHT_OF_REGENE,
- SC_ASH,
+ SC_VOLCANIC_ASH,
SC_GRANITIC_ARMOR,
SC_MAGMA_FLOW,
SC_PYROCLASTIC,
- SC_PARALYSIS,
+ SC_NEEDLE_OF_PARALYZE,
SC_PAIN_KILLER,
-
-
#ifdef RENEWAL
SC_EXTREMITYFIST2,
+ SC_RAID,
#endif
+ SC_DARKCROW = 553,
+ SC_FULL_THROTTLE,
+ SC_REBOUND,
+ SC_UNLIMIT,
+ SC_KINGS_GRACE,
+ SC_TELEKINESIS_INTENSE,
+ SC_OFFERTORIUM,
+ SC_FRIGG_SONG,
SC_ALL_RIDING,
SC_HANBOK,
+ SC_MONSTER_TRANSFORM,
+
SC_MAX, //Automatically updated max, used in for's to check we are within bounds.
} sc_type;
// Official status change ids, used to display status icons on the client.
enum si_type {
SI_BLANK = -1,
- SI_PROVOKE = 0,
- SI_ENDURE = 1,
- SI_TWOHANDQUICKEN = 2,
- SI_CONCENTRATE = 3,
- SI_HIDING = 4,
- SI_CLOAKING = 5,
- SI_ENCPOISON = 6,
- SI_POISONREACT = 7,
- SI_QUAGMIRE = 8,
- SI_ANGELUS = 9,
- SI_BLESSING = 10,
- SI_SIGNUMCRUCIS = 11,
- SI_INCREASEAGI = 12,
- SI_DECREASEAGI = 13,
- SI_SLOWPOISON = 14,
- SI_IMPOSITIO = 15,
- SI_SUFFRAGIUM = 16,
- SI_ASPERSIO = 17,
- SI_BENEDICTIO = 18,
- SI_KYRIE = 19,
- SI_MAGNIFICAT = 20,
- SI_GLORIA = 21,
- SI_AETERNA = 22,
- SI_ADRENALINE = 23,
- SI_WEAPONPERFECTION = 24,
- SI_OVERTHRUST = 25,
- SI_MAXIMIZEPOWER = 26,
- SI_RIDING = 27,
- SI_FALCON = 28,
- SI_TRICKDEAD = 29,
- SI_LOUD = 30,
- SI_ENERGYCOAT = 31,
- SI_BROKENARMOR = 32,
- SI_BROKENWEAPON = 33,
- SI_HALLUCINATION = 34,
- SI_WEIGHT50 = 35,
- SI_WEIGHT90 = 36,
- SI_ASPDPOTION0 = 37,
- SI_ASPDPOTION1 = 38,
- SI_ASPDPOTION2 = 39,
- SI_ASPDPOTIONINFINITY = 40,
- SI_SPEEDPOTION1 = 41,
-// SI_MOVHASTE_INFINITY = 42,
+ SI_PROVOKE = 0,
+ SI_ENDURE = 1,
+ SI_TWOHANDQUICKEN = 2,
+ SI_CONCENTRATION = 3,
+ SI_HIDING = 4,
+ SI_CLOAKING = 5,
+ SI_ENCHANTPOISON = 6,
+ SI_POISONREACT = 7,
+ SI_QUAGMIRE = 8,
+ SI_ANGELUS = 9,
+ SI_BLESSING = 10,
+ SI_CRUCIS = 11,
+ SI_INC_AGI = 12,
+ SI_DEC_AGI = 13,
+ SI_SLOWPOISON = 14,
+ SI_IMPOSITIO = 15,
+ SI_SUFFRAGIUM = 16,
+ SI_ASPERSIO = 17,
+ SI_BENEDICTIO = 18,
+ SI_KYRIE = 19,
+ SI_MAGNIFICAT = 20,
+ SI_GLORIA = 21,
+ SI_LEXAETERNA = 22,
+ SI_ADRENALINE = 23,
+ SI_WEAPONPERFECT = 24,
+ SI_OVERTHRUST = 25,
+ SI_MAXIMIZE = 26,
+ SI_RIDING = 27,
+ SI_FALCON = 28,
+ SI_TRICKDEAD = 29,
+ SI_SHOUT = 30,
+ SI_ENERGYCOAT = 31,
+ SI_BROKENARMOR = 32,
+ SI_BROKENWEAPON = 33,
+ SI_ILLUSION = 34,
+ SI_WEIGHTOVER50 = 35,
+ SI_WEIGHTOVER90 = 36,
+ SI_ATTHASTE_POTION1 = 37,
+ SI_ATTHASTE_POTION2 = 38,
+ SI_ATTHASTE_POTION3 = 39,
+ SI_ATTHASTE_INFINITY = 40,
+ SI_MOVHASTE_POTION = 41,
+ SI_MOVHASTE_INFINITY = 42,
// SI_AUTOCOUNTER = 43,
// SI_SPLASHER = 44,
-// SI_ANKLESNARE = 45,
- SI_ACTIONDELAY = 46,
+ SI_ANKLESNARE = 45,
+ SI_POSTDELAY = 46,
// SI_NOACTION = 47,
// SI_IMPOSSIBLEPICKUP = 48,
// SI_BARRIER = 49,
- SI_STRIPWEAPON = 50,
- SI_STRIPSHIELD = 51,
- SI_STRIPARMOR = 52,
- SI_STRIPHELM = 53,
- SI_CP_WEAPON = 54,
- SI_CP_SHIELD = 55,
- SI_CP_ARMOR = 56,
- SI_CP_HELM = 57,
- SI_AUTOGUARD = 58,
- SI_REFLECTSHIELD = 59,
+ SI_NOEQUIPWEAPON = 50,
+ SI_NOEQUIPSHIELD = 51,
+ SI_NOEQUIPARMOR = 52,
+ SI_NOEQUIPHELM = 53,
+ SI_PROTECTWEAPON = 54,
+ SI_PROTECTSHIELD = 55,
+ SI_PROTECTARMOR = 56,
+ SI_PROTECTHELM = 57,
+ SI_AUTOGUARD = 58,
+ SI_REFLECTSHIELD = 59,
// SI_DEVOTION = 60,
SI_PROVIDENCE = 61,
SI_DEFENDER = 62,
@@ -750,29 +769,29 @@ enum si_type {
SI_STEELBODY = 87,
SI_EXTREMITYFIST = 88,
// SI_COMBOATTACK = 89,
- SI_FIREWEAPON = 90,
- SI_WATERWEAPON = 91,
- SI_WINDWEAPON = 92,
- SI_EARTHWEAPON = 93,
+ SI_PROPERTYFIRE = 90,
+ SI_PROPERTYWATER = 91,
+ SI_PROPERTYWIND = 92,
+ SI_PROPERTYGROUND = 93,
// SI_MAGICATTACK = 94,
SI_STOP = 95,
// SI_WEAPONBRAKER = 96,
- SI_UNDEAD = 97,
+ SI_PROPERTYUNDEAD = 97,
// SI_POWERUP = 98,
// SI_AGIUP = 99,
// SI_SIEGEMODE = 100,
// SI_INVISIBLE = 101,
// SI_STATUSONE = 102,
- SI_AURABLADE = 103,
- SI_PARRYING = 104,
- SI_CONCENTRATION = 105,
- SI_TENSIONRELAX = 106,
+ SI_AURABLADE = 103,
+ SI_PARRYING = 104,
+ SI_LKCONCENTRATION = 105,
+ SI_TENSIONRELAX = 106,
SI_BERSERK = 107,
// SI_SACRIFICE = 108,
// SI_GOSPEL = 109,
SI_ASSUMPTIO = 110,
// SI_BASILICA = 111,
- SI_LANDENDOW = 112,
+ SI_GROUNDMAGIC = 112,
SI_MAGICPOWER = 113,
SI_EDP = 114,
SI_TRUESIGHT = 115,
@@ -780,52 +799,52 @@ enum si_type {
SI_MELTDOWN = 117,
SI_CARTBOOST = 118,
// SI_CHASEWALK = 119,
- SI_REJECTSWORD = 120,
- SI_MARIONETTE = 121,
- SI_MARIONETTE2 = 122,
- SI_MOONLIT = 123,
- SI_BLEEDING = 124,
+ SI_SWORDREJECT = 120,
+ SI_MARIONETTE_MASTER = 121,
+ SI_MARIONETTE = 122,
+ SI_MOON = 123,
+ SI_BLOODING = 124,
SI_JOINTBEAT = 125,
// SI_MINDBREAKER = 126,
// SI_MEMORIZE = 127,
// SI_FOGWALL = 128,
// SI_SPIDERWEB = 129,
- SI_BABY = 130,
+ SI_PROTECTEXP = 130,
// SI_SUB_WEAPONPROPERTY = 131,
SI_AUTOBERSERK = 132,
SI_RUN = 133,
- SI_BUMP = 134,
- SI_READYSTORM = 135,
-// SI_STORMKICK_READY = 136,
- SI_READYDOWN = 137,
-// SI_DOWNKICK_READY = 138,
- SI_READYTURN = 139,
-// SI_TURNKICK_READY = 140,
- SI_READYCOUNTER = 141,
-// SI_COUNTER_READY = 142,
- SI_DODGE = 143,
-// SI_DODGE_READY = 144,
- SI_SPURT = 145,
- SI_SHADOWWEAPON = 146,
- SI_ADRENALINE2 = 147,
- SI_GHOSTWEAPON = 148,
- SI_SPIRIT = 149,
- SI_PLUSATTACKPOWER = 150,
- SI_PLUSMAGICPOWER = 151,
- SI_DEVIL = 152,
+ SI_TING = 134,
+ SI_STORMKICK_ON = 135,
+ SI_STORMKICK_READY = 136,
+ SI_DOWNKICK_ON = 137,
+ SI_DOWNKICK_READY = 138,
+ SI_TURNKICK_ON = 139,
+ SI_TURNKICK_READY = 140,
+ SI_COUNTER_ON = 141,
+ SI_COUNTER_READY = 142,
+ SI_DODGE_ON = 143,
+ SI_DODGE_READY = 144,
+ SI_STRUP = 145,
+ SI_PROPERTYDARK = 146,
+ SI_ADRENALINE2 = 147,
+ SI_PROPERTYTELEKINESIS = 148,
+ SI_SOULLINK = 149,
+ SI_PLUSATTACKPOWER = 150,
+ SI_PLUSMAGICPOWER = 151,
+ SI_DEVIL1 = 152,
SI_KAITE = 153,
// SI_SWOO = 154,
// SI_STAR2 = 155,
SI_KAIZEL = 156,
SI_KAAHI = 157,
SI_KAUPE = 158,
- SI_SMA = 159,
- SI_NIGHT = 160,
- SI_ONEHAND = 161,
+ SI_SMA_READY = 159,
+ SI_SKE = 160,
+ SI_ONEHANDQUICKEN = 161,
// SI_FRIEND = 162,
// SI_FRIENDUP = 163,
// SI_SG_WARM = 164,
- SI_WARM = 165,
+ SI_SG_SUN_WARM = 165,
// 166 | The three show the exact same display: ultra red character (165, 166, 167)
// 167 | Their names would be SI_SG_SUN_WARM, SI_SG_MOON_WARM, SI_SG_STAR_WARM
// SI_EMOTION = 168,
@@ -844,34 +863,34 @@ enum si_type {
SI_PRESERVE = 181,
SI_INCSTR = 182,
// SI_NOT_EXTREMITYFIST = 183,
- SI_INTRAVISION = 184,
+ SI_CLAIRVOYANCE = 184,
// SI_MOVESLOW_POTION = 185,
- SI_DOUBLECAST = 186,
+ SI_DOUBLECASTING = 186,
// SI_GRAVITATION = 187,
- SI_MAXOVERTHRUST = 188,
+ SI_OVERTHRUSTMAX = 188,
// SI_LONGING = 189,
// SI_HERMODE = 190,
- SI_TAROT = 191, // the icon allows no doubt... but what is it really used for ?? [DracoRPG]
+ SI_TAROTCARD = 191, // the icon allows no doubt... but what is it really used for ?? [DracoRPG]
// SI_HLIF_AVOID = 192,
// SI_HFLI_FLEET = 193,
// SI_HFLI_SPEED = 194,
// SI_HLIF_CHANGE = 195,
// SI_HAMI_BLOODLUST = 196,
- SI_SHRINK = 197,
- SI_SIGHTBLASTER = 198,
- SI_WINKCHARM = 199,
- SI_CLOSECONFINE = 200,
- SI_CLOSECONFINE2 = 201,
+ SI_CR_SHRINK = 197,
+ SI_WZ_SIGHTBLASTER = 198,
+ SI_DC_WINKCHARM = 199,
+ SI_RG_CCONFINE_M = 200,
+ SI_RG_CCONFINE_S = 201,
// SI_DISABLEMOVE = 202,
- SI_MADNESSCANCEL = 203, //[blackhole89]
- SI_GATLINGFEVER = 204,
- SI_EARTHSCROLL = 205,
- SI_UTSUSEMI = 206,
- SI_BUNSINJYUTSU = 207,
- SI_NEN = 208,
- SI_ADJUSTMENT = 209,
- SI_ACCURACY = 210,
-// SI_NJ_SUITON = 211,
+ SI_GS_MADNESSCANCEL = 203, //[blackhole89]
+ SI_GS_GATLINGFEVER = 204,
+ SI_EARTHSCROLL = 205,
+ SI_NJ_UTSUSEMI = 206,
+ SI_NJ_BUNSINJYUTSU = 207,
+ SI_NJ_NEN = 208,
+ SI_GS_ADJUSTMENT = 209,
+ SI_GS_ACCURACY = 210,
+ SI_NJ_SUITON = 211,
// SI_PET = 212,
// SI_MENTAL = 213,
// SI_EXPMEMORY = 214,
@@ -901,19 +920,19 @@ enum si_type {
// SI_DGAUGE = 238,
// SI_DACCEL = 239,
// SI_DBLOCK = 240,
- SI_FOODSTR = 241,
- SI_FOODAGI = 242,
- SI_FOODVIT = 243,
- SI_FOODDEX = 244,
- SI_FOODINT = 245,
- SI_FOODLUK = 246,
- SI_FOODFLEE = 247,
- SI_FOODHIT = 248,
- SI_FOODCRI = 249,
- SI_EXPBOOST = 250,
- SI_LIFEINSURANCE = 251,
- SI_ITEMBOOST = 252,
- SI_BOSSMAPINFO = 253,
+ SI_FOOD_STR = 241,
+ SI_FOOD_AGI = 242,
+ SI_FOOD_VIT = 243,
+ SI_FOOD_DEX = 244,
+ SI_FOOD_INT = 245,
+ SI_FOOD_LUK = 246,
+ SI_FOOD_BASICAVOIDANCE = 247,
+ SI_FOOD_BASICHIT = 248,
+ SI_FOOD_CRITICALSUCCESSVALUE = 249,
+ SI_CASH_PLUSEXP = 250,
+ SI_CASH_DEATHPENALTY = 251,
+ SI_CASH_RECEIVEITEM = 252,
+ SI_CASH_BOSS_ALARM = 253,
// SI_DA_ENERGY = 254,
// SI_DA_FIRSTSLOT = 255,
// SI_DA_HEADDEF = 256,
@@ -937,11 +956,11 @@ enum si_type {
SI_FOOD_DEX_CASH = 274,
SI_FOOD_INT_CASH = 275,
SI_FOOD_LUK_CASH = 276,
- SI_MERC_FLEEUP = 277,
- SI_MERC_ATKUP = 278,
- SI_MERC_HPUP = 279,
- SI_MERC_SPUP = 280,
- SI_MERC_HITUP = 281,
+ SI_MER_FLEE = 277,
+ SI_MER_ATK = 278,
+ SI_MER_HP = 279,
+ SI_MER_SP = 280,
+ SI_MER_HIT = 281,
SI_SLOWCAST = 282,
// SI_MAGICMIRROR = 283,
// SI_STONESKIN = 284,
@@ -949,14 +968,14 @@ enum si_type {
SI_CRITICALWOUND = 286,
// SI_NPC_DEFENDER = 287,
// SI_NOACTION_WAIT = 288,
- SI_MOVHASTE_HORSE = 289,
- SI_DEF_RATE = 290,
- SI_MDEF_RATE = 291,
- SI_INCHEALRATE = 292,
- SI_S_LIFEPOTION = 293,
- SI_L_LIFEPOTION = 294,
- SI_INCCRI = 295,
- SI_PLUSAVOIDVALUE = 296,
+ SI_MOVHASTE_HORSE = 289,
+ SI_PROTECT_DEF = 290,
+ SI_PROTECT_MDEF = 291,
+ SI_HEALPLUS = 292,
+ SI_S_LIFEPOTION = 293,
+ SI_L_LIFEPOTION = 294,
+ SI_CRITICALPERCENT = 295,
+ SI_PLUSAVOIDVALUE = 296,
// SI_ATKER_ASPD = 297,
// SI_TARGET_ASPD = 298,
// SI_ATKER_MOVESPEED = 299,
@@ -975,7 +994,7 @@ enum si_type {
SI_CASH_PLUSONLYJOBEXP = 312,
SI_PARTYFLEE = 313,
// SI_ANGEL_PROTECT = 314,
- SI_ENDURE_MDEF = 315,
+// SI_ENDURE_MDEF = 315,
SI_ENCHANTBLADE = 316,
SI_DEATHBOUND = 317,
SI_REFRESH = 318,
@@ -1094,12 +1113,12 @@ enum si_type {
SI_PROPERTYWALK = 431,
SI_SPELLFIST = 432,
SI_NETHERWORLD = 433,
- SI_VOICEOFSIREN = 434,
+ SI_SIREN = 434,
SI_DEEPSLEEP = 435,
SI_SIRCLEOFNATURE = 436,
SI_COLD = 437,
SI_GLOOMYDAY = 438,
- SI_SONGOFMANA = 439,
+ SI_SONG_OF_MANA = 439,
SI_CLOUDKILL = 440,
SI_DANCEWITHWUG = 441,
SI_RUSHWINDMILL = 442,
@@ -1361,6 +1380,34 @@ enum si_type {
SI_QUEST_BUFF3 = 707,
SI_REUSE_LIMIT_RECALL = 708,
SI_SAVEPOSITION = 709,
+ SI_HANDICAPSTATE_ICEEXPLO = 710,
+ SI_FENRIR_CARD = 711,
+ SI_REUSE_LIMIT_ASPD_POTION = 712,
+ SI_MAXPAIN = 713,
+ SI_PC_STOP = 714,
+ SI_FRIGG_SONG = 715,
+ SI_OFFERTORIUM = 716,
+ SI_TELEKINESIS_INTENSE = 717,
+ SI_MOONSTAR = 718,
+ SI_STRANGELIGHTS = 719,
+ SI_FULL_THROTTLE = 720,
+ SI_REBOUND = 721,
+ SI_UNLIMIT = 722,
+ SI_KINGS_GRACE = 723,
+ SI_ITEM_ATKMAX = 724,
+ SI_ITEM_ATKMIN = 725,
+ SI_ITEM_MATKMAX = 726,
+ SI_ITEM_MATKMIN = 727,
+ SI_SUPER_STAR = 728,
+ SI_HIGH_RANKER = 729,
+ SI_DARKCROW = 730,
+ SI_2013_VALENTINE1 = 731,
+ SI_2013_VALENTINE2 = 732,
+ SI_2013_VALENTINE3 = 733,
+ //SI_ = 734,
+ //SI_ = 735,
+ SI_CHILL = 736,
+ SI_BURNT = 737,
SI_MAX,
};
@@ -1553,7 +1600,7 @@ enum scb_flag
//Basic damage info of a weapon
//Required because players have two of these, one in status_data
//and another for their left hand weapon.
-struct weapon_atk {
+typedef struct weapon_atk {
unsigned short atk, atk2;
unsigned short range;
unsigned char ele;
@@ -1561,7 +1608,7 @@ struct weapon_atk {
unsigned short matk;
unsigned char wlv;
#endif
-};
+}weapon_atk;
sc_type SkillStatusChangeTable[MAX_SKILL]; // skill -> status
int StatusIconChangeTable[SC_MAX]; // status -> "icon" (icon is a bit of a misnomer, since there exist values with no icon associated)
@@ -1681,6 +1728,7 @@ sc_type status_skill2sc(int skill);
int status_sc2skill(sc_type sc);
unsigned int status_sc2scb_flag(sc_type sc);
int status_type2relevant_bl_types(int type);
+int status_get_sc_type(sc_type idx);
int status_damage(struct block_list *src,struct block_list *target,int hp,int sp, int walkdelay, int flag);
//Define for standard HP damage attacks.
@@ -1801,10 +1849,20 @@ int status_check_visibility(struct block_list *src, struct block_list *target);
int status_change_spread( struct block_list *src, struct block_list *bl );
+defType status_calc_def(struct block_list *bl, struct status_change *sc, int, bool);
+signed short status_calc_def2(struct block_list *,struct status_change *, int, bool);
+defType status_calc_mdef(struct block_list *bl, struct status_change *sc, int, bool);
+signed short status_calc_mdef2(struct block_list *,struct status_change *, int, bool);
+
#ifdef RENEWAL
unsigned short status_base_matk(const struct status_data* status, int level);
+int status_get_weapon_atk(struct block_list *src, struct weapon_atk *watk, int flag);
+int status_get_total_mdef(struct block_list *src);
+int status_get_total_def(struct block_list *src);
#endif
+int status_get_matk(struct block_list *src, int flag);
+
int status_readdb(void);
int do_init_status(void);
void do_final_status(void);
diff --git a/src/map/storage.c b/src/map/storage.c
index 01da53907..e3fa073af 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#include "../common/cbasetypes.h"
#include "../common/db.h"
@@ -23,9 +24,6 @@
#include <stdlib.h>
#include <string.h>
-
-static DBMap* guild_storage_db; // int guild_id -> struct guild_storage*
-
/*==========================================
* Sort items in the warehouse
*------------------------------------------*/
@@ -57,14 +55,13 @@ static void storage_sortitem(struct item* items, unsigned int size)
/*==========================================
* Init/Terminate
*------------------------------------------*/
-int do_init_storage(void) // Called from map.c::do_init()
-{
- guild_storage_db=idb_alloc(DB_OPT_RELEASE_DATA);
+/* ##TODO not really init_storage but init_gstorage, should rename/move */
+int do_init_storage(void) { // Called from map.c::do_init()
+ gstorage->db = idb_alloc(DB_OPT_RELEASE_DATA);
return 1;
}
-void do_final_storage(void) // by [MC Cameri]
-{
- guild_storage_db->destroy(guild_storage_db,NULL);
+void do_final_storage(void) { // by [MC Cameri]
+ gstorage->db->destroy(gstorage->db,NULL);
}
/**
@@ -75,15 +72,14 @@ static int storage_reconnect_sub(DBKey key, DBData *data, va_list ap)
{
struct guild_storage *stor = DB->data2ptr(data);
if (stor->dirty && stor->storage_status == 0) //Save closed storages.
- storage_guild_storagesave(0, stor->guild_id,0);
+ gstorage->save(0, stor->guild_id,0);
return 0;
}
//Function to be invoked upon server reconnection to char. To save all 'dirty' storages [Skotlex]
-void do_reconnect_storage(void)
-{
- guild_storage_db->foreach(guild_storage_db, storage_reconnect_sub);
+void do_reconnect_storage(void) {
+ gstorage->db->foreach(gstorage->db, storage_reconnect_sub);
}
/*==========================================
@@ -98,7 +94,7 @@ int storage_storageopen(struct map_session_data *sd)
if(sd->state.storage_flag)
return 1; //Already open?
- if( !pc_can_give_items(sd) )
+ if( !pc->can_give_items(sd) )
{ //check is this GM level is allowed to put items to storage
clif->message(sd->fd, msg_txt(246));
return 1;
@@ -132,8 +128,7 @@ int compare_item(struct item *a, struct item *b)
/*==========================================
* Internal add-item function.
*------------------------------------------*/
-static int storage_additem(struct map_session_data* sd, struct item* item_data, int amount)
-{
+int storage_additem(struct map_session_data* sd, struct item* item_data, int amount) {
struct storage_data* stor = &sd->status.storage;
struct item_data *data;
int i;
@@ -141,14 +136,14 @@ static int storage_additem(struct map_session_data* sd, struct item* item_data,
if( item_data->nameid <= 0 || amount <= 0 )
return 1;
- data = itemdb_search(item_data->nameid);
+ data = itemdb->search(item_data->nameid);
if( data->stack.storage && amount > data->stack.amount )
{// item stack limitation
return 1;
}
- if( !itemdb_canstore(item_data, pc_get_group_level(sd)) )
+ if( !itemdb_canstore(item_data, pc->get_group_level(sd)) )
{ //Check if item is storable. [Skotlex]
clif->message (sd->fd, msg_txt(264));
return 1;
@@ -226,8 +221,8 @@ int storage_storageadd(struct map_session_data* sd, int index, int amount)
if( amount < 1 || amount > sd->status.inventory[index].amount )
return 0;
- if( storage_additem(sd,&sd->status.inventory[index],amount) == 0 )
- pc_delitem(sd,index,amount,0,4,LOG_TYPE_STORAGE);
+ if( storage->additem(sd,&sd->status.inventory[index],amount) == 0 )
+ pc->delitem(sd,index,amount,0,4,LOG_TYPE_STORAGE);
return 1;
}
@@ -252,8 +247,8 @@ int storage_storageget(struct map_session_data* sd, int index, int amount)
if( amount < 1 || amount > sd->status.storage.items[index].amount )
return 0;
- if( (flag = pc_additem(sd,&sd->status.storage.items[index],amount,LOG_TYPE_STORAGE)) == 0 )
- storage_delitem(sd,index,amount);
+ if( (flag = pc->additem(sd,&sd->status.storage.items[index],amount,LOG_TYPE_STORAGE)) == 0 )
+ storage->delitem(sd,index,amount);
else
clif->additem(sd,0,0,flag);
@@ -283,8 +278,8 @@ int storage_storageaddfromcart(struct map_session_data* sd, int index, int amoun
if( amount < 1 || amount > sd->status.cart[index].amount )
return 0;
- if( storage_additem(sd,&sd->status.cart[index],amount) == 0 )
- pc_cart_delitem(sd,index,amount,0,LOG_TYPE_STORAGE);
+ if( storage->additem(sd,&sd->status.cart[index],amount) == 0 )
+ pc->cart_delitem(sd,index,amount,0,LOG_TYPE_STORAGE);
return 1;
}
@@ -309,8 +304,8 @@ int storage_storagegettocart(struct map_session_data* sd, int index, int amount)
if( amount < 1 || amount > sd->status.storage.items[index].amount )
return 0;
- if( pc_cart_additem(sd,&sd->status.storage.items[index],amount,LOG_TYPE_STORAGE) == 0 )
- storage_delitem(sd,index,amount);
+ if( pc->cart_additem(sd,&sd->status.storage.items[index],amount,LOG_TYPE_STORAGE) == 0 )
+ storage->delitem(sd,index,amount);
return 1;
}
@@ -325,7 +320,7 @@ void storage_storageclose(struct map_session_data* sd)
clif->storageclose(sd);
- if( save_settings&4 )
+ if( iMap->save_settings&4 )
chrif_save(sd,0); //Invokes the storage saving as well.
sd->state.storage_flag = 0;
@@ -338,7 +333,7 @@ void storage_storage_quit(struct map_session_data* sd, int flag)
{
nullpo_retv(sd);
- if (save_settings&4)
+ if (iMap->save_settings&4)
chrif_save(sd, flag); //Invokes the storage saving as well.
sd->state.storage_flag = 0;
@@ -359,19 +354,17 @@ struct guild_storage *guild2storage(int guild_id)
{
struct guild_storage *gs = NULL;
if(guild->search(guild_id) != NULL)
- gs = idb_ensure(guild_storage_db,guild_id,create_guildstorage);
+ gs = idb_ensure(gstorage->db,guild_id,create_guildstorage);
return gs;
}
//For just locating a storage without creating one. [Skotlex]
-struct guild_storage *guild2storage2(int guild_id)
-{
- return (struct guild_storage*)idb_get(guild_storage_db,guild_id);
+struct guild_storage *guild2storage2(int guild_id) {
+ return (struct guild_storage*)idb_get(gstorage->db,guild_id);
}
-int guild_storage_delete(int guild_id)
-{
- idb_remove(guild_storage_db,guild_id);
+int guild_storage_delete(int guild_id) {
+ idb_remove(gstorage->db,guild_id);
return 0;
}
@@ -394,12 +387,12 @@ int storage_guild_storageopen(struct map_session_data* sd)
if(sd->state.storage_flag)
return 1; //Can't open both storages at a time.
- if( !pc_can_give_items(sd) ) { //check is this GM level can open guild storage and store items [Lupus]
+ if( !pc->can_give_items(sd) ) { //check is this GM level can open guild storage and store items [Lupus]
clif->message(sd->fd, msg_txt(246));
return 1;
}
- if((gstor = guild2storage2(sd->status.guild_id)) == NULL) {
+ if((gstor = gstorage->id2storage2(sd->status.guild_id)) == NULL) {
intif_request_guild_storage(sd->status.account_id,sd->status.guild_id);
return 0;
}
@@ -435,14 +428,14 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto
if(item_data->nameid <= 0 || amount <= 0)
return 1;
- data = itemdb_search(item_data->nameid);
+ data = itemdb->search(item_data->nameid);
if( data->stack.guildstorage && amount > data->stack.amount )
{// item stack limitation
return 1;
}
- if( !itemdb_canguildstore(item_data, pc_get_group_level(sd)) || item_data->expire_time )
+ if( !itemdb_canguildstore(item_data, pc->get_group_level(sd)) || item_data->expire_time )
{ //Check if item is storable. [Skotlex]
clif->message (sd->fd, msg_txt(264));
return 1;
@@ -512,7 +505,7 @@ int storage_guild_storageadd(struct map_session_data* sd, int index, int amount)
struct guild_storage *stor;
nullpo_ret(sd);
- nullpo_ret(stor=guild2storage2(sd->status.guild_id));
+ nullpo_ret(stor=gstorage->id2storage2(sd->status.guild_id));
if( !stor->storage_status || stor->storage_amount > MAX_GUILD_STORAGE )
return 0;
@@ -527,12 +520,12 @@ int storage_guild_storageadd(struct map_session_data* sd, int index, int amount)
return 0;
if( stor->lock ) {
- storage_guild_storageclose(sd);
+ gstorage->close(sd);
return 0;
}
- if(guild_storage_additem(sd,stor,&sd->status.inventory[index],amount)==0)
- pc_delitem(sd,index,amount,0,4,LOG_TYPE_GSTORAGE);
+ if(gstorage->additem(sd,stor,&sd->status.inventory[index],amount)==0)
+ pc->delitem(sd,index,amount,0,4,LOG_TYPE_GSTORAGE);
return 1;
}
@@ -565,12 +558,12 @@ int storage_guild_storageget(struct map_session_data* sd, int index, int amount)
return 0;
if( stor->lock ) {
- storage_guild_storageclose(sd);
+ gstorage->close(sd);
return 0;
}
- if((flag = pc_additem(sd,&stor->items[index],amount,LOG_TYPE_GSTORAGE)) == 0)
- guild_storage_delitem(sd,stor,index,amount);
+ if((flag = pc->additem(sd,&stor->items[index],amount,LOG_TYPE_GSTORAGE)) == 0)
+ gstorage->delitem(sd,stor,index,amount);
else //inform fail
clif->additem(sd,0,0,flag);
// log_fromstorage(sd, index, 1);
@@ -604,8 +597,8 @@ int storage_guild_storageaddfromcart(struct map_session_data* sd, int index, int
if( amount < 1 || amount > sd->status.cart[index].amount )
return 0;
- if(guild_storage_additem(sd,stor,&sd->status.cart[index],amount)==0)
- pc_cart_delitem(sd,index,amount,0,LOG_TYPE_GSTORAGE);
+ if(gstorage->additem(sd,stor,&sd->status.cart[index],amount)==0)
+ pc->cart_delitem(sd,index,amount,0,LOG_TYPE_GSTORAGE);
return 1;
}
@@ -636,8 +629,8 @@ int storage_guild_storagegettocart(struct map_session_data* sd, int index, int a
if(amount < 1 || amount > stor->items[index].amount)
return 0;
- if(pc_cart_additem(sd,&stor->items[index],amount,LOG_TYPE_GSTORAGE)==0)
- guild_storage_delitem(sd,stor,index,amount);
+ if(pc->cart_additem(sd,&stor->items[index],amount,LOG_TYPE_GSTORAGE)==0)
+ gstorage->delitem(sd,stor,index,amount);
return 1;
}
@@ -673,7 +666,7 @@ int storage_guild_storagesaved(int guild_id)
{
struct guild_storage *stor;
- if((stor=guild2storage2(guild_id)) != NULL) {
+ if((stor=gstorage->id2storage2(guild_id)) != NULL) {
if (stor->dirty && stor->storage_status == 0)
{ //Storage has been correctly saved.
stor->dirty = 0;
@@ -689,15 +682,15 @@ int storage_guild_storageclose(struct map_session_data* sd)
struct guild_storage *stor;
nullpo_ret(sd);
- nullpo_ret(stor=guild2storage2(sd->status.guild_id));
+ nullpo_ret(stor=gstorage->id2storage2(sd->status.guild_id));
clif->storageclose(sd);
if (stor->storage_status)
{
- if (save_settings&4)
+ if (iMap->save_settings&4)
chrif_save(sd, 0); //This one also saves the storage. [Skotlex]
else
- storage_guild_storagesave(sd->status.account_id, sd->status.guild_id,0);
+ gstorage->save(sd->status.account_id, sd->status.guild_id,0);
stor->storage_status=0;
}
sd->state.storage_flag = 0;
@@ -710,26 +703,63 @@ int storage_guild_storage_quit(struct map_session_data* sd, int flag)
struct guild_storage *stor;
nullpo_ret(sd);
- nullpo_ret(stor=guild2storage2(sd->status.guild_id));
+ nullpo_ret(stor=gstorage->id2storage2(sd->status.guild_id));
if(flag)
{ //Only during a guild break flag is 1 (don't save storage)
sd->state.storage_flag = 0;
stor->storage_status = 0;
clif->storageclose(sd);
- if (save_settings&4)
+ if (iMap->save_settings&4)
chrif_save(sd,0);
return 0;
}
if(stor->storage_status) {
- if (save_settings&4)
+ if (iMap->save_settings&4)
chrif_save(sd,0);
else
- storage_guild_storagesave(sd->status.account_id,sd->status.guild_id,1);
+ gstorage->save(sd->status.account_id,sd->status.guild_id,1);
}
sd->state.storage_flag = 0;
stor->storage_status = 0;
return 0;
}
+void storage_defaults(void) {
+ storage = &storage_s;
+
+ /* */
+ storage->init = do_init_storage;
+ storage->final = do_final_storage;
+ /* */
+ storage->reconnect = do_reconnect_storage;
+ /* */
+ storage->delitem = storage_delitem;
+ storage->open = storage_storageopen;
+ storage->add = storage_storageadd;
+ storage->additem = storage_additem;
+ storage->get = storage_storageget;
+ storage->addfromcart = storage_storageaddfromcart;
+ storage->gettocart = storage_storagegettocart;
+ storage->close = storage_storageclose;
+ storage->pc_quit = storage_storage_quit;
+}
+void gstorage_defaults(void) {
+ gstorage = &gstorage_s;
+
+ gstorage->id2storage = guild2storage;
+ gstorage->id2storage2 = guild2storage2;
+ gstorage->delete = guild_storage_delete;
+ gstorage->open = storage_guild_storageopen;
+ gstorage->additem = guild_storage_additem;
+ gstorage->delitem = guild_storage_delitem;
+ gstorage->add = storage_guild_storageadd;
+ gstorage->get = storage_guild_storageget;
+ gstorage->addfromcart = storage_guild_storageaddfromcart;
+ gstorage->gettocart = storage_guild_storagegettocart;
+ gstorage->close = storage_guild_storageclose;
+ gstorage->pc_quit = storage_guild_storage_quit;
+ gstorage->save = storage_guild_storagesave;
+ gstorage->saved = storage_guild_storagesaved;
+} \ No newline at end of file
diff --git a/src/map/storage.h b/src/map/storage.h
index c08ec81cb..fc05ef06c 100644
--- a/src/map/storage.h
+++ b/src/map/storage.h
@@ -1,41 +1,56 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#ifndef _STORAGE_H_
#define _STORAGE_H_
-//#include "../common/mmo.h"
struct storage_data;
struct guild_storage;
struct item;
-//#include "map.h"
struct map_session_data;
+struct DBMap;
-int storage_delitem(struct map_session_data* sd, int n, int amount);
-int storage_storageopen(struct map_session_data *sd);
-int storage_storageadd(struct map_session_data *sd,int index,int amount);
-int storage_storageget(struct map_session_data *sd,int index,int amount);
-int storage_storageaddfromcart(struct map_session_data *sd,int index,int amount);
-int storage_storagegettocart(struct map_session_data *sd,int index,int amount);
-void storage_storageclose(struct map_session_data *sd);
-int do_init_storage(void);
-void do_final_storage(void);
-void do_reconnect_storage(void);
-void storage_storage_quit(struct map_session_data *sd, int flag);
+struct storage_interface {
+ int (*init) (void);
+ void (*final) (void);
+ /* */
+ void (*reconnect) (void);
+ /* */
+ int (*delitem) (struct map_session_data* sd, int n, int amount);
+ int (*open) (struct map_session_data *sd);
+ int (*add) (struct map_session_data *sd,int index,int amount);
+ int (*get) (struct map_session_data *sd,int index,int amount);
+ int (*additem) (struct map_session_data* sd, struct item* item_data, int amount);
+ int (*addfromcart) (struct map_session_data *sd,int index,int amount);
+ int (*gettocart) (struct map_session_data *sd,int index,int amount);
+ void (*close) (struct map_session_data *sd);
+ void (*pc_quit) (struct map_session_data *sd, int flag);
+} storage_s;
+struct storage_interface *storage;
-struct guild_storage* guild2storage(int guild_id);
-struct guild_storage *guild2storage2(int guild_id);
-int guild_storage_delete(int guild_id);
-int storage_guild_storageopen(struct map_session_data *sd);
-int guild_storage_additem(struct map_session_data *sd,struct guild_storage *stor,struct item *item_data,int amount);
-int guild_storage_delitem(struct map_session_data *sd,struct guild_storage *stor,int n,int amount);
-int storage_guild_storageadd(struct map_session_data *sd,int index,int amount);
-int storage_guild_storageget(struct map_session_data *sd,int index,int amount);
-int storage_guild_storageaddfromcart(struct map_session_data *sd,int index,int amount);
-int storage_guild_storagegettocart(struct map_session_data *sd,int index,int amount);
-int storage_guild_storageclose(struct map_session_data *sd);
-int storage_guild_storage_quit(struct map_session_data *sd,int flag);
-int storage_guild_storagesave(int account_id, int guild_id, int flag);
-int storage_guild_storagesaved(int guild_id); //Ack from char server that guild store was saved.
+struct guild_storage_interface {
+ struct DBMap* db; // int guild_id -> struct guild_storage*
+ /* */
+ struct guild_storage *(*id2storage) (int guild_id);
+ struct guild_storage *(*id2storage2) (int guild_id);
+ int (*delete) (int guild_id);
+ int (*open) (struct map_session_data *sd);
+ int (*additem) (struct map_session_data *sd,struct guild_storage *stor,struct item *item_data,int amount);
+ int (*delitem) (struct map_session_data *sd,struct guild_storage *stor,int n,int amount);
+ int (*add) (struct map_session_data *sd,int index,int amount);
+ int (*get) (struct map_session_data *sd,int index,int amount);
+ int (*addfromcart) (struct map_session_data *sd,int index,int amount);
+ int (*gettocart) (struct map_session_data *sd,int index,int amount);
+ int (*close) (struct map_session_data *sd);
+ int (*pc_quit) (struct map_session_data *sd,int flag);
+ int (*save) (int account_id, int guild_id, int flag);
+ int (*saved) (int guild_id); //Ack from char server that guild store was saved.
+} gstorage_s;
+
+struct guild_storage_interface *gstorage;
+
+void storage_defaults(void);
+void gstorage_defaults(void);
#endif /* _STORAGE_H_ */
diff --git a/src/map/trade.c b/src/map/trade.c
index 1417426e9..a2a29651b 100644
--- a/src/map/trade.c
+++ b/src/map/trade.c
@@ -55,7 +55,7 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta
}
if ( sd->trade_partner != 0 ) { // If a character tries to trade to another one then cancel the previous one
- struct map_session_data *previous_sd = map_id2sd(sd->trade_partner);
+ struct map_session_data *previous_sd = iMap->id2sd(sd->trade_partner);
if( previous_sd ){
previous_sd->trade_partner = 0;
clif->tradecancelled(previous_sd);
@@ -69,7 +69,7 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta
return;
}
- if (!pc_can_give_items(sd) || !pc_can_give_items(target_sd)) //check if both GMs are allowed to trade
+ if (!pc->can_give_items(sd) || !pc->can_give_items(target_sd)) //check if both GMs are allowed to trade
{
clif->message(sd->fd, msg_txt(246));
clif->tradestart(sd, 2); // GM is not allowed to trade
@@ -77,7 +77,7 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta
}
// Players can not request trade from far away, unless they are allowed to use @trade.
- if (!pc_can_use_command(sd, "@trade") &&
+ if (!pc->can_use_command(sd, "@trade") &&
(sd->bl.m != target_sd->bl.m || !check_distance_bl(&sd->bl, &target_sd->bl, TRADE_DISTANCE))) {
clif->tradestart(sd, 0); // too far
return ;
@@ -107,7 +107,7 @@ void trade_tradeack(struct map_session_data *sd, int type)
if (sd->state.trading || !sd->trade_partner)
return; //Already trading or no partner set.
- if ((tsd = map_id2sd(sd->trade_partner)) == NULL) {
+ if ((tsd = iMap->id2sd(sd->trade_partner)) == NULL) {
clif->tradestart(sd, 1); // character does not exist
sd->trade_partner=0;
return;
@@ -135,7 +135,7 @@ void trade_tradeack(struct map_session_data *sd, int type)
// Players can not request trade from far away, unless they are allowed to use @trade.
// Check here as well since the original character could had warped.
- if (!pc_can_use_command(sd, "@trade") &&
+ if (!pc->can_use_command(sd, "@trade") &&
(sd->bl.m != tsd->bl.m || !check_distance_bl(&sd->bl, &tsd->bl, TRADE_DISTANCE))) {
clif->tradestart(sd, 0); // too far
sd->trade_partner=0;
@@ -201,9 +201,9 @@ int impossible_trade_check(struct map_session_data *sd)
if (inventory[index].amount < sd->deal.item[i].amount)
{ // if more than the player have -> hack
sprintf(message_to_gm, msg_txt(538), sd->status.name, sd->status.account_id); // Hack on trade: character '%s' (account: %d) try to trade more items that he has.
- intif_wis_message_to_gm(wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm);
+ intif_wis_message_to_gm(iMap->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm);
sprintf(message_to_gm, msg_txt(539), inventory[index].amount, inventory[index].nameid, sd->deal.item[i].amount); // This player has %d of a kind of item (id: %d), and try to trade %d of them.
- intif_wis_message_to_gm(wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm);
+ intif_wis_message_to_gm(iMap->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm);
// if we block people
if (battle_config.ban_hack_trade < 0) {
chrif_char_ask_name(-1, sd->status.name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
@@ -220,7 +220,7 @@ int impossible_trade_check(struct map_session_data *sd)
// message about the ban
strcpy(message_to_gm, msg_txt(508)); // This player hasn't been banned (Ban option is disabled).
- intif_wis_message_to_gm(wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm);
+ intif_wis_message_to_gm(iMap->wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm);
return 1;
}
inventory[index].amount -= sd->deal.item[i].amount; // remove item from inventory
@@ -257,7 +257,7 @@ int trade_check(struct map_session_data *sd, struct map_session_data *tsd)
if (amount > inventory[n].amount)
return 0; //qty Exploit?
- data = itemdb_search(inventory[n].nameid);
+ data = itemdb->search(inventory[n].nameid);
i = MAX_INVENTORY;
if (itemdb_isstackable2(data)) { //Stackable item.
for(i = 0; i < MAX_INVENTORY; i++)
@@ -288,7 +288,7 @@ int trade_check(struct map_session_data *sd, struct map_session_data *tsd)
if (amount > inventory2[n].amount)
return 0;
// search if it's possible to add item (for full inventory)
- data = itemdb_search(inventory2[n].nameid);
+ data = itemdb->search(inventory2[n].nameid);
i = MAX_INVENTORY;
if (itemdb_isstackable2(data)) {
for(i = 0; i < MAX_INVENTORY; i++)
@@ -329,9 +329,9 @@ void trade_tradeadditem(struct map_session_data *sd, short index, short amount)
if( !sd->state.trading || sd->state.deal_locked > 0 )
return; //Can't add stuff.
- if( (target_sd = map_id2sd(sd->trade_partner)) == NULL )
+ if( (target_sd = iMap->id2sd(sd->trade_partner)) == NULL )
{
- trade_tradecancel(sd);
+ trade->cancel(sd);
return;
}
@@ -350,10 +350,10 @@ void trade_tradeadditem(struct map_session_data *sd, short index, short amount)
return;
item = &sd->status.inventory[index];
- src_lv = pc_get_group_level(sd);
- dst_lv = pc_get_group_level(target_sd);
+ src_lv = pc->get_group_level(sd);
+ dst_lv = pc->get_group_level(target_sd);
if( !itemdb_cantrade(item, src_lv, dst_lv) && //Can't trade
- (pc_get_partner(sd) != target_sd || !itemdb_canpartnertrade(item, src_lv, dst_lv)) ) //Can't partner-trade
+ (pc->get_partner(sd) != target_sd || !itemdb_canpartnertrade(item, src_lv, dst_lv)) ) //Can't partner-trade
{
clif->message (sd->fd, msg_txt(260));
clif->tradeitemok(sd, index+2, 1);
@@ -413,15 +413,15 @@ void trade_tradeaddzeny(struct map_session_data* sd, int amount)
if( !sd->state.trading || sd->state.deal_locked > 0 )
return; //Can't add stuff.
- if( (target_sd = map_id2sd(sd->trade_partner)) == NULL )
+ if( (target_sd = iMap->id2sd(sd->trade_partner)) == NULL )
{
- trade_tradecancel(sd);
+ trade->cancel(sd);
return;
}
if( amount < 0 || amount > sd->status.zeny || amount > MAX_ZENY - target_sd->status.zeny )
{ // invalid values, no appropriate packet for it => abort
- trade_tradecancel(sd);
+ trade->cancel(sd);
return;
}
@@ -439,8 +439,8 @@ void trade_tradeok(struct map_session_data *sd)
if(sd->state.deal_locked || !sd->state.trading)
return;
- if ((target_sd = map_id2sd(sd->trade_partner)) == NULL) {
- trade_tradecancel(sd);
+ if ((target_sd = iMap->id2sd(sd->trade_partner)) == NULL) {
+ trade->cancel(sd);
return;
}
sd->state.deal_locked = 1;
@@ -457,7 +457,7 @@ void trade_tradecancel(struct map_session_data *sd)
struct map_session_data *target_sd;
int trade_i;
- target_sd = map_id2sd(sd->trade_partner);
+ target_sd = iMap->id2sd(sd->trade_partner);
if(!sd->state.trading)
{ // Not trade acepted
@@ -520,7 +520,7 @@ void trade_tradecommit(struct map_session_data *sd)
if (!sd->state.trading || !sd->state.deal_locked) //Locked should be 1 (pressed ok) before you can press trade.
return;
- if ((tsd = map_id2sd(sd->trade_partner)) == NULL) {
+ if ((tsd = iMap->id2sd(sd->trade_partner)) == NULL) {
trade_tradecancel(sd);
return;
}
@@ -532,18 +532,18 @@ void trade_tradecommit(struct map_session_data *sd)
//Now is a good time (to save on resources) to check that the trade can indeed be made and it's not exploitable.
// check exploit (trade more items that you have)
- if (impossible_trade_check(sd)) {
- trade_tradecancel(sd);
+ if (trade->check_impossible(sd)) {
+ trade->cancel(sd);
return;
}
// check exploit (trade more items that you have)
- if (impossible_trade_check(tsd)) {
- trade_tradecancel(tsd);
+ if (trade->check_impossible(tsd)) {
+ trade->cancel(tsd);
return;
}
// check for full inventory (can not add traded items)
- if (!trade_check(sd,tsd)) { // check the both players
- trade_tradecancel(sd);
+ if (!trade->check(sd,tsd)) { // check the both players
+ trade->cancel(sd);
return;
}
@@ -555,9 +555,9 @@ void trade_tradecommit(struct map_session_data *sd)
{
n = sd->deal.item[trade_i].index;
- flag = pc_additem(tsd, &sd->status.inventory[n], sd->deal.item[trade_i].amount,LOG_TYPE_TRADE);
+ flag = pc->additem(tsd, &sd->status.inventory[n], sd->deal.item[trade_i].amount,LOG_TYPE_TRADE);
if (flag == 0)
- pc_delitem(sd, n, sd->deal.item[trade_i].amount, 1, 6, LOG_TYPE_TRADE);
+ pc->delitem(sd, n, sd->deal.item[trade_i].amount, 1, 6, LOG_TYPE_TRADE);
else
clif->additem(sd, n, sd->deal.item[trade_i].amount, 0);
sd->deal.item[trade_i].index = 0;
@@ -567,9 +567,9 @@ void trade_tradecommit(struct map_session_data *sd)
{
n = tsd->deal.item[trade_i].index;
- flag = pc_additem(sd, &tsd->status.inventory[n], tsd->deal.item[trade_i].amount,LOG_TYPE_TRADE);
+ flag = pc->additem(sd, &tsd->status.inventory[n], tsd->deal.item[trade_i].amount,LOG_TYPE_TRADE);
if (flag == 0)
- pc_delitem(tsd, n, tsd->deal.item[trade_i].amount, 1, 6, LOG_TYPE_TRADE);
+ pc->delitem(tsd, n, tsd->deal.item[trade_i].amount, 1, 6, LOG_TYPE_TRADE);
else
clif->additem(tsd, n, tsd->deal.item[trade_i].amount, 0);
tsd->deal.item[trade_i].index = 0;
@@ -578,14 +578,14 @@ void trade_tradecommit(struct map_session_data *sd)
}
if( sd->deal.zeny ) {
- pc_payzeny(sd ,sd->deal.zeny, LOG_TYPE_TRADE, tsd);
- pc_getzeny(tsd,sd->deal.zeny,LOG_TYPE_TRADE, sd);
+ pc->payzeny(sd ,sd->deal.zeny, LOG_TYPE_TRADE, tsd);
+ pc->getzeny(tsd,sd->deal.zeny,LOG_TYPE_TRADE, sd);
sd->deal.zeny = 0;
}
if ( tsd->deal.zeny) {
- pc_payzeny(tsd,tsd->deal.zeny,LOG_TYPE_TRADE, sd);
- pc_getzeny(sd ,tsd->deal.zeny,LOG_TYPE_TRADE, tsd);
+ pc->payzeny(tsd,tsd->deal.zeny,LOG_TYPE_TRADE, sd);
+ pc->getzeny(sd ,tsd->deal.zeny,LOG_TYPE_TRADE, tsd);
tsd->deal.zeny = 0;
}
@@ -601,9 +601,24 @@ void trade_tradecommit(struct map_session_data *sd)
clif->tradecompleted(tsd, 0);
// save both player to avoid crash: they always have no advantage/disadvantage between the 2 players
- if (save_settings&1)
+ if (iMap->save_settings&1)
{
chrif_save(sd,0);
chrif_save(tsd,0);
}
}
+
+void trade_defaults(void)
+{
+ trade = &trade_s;
+
+ trade->request = trade_traderequest;
+ trade->ack = trade_tradeack;
+ trade->check_impossible = impossible_trade_check;
+ trade->check = trade_check;
+ trade->additem = trade_tradeadditem;
+ trade->addzeny = trade_tradeaddzeny;
+ trade->ok = trade_tradeok;
+ trade->cancel = trade_tradecancel;
+ trade->commit = trade_tradecommit;
+} \ No newline at end of file
diff --git a/src/map/trade.h b/src/map/trade.h
index 6bb39936e..8bf918ad2 100644
--- a/src/map/trade.h
+++ b/src/map/trade.h
@@ -1,18 +1,26 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#ifndef _TRADE_H_
#define _TRADE_H_
-//#include "map.h"
struct map_session_data;
-void trade_traderequest(struct map_session_data *sd, struct map_session_data *target_sd);
-void trade_tradeack(struct map_session_data *sd,int type);
-void trade_tradeadditem(struct map_session_data *sd,short index,short amount);
-void trade_tradeaddzeny(struct map_session_data *sd,int amount);
-void trade_tradeok(struct map_session_data *sd);
-void trade_tradecancel(struct map_session_data *sd);
-void trade_tradecommit(struct map_session_data *sd);
+struct trade_interface {
+ void (*request) (struct map_session_data *sd, struct map_session_data *target_sd);
+ void (*ack) (struct map_session_data *sd,int type);
+ int (*check_impossible) (struct map_session_data *sd);
+ int (*check) (struct map_session_data *sd, struct map_session_data *tsd);
+ void (*additem) (struct map_session_data *sd,short index,short amount);
+ void (*addzeny) (struct map_session_data *sd,int amount);
+ void (*ok) (struct map_session_data *sd);
+ void (*cancel) (struct map_session_data *sd);
+ void (*commit) (struct map_session_data *sd);
+} trade_s;
+
+struct trade_interface *trade;
+
+void trade_defaults(void);
#endif /* _TRADE_H_ */
diff --git a/src/map/unit.c b/src/map/unit.c
index cbc695c4a..5e836dc2e 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -50,7 +50,7 @@ struct unit_data* unit_bl2ud(struct block_list *bl)
if( bl->type == BL_PC) return &((struct map_session_data*)bl)->ud;
if( bl->type == BL_MOB) return &((struct mob_data*)bl)->ud;
if( bl->type == BL_PET) return &((struct pet_data*)bl)->ud;
- if( bl->type == BL_NPC) return &((struct npc_data*)bl)->ud;
+ if( bl->type == BL_NPC) return ((struct npc_data*)bl)->ud;
if( bl->type == BL_HOM) return &((struct homun_data*)bl)->ud;
if( bl->type == BL_MER) return &((struct mercenary_data*)bl)->ud;
if( bl->type == BL_ELEM) return &((struct elemental_data*)bl)->ud;
@@ -108,7 +108,7 @@ int unit_walktoxy_sub(struct block_list *bl)
else
i = status_get_speed(bl);
if( i > 0)
- ud->walktimer = add_timer(gettick()+i,unit_walktoxy_timer,bl->id,i);
+ ud->walktimer = iTimer->add_timer(iTimer->gettick()+i,unit_walktoxy_timer,bl->id,i);
return 1;
}
@@ -123,7 +123,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
struct unit_data *ud;
struct mercenary_data *mrd;
- bl = map_id2bl(id);
+ bl = iMap->id2bl(id);
if(bl == NULL)
return 0;
sd = BL_CAST(BL_PC, bl);
@@ -154,29 +154,29 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
dx = dirx[(int)dir];
dy = diry[(int)dir];
- if(map_getcell(bl->m,x+dx,y+dy,CELL_CHKNOPASS))
+ if(iMap->getcell(bl->m,x+dx,y+dy,CELL_CHKNOPASS))
return unit_walktoxy_sub(bl);
//Refresh view for all those we lose sight
- map_foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl);
+ iMap->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl);
x += dx;
y += dy;
- map_moveblock(bl, x, y, tick);
+ iMap->moveblock(bl, x, y, tick);
ud->walk_count++; //walked cell counter, to be used for walk-triggered skills. [Skotlex]
status_change_end(bl, SC_ROLLINGCUTTER, INVALID_TIMER); //If you move, you lose your counters. [malufett]
if (bl->x != x || bl->y != y || ud->walktimer != INVALID_TIMER)
- return 0; //map_moveblock has altered the object beyond what we expected (moved/warped it)
+ return 0; //iMap->moveblock has altered the object beyond what we expected (moved/warped it)
ud->walktimer = -2; // arbitrary non-INVALID_TIMER value to make the clif code send walking packets
- map_foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, sd?BL_ALL:BL_PC, bl);
+ iMap->foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, sd?BL_ALL:BL_PC, bl);
ud->walktimer = INVALID_TIMER;
if(sd) {
if( sd->touching_id )
npc_touchnext_areanpc(sd,false);
- if(map_getcell(bl->m,x,y,CELL_CHKNPC)) {
+ if(iMap->getcell(bl->m,x,y,CELL_CHKNPC)) {
npc_touch_areanpc(sd,bl->m,x,y);
if (bl->prev == NULL) //Script could have warped char, abort remaining of the function.
return 0;
@@ -188,9 +188,9 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
// mercenary should be warped after being 3 seconds too far from the master [greenbox]
if (sd->md->masterteleport_timer == 0)
{
- sd->md->masterteleport_timer = gettick();
+ sd->md->masterteleport_timer = iTimer->gettick();
}
- else if (DIFF_TICK(gettick(), sd->md->masterteleport_timer) > 3000)
+ else if (DIFF_TICK(iTimer->gettick(), sd->md->masterteleport_timer) > 3000)
{
sd->md->masterteleport_timer = 0;
unit_warp( &sd->md->bl, sd->bl.m, sd->bl.x, sd->bl.y, CLR_TELEPORT );
@@ -202,7 +202,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
sd->md->masterteleport_timer = 0;
}
} else if (md) {
- if( map_getcell(bl->m,x,y,CELL_CHKNPC) ) {
+ if( iMap->getcell(bl->m,x,y,CELL_CHKNPC) ) {
if( npc_touch_areanpc2(md) ) return 0; // Warped
} else
md->areanpc_id = 0;
@@ -229,9 +229,9 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
// mercenary should be warped after being 3 seconds too far from the master [greenbox]
if (mrd->masterteleport_timer == 0)
{
- mrd->masterteleport_timer = gettick();
+ mrd->masterteleport_timer = iTimer->gettick();
}
- else if (DIFF_TICK(gettick(), mrd->masterteleport_timer) > 3000)
+ else if (DIFF_TICK(iTimer->gettick(), mrd->masterteleport_timer) > 3000)
{
mrd->masterteleport_timer = 0;
unit_warp( bl, mrd->master->bl.id, mrd->master->bl.x, mrd->master->bl.y, CLR_TELEPORT );
@@ -258,7 +258,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
i = status_get_speed(bl);
if(i > 0) {
- ud->walktimer = add_timer(tick+i,unit_walktoxy_timer,id,i);
+ ud->walktimer = iTimer->add_timer(tick+i,unit_walktoxy_timer,id,i);
if( md && DIFF_TICK(tick,md->dmgtick) < 3000 )//not required not damaged recently
clif->move(ud);
} else if(ud->state.running) {
@@ -268,7 +268,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
}
else if (ud->target_to) {
//Update target trajectory.
- struct block_list *tbl = map_id2bl(ud->target_to);
+ struct block_list *tbl = iMap->id2bl(ud->target_to);
if (!tbl || !status_check_visibility(bl, tbl)) { //Cancel chase.
ud->to_x = bl->x;
ud->to_y = bl->y;
@@ -300,7 +300,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
static int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data)
{
- struct block_list *bl = map_id2bl(id);
+ struct block_list *bl = iMap->id2bl(id);
if (!bl || bl->prev == NULL)
return 0;
@@ -327,16 +327,17 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag)
path_search(&wpd, bl->m, bl->x, bl->y, x, y, flag&1, CELL_CHKNOPASS); // Count walk path cells
#ifdef OFFICIAL_WALKPATH
if( !path_search_long(NULL, bl->m, bl->x, bl->y, x, y, CELL_CHKNOPASS) // Check if there is an obstacle between
- && wpd.path_len > 14 ) // Official number of walkable cells is 14 if and only if there is an obstacle between. [malufett]
+ && (wpd.path_len > (battle_config.max_walk_path/17)*14) // Official number of walkable cells is 14 if and only if there is an obstacle between. [malufett]
+ && (bl->type != BL_NPC) ) // If type is a NPC, please disregard.
return 0;
#endif
if( (battle_config.max_walk_path < wpd.path_len) && (bl->type != BL_NPC) )
return 0;
- if (flag&4 && DIFF_TICK(ud->canmove_tick, gettick()) > 0 &&
- DIFF_TICK(ud->canmove_tick, gettick()) < 2000)
+ if (flag&4 && DIFF_TICK(ud->canmove_tick, iTimer->gettick()) > 0 &&
+ DIFF_TICK(ud->canmove_tick, iTimer->gettick()) < 2000)
{ // Delay walking command. [Skotlex]
- add_timer(ud->canmove_tick+1, unit_delay_walktoxy_timer, bl->id, (x<<16)|(y&0xFFFF));
+ iTimer->add_timer(ud->canmove_tick+1, unit_delay_walktoxy_timer, bl->id, (x<<16)|(y&0xFFFF));
return 1;
}
@@ -350,7 +351,7 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag)
sc = status_get_sc(bl);
if (sc && sc->data[SC_CONFUSION]) //Randomize the target position
- map_random_dir(bl, &ud->to_x, &ud->to_y);
+ iMap->random_dir(bl, &ud->to_x, &ud->to_y);
if(ud->walktimer != INVALID_TIMER) {
// When you come to the center of the grid because the change of destination while you're walking right now
@@ -360,7 +361,7 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag)
}
if(ud->attacktimer != INVALID_TIMER) {
- delete_timer( ud->attacktimer, unit_attack_timer );
+ iTimer->delete_timer( ud->attacktimer, unit_attack_timer );
ud->attacktimer = INVALID_TIMER;
}
@@ -378,13 +379,13 @@ static inline void set_mobstate(struct block_list* bl, int flag)
static int unit_walktobl_sub(int tid, unsigned int tick, int id, intptr_t data)
{
- struct block_list *bl = map_id2bl(id);
+ struct block_list *bl = iMap->id2bl(id);
struct unit_data *ud = bl?unit_bl2ud(bl):NULL;
if (ud && ud->walktimer == INVALID_TIMER && ud->target == data)
{
if (DIFF_TICK(ud->canmove_tick, tick) > 0) //Keep waiting?
- add_timer(ud->canmove_tick+1, unit_walktobl_sub, id, data);
+ iTimer->add_timer(ud->canmove_tick+1, unit_walktobl_sub, id, data);
else if (unit_can_move(bl))
{
if (unit_walktoxy_sub(bl))
@@ -425,7 +426,7 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int
sc = status_get_sc(bl);
if (sc && sc->data[SC_CONFUSION]) //Randomize the target position
- map_random_dir(bl, &ud->to_x, &ud->to_y);
+ iMap->random_dir(bl, &ud->to_x, &ud->to_y);
if(ud->walktimer != INVALID_TIMER) {
ud->state.change_walk_target = 1;
@@ -433,9 +434,9 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int
return 1;
}
- if(DIFF_TICK(ud->canmove_tick, gettick()) > 0)
+ if(DIFF_TICK(ud->canmove_tick, iTimer->gettick()) > 0)
{ //Can't move, wait a bit before invoking the movement.
- add_timer(ud->canmove_tick+1, unit_walktobl_sub, bl->id, ud->target);
+ iTimer->add_timer(ud->canmove_tick+1, unit_walktobl_sub, bl->id, ud->target);
return 1;
}
@@ -443,7 +444,7 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int
return 0;
if(ud->attacktimer != INVALID_TIMER) {
- delete_timer( ud->attacktimer, unit_attack_timer );
+ iTimer->delete_timer( ud->attacktimer, unit_attack_timer );
ud->attacktimer = INVALID_TIMER;
}
@@ -478,11 +479,11 @@ int unit_run(struct block_list *bl)
to_y = bl->y;
for(i=0;i<AREA_SIZE;i++)
{
- if(!map_getcell(bl->m,to_x+dir_x,to_y+dir_y,CELL_CHKPASS))
+ if(!iMap->getcell(bl->m,to_x+dir_x,to_y+dir_y,CELL_CHKPASS))
break;
//if sprinting and there's a PC/Mob/NPC, block the path [Kevin]
- if(sc->data[SC_RUN] && map_count_oncell(bl->m, to_x+dir_x, to_y+dir_y, BL_PC|BL_MOB|BL_NPC))
+ if(sc->data[SC_RUN] && iMap->count_oncell(bl->m, to_x+dir_x, to_y+dir_y, BL_PC|BL_MOB|BL_NPC))
break;
to_x += dir_x;
@@ -491,7 +492,7 @@ int unit_run(struct block_list *bl)
if( (to_x == bl->x && to_y == bl->y ) || (to_x == (bl->x+1) || to_y == (bl->y+1)) || (to_x == (bl->x-1) || to_y == (bl->y-1))) {
//If you can't run forward, you must be next to a wall, so bounce back. [Skotlex]
- clif->sc_load(bl,bl->id,AREA,SI_BUMP,0,0,0);
+ clif->sc_load(bl,bl->id,AREA,SI_TING,0,0,0);
//Set running to 0 beforehand so status_change_end knows not to enable spurt [Kevin]
unit_bl2ud(bl)->state.running = 0;
@@ -499,7 +500,7 @@ int unit_run(struct block_list *bl)
skill->blown(bl,bl,skill->get_blewcount(TK_RUN,lv),unit_getdir(bl),0);
clif->fixpos(bl); //Why is a clif->slide (skill->blown) AND a fixpos needed? Ask Aegis.
- clif->sc_end(bl,bl->id,AREA,SI_BUMP);
+ clif->sc_end(bl,bl->id,AREA,SI_TING);
return 0;
}
if (unit_walktoxy(bl, to_x, to_y, 1))
@@ -511,7 +512,7 @@ int unit_run(struct block_list *bl)
} while (--i > 0 && !unit_walktoxy(bl, to_x, to_y, 1));
if ( i == 0 ) {
// copy-paste from above
- clif->sc_load(bl,bl->id,AREA,SI_BUMP,0,0,0);
+ clif->sc_load(bl,bl->id,AREA,SI_TING,0,0,0);
//Set running to 0 beforehand so status_change_end knows not to enable spurt [Kevin]
unit_bl2ud(bl)->state.running = 0;
@@ -519,7 +520,7 @@ int unit_run(struct block_list *bl)
skill->blown(bl,bl,skill->get_blewcount(TK_RUN,lv),unit_getdir(bl),0);
clif->fixpos(bl);
- clif->sc_end(bl,bl->id,AREA,SI_BUMP);
+ clif->sc_end(bl,bl->id,AREA,SI_TING);
return 0;
}
return 1;
@@ -550,10 +551,10 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) {
to_y = bl->y;
for(i=0;i<AREA_SIZE;i++)
{
- if(!map_getcell(bl->m,to_x+dir_x,to_y+dir_y,CELL_CHKPASS))
+ if(!iMap->getcell(bl->m,to_x+dir_x,to_y+dir_y,CELL_CHKPASS))
break;
- if(sc->data[SC_WUGDASH] && map_count_oncell(bl->m, to_x+dir_x, to_y+dir_y, BL_PC|BL_MOB|BL_NPC))
+ if(sc->data[SC_WUGDASH] && iMap->count_oncell(bl->m, to_x+dir_x, to_y+dir_y, BL_PC|BL_MOB|BL_NPC))
break;
to_x += dir_x;
@@ -567,7 +568,7 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) {
if( sd ){
clif->fixpos(bl);
- skill->castend_damage_id(bl, &sd->bl, RA_WUGDASH, lv, gettick(), SD_LEVEL);
+ skill->castend_damage_id(bl, &sd->bl, RA_WUGDASH, lv, iTimer->gettick(), SD_LEVEL);
}
return 0;
}
@@ -584,7 +585,7 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) {
if( sd ){
clif->fixpos(bl);
- skill->castend_damage_id(bl, &sd->bl, RA_WUGDASH, lv, gettick(), SD_LEVEL);
+ skill->castend_damage_id(bl, &sd->bl, RA_WUGDASH, lv, iTimer->gettick(), SD_LEVEL);
}
return 0;
}
@@ -594,8 +595,8 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) {
//Makes bl attempt to run dist cells away from target. Uses hard-paths.
int unit_escape(struct block_list *bl, struct block_list *target, short dist)
{
- uint8 dir = map_calc_dir(target, bl->x, bl->y);
- while( dist > 0 && map_getcell(bl->m, bl->x + dist*dirx[dir], bl->y + dist*diry[dir], CELL_CHKNOREACH) )
+ uint8 dir = iMap->calc_dir(target, bl->x, bl->y);
+ while( dist > 0 && iMap->getcell(bl->m, bl->x + dist*dirx[dir], bl->y + dist*diry[dir], CELL_CHKNOREACH) )
dist--;
return ( dist > 0 && unit_walktoxy(bl, bl->x + dist*dirx[dir], bl->y + dist*diry[dir], 0) );
}
@@ -617,30 +618,30 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool
unit_stop_walking(bl,1);
unit_stop_attack(bl);
- if( checkpath && (map_getcell(bl->m,dst_x,dst_y,CELL_CHKNOPASS) || !path_search(NULL,bl->m,bl->x,bl->y,dst_x,dst_y,easy,CELL_CHKNOREACH)) )
+ if( checkpath && (iMap->getcell(bl->m,dst_x,dst_y,CELL_CHKNOPASS) || !path_search(NULL,bl->m,bl->x,bl->y,dst_x,dst_y,easy,CELL_CHKNOREACH)) )
return 0; // unreachable
ud->to_x = dst_x;
ud->to_y = dst_y;
- dir = map_calc_dir(bl, dst_x, dst_y);
+ dir = iMap->calc_dir(bl, dst_x, dst_y);
ud->dir = dir;
dx = dst_x - bl->x;
dy = dst_y - bl->y;
- map_foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl);
+ iMap->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl);
- map_moveblock(bl, dst_x, dst_y, gettick());
+ iMap->moveblock(bl, dst_x, dst_y, iTimer->gettick());
ud->walktimer = -2; // arbitrary non-INVALID_TIMER value to make the clif code send walking packets
- map_foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, sd?BL_ALL:BL_PC, bl);
+ iMap->foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, sd?BL_ALL:BL_PC, bl);
ud->walktimer = INVALID_TIMER;
if(sd) {
if( sd->touching_id )
npc_touchnext_areanpc(sd,false);
- if(map_getcell(bl->m,bl->x,bl->y,CELL_CHKNPC)) {
+ if(iMap->getcell(bl->m,bl->x,bl->y,CELL_CHKNPC)) {
npc_touch_areanpc(sd,bl->m,bl->x,bl->y);
if (bl->prev == NULL) //Script could have warped char, abort remaining of the function.
return 0;
@@ -678,10 +679,12 @@ int unit_setdir(struct block_list *bl,unsigned char dir)
return 0;
}
-uint8 unit_getdir(struct block_list *bl)
-{
+uint8 unit_getdir(struct block_list *bl) {
struct unit_data *ud;
- nullpo_ret(bl );
+ nullpo_ret(bl);
+
+ if( bl->type == BL_NPC )
+ return ((TBL_NPC*)bl)->dir;
ud = unit_bl2ud(bl);
if (!ud) return 0;
return ud->dir;
@@ -719,15 +722,15 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag)
dy = ny-bl->y;
if(dx || dy) {
- map_foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl);
+ iMap->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl);
if(su) {
skill->unit_move_unit_group(su->group, bl->m, dx, dy);
} else {
- map_moveblock(bl, nx, ny, gettick());
+ iMap->moveblock(bl, nx, ny, iTimer->gettick());
}
- map_foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl);
+ iMap->foreachinmovearea(clif->insight, bl, AREA_SIZE, -dx, -dy, bl->type == BL_PC ? BL_ALL : BL_PC, bl);
if(!(flag&1)) {
clif->blown(bl);
@@ -737,7 +740,7 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag)
if(sd->touching_id) {
npc_touchnext_areanpc(sd, false);
}
- if(map_getcell(bl->m, bl->x, bl->y, CELL_CHKNPC)) {
+ if(iMap->getcell(bl->m, bl->x, bl->y, CELL_CHKNPC)) {
npc_touch_areanpc(sd, bl->m, bl->x, bl->y);
} else {
sd->areanpc_id = 0;
@@ -752,7 +755,7 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag)
}
//Warps a unit/ud to a given map/position.
-//In the case of players, pc_setpos is used.
+//In the case of players, pc->setpos is used.
//it respects the no warp flags, so it is safe to call this without doing nowarpto/nowarp checks.
int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type)
{
@@ -785,16 +788,16 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type)
if (x<0 || y<0)
{ //Random map position.
- if (!map_search_freecell(NULL, m, &x, &y, -1, -1, 1)) {
+ if (!iMap->search_freecell(NULL, m, &x, &y, -1, -1, 1)) {
ShowWarning("unit_warp failed. Unit Id:%d/Type:%d, target position map %d (%s) at [%d,%d]\n", bl->id, bl->type, m, map[m].name, x, y);
return 2;
}
- } else if (map_getcell(m,x,y,CELL_CHKNOREACH))
+ } else if (iMap->getcell(m,x,y,CELL_CHKNOREACH))
{ //Invalid target cell
ShowWarning("unit_warp: Specified non-walkable target cell: %d (%s) at [%d,%d]\n", m, map[m].name, x,y);
- if (!map_search_freecell(NULL, m, &x, &y, 4, 4, 1))
+ if (!iMap->search_freecell(NULL, m, &x, &y, 4, 4, 1))
{ //Can't find a nearby cell
ShowWarning("unit_warp failed. Unit Id:%d/Type:%d, target position map %d (%s) at [%d,%d]\n", bl->id, bl->type, m, map[m].name, x, y);
return 2;
@@ -802,7 +805,7 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type)
}
if (bl->type == BL_PC) //Use pc_setpos
- return pc_setpos((TBL_PC*)bl, map_id2index(m), x, y, type);
+ return pc->setpos((TBL_PC*)bl, map_id2index(m), x, y, type);
if (!unit_remove_map(bl, type))
return 3;
@@ -815,9 +818,9 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type)
bl->y=ud->to_y=y;
bl->m=m;
- map_addblock(bl);
+ iMap->addblock(bl);
clif->spawn(bl);
- skill->unit_move(bl,gettick(),1);
+ skill->unit_move(bl,iTimer->gettick(),1);
return 0;
}
@@ -841,13 +844,13 @@ int unit_stop_walking(struct block_list *bl,int type)
if(!ud || ud->walktimer == INVALID_TIMER)
return 0;
//NOTE: We are using timer data after deleting it because we know the
- //delete_timer function does not messes with it. If the function's
+ //iTimer->delete_timer function does not messes with it. If the function's
//behaviour changes in the future, this code could break!
- td = get_timer(ud->walktimer);
- delete_timer(ud->walktimer, unit_walktoxy_timer);
+ td = iTimer->get_timer(ud->walktimer);
+ iTimer->delete_timer(ud->walktimer, unit_walktoxy_timer);
ud->walktimer = INVALID_TIMER;
ud->state.change_walk_target = 0;
- tick = gettick();
+ tick = iTimer->gettick();
if( (type&0x02 && !ud->walkpath.path_pos) //Force moving at least one cell.
|| (type&0x04 && td && DIFF_TICK(td->tick, tick) <= td->data/2) //Enough time has passed to cover half-cell
) {
@@ -863,7 +866,7 @@ int unit_stop_walking(struct block_list *bl,int type)
ud->to_x = bl->x;
ud->to_y = bl->y;
if(bl->type == BL_PET && type&~0xff)
- ud->canmove_tick = gettick() + (type>>8);
+ ud->canmove_tick = iTimer->gettick() + (type>>8);
//Readded, the check in unit_set_walkdelay means dmg during running won't fall through to this place in code [Kevin]
if (ud->state.running) {
@@ -906,10 +909,10 @@ int unit_can_move(struct block_list *bl) {
if (!ud)
return 0;
- if (ud->skilltimer != INVALID_TIMER && ud->skill_id != LG_EXEEDBREAK && (!sd || !pc_checkskill(sd, SA_FREECAST) || skill->get_inf2(ud->skill_id)&INF2_GUILD_SKILL))
+ if (ud->skilltimer != INVALID_TIMER && ud->skill_id != LG_EXEEDBREAK && (!sd || !pc->checkskill(sd, SA_FREECAST) || skill->get_inf2(ud->skill_id)&INF2_GUILD_SKILL))
return 0; // prevent moving while casting
- if (DIFF_TICK(ud->canmove_tick, gettick()) > 0)
+ if (DIFF_TICK(ud->canmove_tick, iTimer->gettick()) > 0)
return 0;
if (sd && (
@@ -922,7 +925,7 @@ int unit_can_move(struct block_list *bl) {
if (sc) {
if( sc->count && (
- sc->data[SC_ANKLE]
+ sc->data[SC_ANKLESNARE]
|| sc->data[SC_AUTOCOUNTER]
|| sc->data[SC_TRICKDEAD]
|| sc->data[SC_BLADESTOP]
@@ -930,14 +933,14 @@ int unit_can_move(struct block_list *bl) {
|| (sc->data[SC_GOSPEL] && sc->data[SC_GOSPEL]->val4 == BCT_SELF) // cannot move while gospel is in effect
|| (sc->data[SC_BASILICA] && sc->data[SC_BASILICA]->val4 == bl->id) // Basilica caster cannot move
|| sc->data[SC_STOP]
- || sc->data[SC_CLOSECONFINE]
- || sc->data[SC_CLOSECONFINE2]
- || sc->data[SC_MADNESSCANCEL]
+ || sc->data[SC_RG_CCONFINE_M]
+ || sc->data[SC_RG_CCONFINE_S]
+ || sc->data[SC_GS_MADNESSCANCEL]
|| (sc->data[SC_GRAVITATION] && sc->data[SC_GRAVITATION]->val3 == BCT_SELF)
|| sc->data[SC_WHITEIMPRISON]
|| sc->data[SC_ELECTRICSHOCKER]
- || sc->data[SC_BITE]
- || sc->data[SC_THORNSTRAP]
+ || sc->data[SC_WUGBITE]
+ || sc->data[SC_THORNS_TRAP]
|| sc->data[SC_MAGNETICFIELD]
|| sc->data[SC__MANHOLE]
|| sc->data[SC_CURSEDCIRCLE_ATKER]
@@ -946,9 +949,9 @@ int unit_can_move(struct block_list *bl) {
|| sc->data[SC_NETHERWORLD]
|| (sc->data[SC_CAMOUFLAGE] && sc->data[SC_CAMOUFLAGE]->val1 < 3 && !(sc->data[SC_CAMOUFLAGE]->val3&1))
|| sc->data[SC_MEIKYOUSISUI]
- || sc->data[SC_KAGEHUMI]
+ || sc->data[SC_KG_KAGEHUMI]
|| sc->data[SC_KYOUGAKU]
- || sc->data[SC_PARALYSIS]
+ || sc->data[SC_NEEDLE_OF_PARALYZE]
|| sc->data[SC_VACUUM_EXTREME]
|| (sc->data[SC_FEAR] && sc->data[SC_FEAR]->val2 > 0)
|| (sc->data[SC_SPIDERWEB] && sc->data[SC_SPIDERWEB]->val1)
@@ -966,7 +969,7 @@ int unit_can_move(struct block_list *bl) {
if (sc->opt1 > 0 && sc->opt1 != OPT1_STONEWAIT && sc->opt1 != OPT1_BURNING && !(sc->opt1 == OPT1_CRYSTALIZE && bl->type == BL_MOB))
return 0;
- if ((sc->option & OPTION_HIDE) && (!sd || pc_checkskill(sd, RG_TUNNELDRIVE) <= 0))
+ if ((sc->option & OPTION_HIDE) && (!sd || pc->checkskill(sd, RG_TUNNELDRIVE) <= 0))
return 0;
}
@@ -981,7 +984,7 @@ int unit_resume_running(int tid, unsigned int tick, int id, intptr_t data)
{
struct unit_data *ud = (struct unit_data *)data;
- TBL_PC * sd = map_id2sd(id);
+ TBL_PC * sd = iMap->id2sd(id);
if(sd && pc_isridingwug(sd))
clif->skill_nodamage(ud->bl,ud->bl,RA_WUGDASH,ud->skill_lv,
@@ -1031,13 +1034,13 @@ int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int
//Resume running after can move again [Kevin]
if(ud->state.running)
{
- add_timer(ud->canmove_tick, unit_resume_running, bl->id, (intptr_t)ud);
+ iTimer->add_timer(ud->canmove_tick, unit_resume_running, bl->id, (intptr_t)ud);
}
else
{
unit_stop_walking(bl,2|4);
if(ud->target)
- add_timer(ud->canmove_tick+1, unit_walktobl_sub, bl->id, ud->target);
+ iTimer->add_timer(ud->canmove_tick+1, unit_walktobl_sub, bl->id, ud->target);
}
}
}
@@ -1051,7 +1054,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
struct status_change *sc;
struct map_session_data *sd = NULL;
struct block_list * target = NULL;
- unsigned int tick = gettick();
+ unsigned int tick = iTimer->gettick();
int temp = 0, range;
nullpo_ret(src);
@@ -1067,10 +1070,10 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
sc = NULL; //Unneeded
//temp: used to signal combo-skills right now.
- if (sc && sc->data[SC_COMBO] && (sc->data[SC_COMBO]->val1 == skill_id ||
+ if (sc && sc->data[SC_COMBOATTACK] && (sc->data[SC_COMBOATTACK]->val1 == skill_id ||
(sd?skill->check_condition_castbegin(sd,skill_id,skill_lv):0) )) {
- if (sc->data[SC_COMBO]->val2)
- target_id = sc->data[SC_COMBO]->val2;
+ if (sc->data[SC_COMBOATTACK]->val2)
+ target_id = sc->data[SC_COMBOATTACK]->val2;
else
target_id = ud->target;
@@ -1093,7 +1096,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
switch(skill_id) { //Check for skills that auto-select target
case MO_CHAINCOMBO:
if (sc && sc->data[SC_BLADESTOP]){
- if ((target=map_id2bl(sc->data[SC_BLADESTOP]->val4)) == NULL)
+ if ((target=iMap->id2bl(sc->data[SC_BLADESTOP]->val4)) == NULL)
return 0;
}
break;
@@ -1101,7 +1104,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
case WE_FEMALE:
if (!sd->status.partner_id)
return 0;
- target = (struct block_list*)map_charid2sd(sd->status.partner_id);
+ target = (struct block_list*)iMap->charid2sd(sd->status.partner_id);
if (!target) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 0;
@@ -1124,7 +1127,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
}
if( !target ) // choose default target
- target = map_id2bl(target_id);
+ target = iMap->id2bl(target_id);
if( !target || src->m != target->m || !src->prev || !target->prev )
return 0;
@@ -1160,7 +1163,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
break;
case BD_ENCORE:
//Prevent using the dance skill if you no longer have the skill in your tree.
- if(!sd->skill_id_dance || pc_checkskill(sd,sd->skill_id_dance)<=0){
+ if(!sd->skill_id_dance || pc->checkskill(sd,sd->skill_id_dance)<=0){
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 0;
}
@@ -1238,17 +1241,17 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
casttime += casttime * min(skill_lv, sd->spiritball);
break;
case MO_EXTREMITYFIST:
- if (sc && sc->data[SC_COMBO] &&
- (sc->data[SC_COMBO]->val1 == MO_COMBOFINISH ||
- sc->data[SC_COMBO]->val1 == CH_TIGERFIST ||
- sc->data[SC_COMBO]->val1 == CH_CHAINCRUSH))
+ if (sc && sc->data[SC_COMBOATTACK] &&
+ (sc->data[SC_COMBOATTACK]->val1 == MO_COMBOFINISH ||
+ sc->data[SC_COMBOATTACK]->val1 == CH_TIGERFIST ||
+ sc->data[SC_COMBOATTACK]->val1 == CH_CHAINCRUSH))
casttime = -1;
temp = 1;
break;
case SR_GATEOFHELL:
case SR_TIGERCANNON:
- if (sc && sc->data[SC_COMBO] &&
- sc->data[SC_COMBO]->val1 == SR_FALLENEMPIRE)
+ if (sc && sc->data[SC_COMBOATTACK] &&
+ sc->data[SC_COMBOATTACK]->val1 == SR_FALLENEMPIRE)
casttime = -1;
temp = 1;
break;
@@ -1275,7 +1278,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
}
break;
case GD_EMERGENCYCALL: //Emergency Call double cast when the user has learned Leap [Daegaladh]
- if( sd && pc_checkskill(sd,TK_HIGHJUMP) )
+ if( sd && pc->checkskill(sd,TK_HIGHJUMP) )
casttime *= 2;
break;
case RA_WUGDASH:
@@ -1315,10 +1318,11 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
if(!ud->state.running) //need TK_RUN or WUGDASH handler to be done before that, see bugreport:6026
unit_stop_walking(src,1);// eventhough this is not how official works but this will do the trick. bugreport:6829
+
// in official this is triggered even if no cast time.
clif->skillcasting(src, src->id, target_id, 0,0, skill_id, skill->get_ele(skill_id, skill_lv), casttime);
if( casttime > 0 || temp )
- {
+ {
if (sd && target->type == BL_MOB)
{
TBL_MOB *md = (TBL_MOB*)target;
@@ -1383,8 +1387,8 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
if( casttime > 0 ) {
- ud->skilltimer = add_timer( tick+casttime, skill->castend_id, src->id, 0 );
- if( sd && (pc_checkskill(sd,SA_FREECAST) > 0 || skill_id == LG_EXEEDBREAK) )
+ ud->skilltimer = iTimer->add_timer( tick+casttime, skill->castend_id, src->id, 0 );
+ if( sd && (pc->checkskill(sd,SA_FREECAST) > 0 || skill_id == LG_EXEEDBREAK) )
status_calc_bl(&sd->bl, SCB_SPEED);
} else
skill->castend_id(ud->skilltimer,tick,src->id,0);
@@ -1407,7 +1411,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui
struct unit_data *ud = NULL;
struct status_change *sc;
struct block_list bl;
- unsigned int tick = gettick();
+ unsigned int tick = iTimer->gettick();
int range;
nullpo_ret(src);
@@ -1434,7 +1438,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui
* "WHY IS IT HEREE": pneuma cannot be cancelled past this point, the client displays the animation even,
* if we cancel it from nodamage_id, so it has to be here for it to not display the animation.
**/
- if( skill_id == AL_PNEUMA && map_getcell(src->m, skill_x, skill_y, CELL_CHKLANDPROTECTOR) ) {
+ if( skill_id == AL_PNEUMA && iMap->getcell(src->m, skill_x, skill_y, CELL_CHKLANDPROTECTOR) ) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 0;
}
@@ -1443,7 +1447,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui
if (!status_check_skilluse(src, NULL, skill_id, 0))
return 0;
- if( map_getcell(src->m, skill_x, skill_y, CELL_CHKWALL) )
+ if( iMap->getcell(src->m, skill_x, skill_y, CELL_CHKWALL) )
{// can't cast ground targeted spells on wall cells
if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 0;
@@ -1514,9 +1518,9 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui
// in official this is triggered even if no cast time.
clif->skillcasting(src, src->id, 0, skill_x, skill_y, skill_id, skill->get_ele(skill_id, skill_lv), casttime);
if( casttime > 0 ) {
- ud->skilltimer = add_timer( tick+casttime, skill->castend_pos, src->id, 0 );
- if( (sd && pc_checkskill(sd,SA_FREECAST) > 0) || skill_id == LG_EXEEDBREAK)
- status_calc_bl(&sd->bl, SCB_SPEED);
+ ud->skilltimer = iTimer->add_timer( tick+casttime, skill->castend_pos, src->id, 0 );
+ if( (sd && pc->checkskill(sd,SA_FREECAST) > 0) || skill_id == LG_EXEEDBREAK)
+ status_calc_bl(&sd->bl, SCB_SPEED);
} else {
ud->skilltimer = INVALID_TIMER;
skill->castend_pos(ud->skilltimer,tick,src->id,0);
@@ -1535,9 +1539,9 @@ int unit_set_target(struct unit_data* ud, int target_id)
nullpo_ret(ud);
if( ud->target != target_id ) {
- if( ud->target && (target = map_id2bl(ud->target)) && (ux = unit_bl2ud(target)) && ux->target_count > 0 )
+ if( ud->target && (target = iMap->id2bl(ud->target)) && (ux = unit_bl2ud(target)) && ux->target_count > 0 )
ux->target_count --;
- if( target_id && (target = map_id2bl(target_id)) && (ux = unit_bl2ud(target)) )
+ if( target_id && (target = iMap->id2bl(target_id)) && (ux = unit_bl2ud(target)) )
ux->target_count ++;
}
@@ -1553,7 +1557,7 @@ int unit_stop_attack(struct block_list *bl)
if(!ud || ud->attacktimer == INVALID_TIMER)
return 0;
- delete_timer( ud->attacktimer, unit_attack_timer );
+ iTimer->delete_timer( ud->attacktimer, unit_attack_timer );
ud->attacktimer = INVALID_TIMER;
unit_set_target(ud, 0);
return 0;
@@ -1569,7 +1573,7 @@ int unit_unattackable(struct block_list *bl)
}
if(bl->type == BL_MOB)
- mob_unlocktarget((struct mob_data*)bl, gettick()) ;
+ mob_unlocktarget((struct mob_data*)bl, iTimer->gettick()) ;
else if(bl->type == BL_PET)
pet_unlocktarget((struct pet_data*)bl);
return 0;
@@ -1586,7 +1590,7 @@ int unit_attack(struct block_list *src,int target_id,int continuous)
nullpo_ret(ud = unit_bl2ud(src));
- target = map_id2bl(target_id);
+ target = iMap->id2bl(target_id);
if( target==NULL || status_isdead(target) ) {
unit_unattackable(src);
return 1;
@@ -1621,11 +1625,11 @@ int unit_attack(struct block_list *src,int target_id,int continuous)
if(src->type == BL_MOB)
((TBL_MOB*)src)->state.skillstate = ((TBL_MOB*)src)->state.aggressive?MSS_ANGRY:MSS_BERSERK;
- if(DIFF_TICK(ud->attackabletime, gettick()) > 0)
+ if(DIFF_TICK(ud->attackabletime, iTimer->gettick()) > 0)
//Do attack next time it is possible. [Skotlex]
- ud->attacktimer=add_timer(ud->attackabletime,unit_attack_timer,src->id,0);
+ ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit_attack_timer,src->id,0);
else //Attack NOW.
- unit_attack_timer(INVALID_TIMER, gettick(), src->id, 0);
+ unit_attack_timer(INVALID_TIMER, iTimer->gettick(), src->id, 0);
return 0;
}
@@ -1636,19 +1640,19 @@ int unit_cancel_combo(struct block_list *bl)
{
struct unit_data *ud;
- if (!status_change_end(bl, SC_COMBO, INVALID_TIMER))
+ if (!status_change_end(bl, SC_COMBOATTACK, INVALID_TIMER))
return 0; //Combo wasn't active.
ud = unit_bl2ud(bl);
nullpo_ret(ud);
- ud->attackabletime = gettick() + status_get_amotion(bl);
+ ud->attackabletime = iTimer->gettick() + status_get_amotion(bl);
if (ud->attacktimer == INVALID_TIMER)
return 1; //Nothing more to do.
- delete_timer(ud->attacktimer, unit_attack_timer);
- ud->attacktimer=add_timer(ud->attackabletime,unit_attack_timer,bl->id,0);
+ iTimer->delete_timer(ud->attacktimer, unit_attack_timer);
+ ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit_attack_timer,bl->id,0);
return 1;
}
/*==========================================
@@ -1689,9 +1693,9 @@ bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range,
dx=(dx>0)?1:((dx<0)?-1:0);
dy=(dy>0)?1:((dy<0)?-1:0);
- if (map_getcell(tbl->m,tbl->x-dx,tbl->y-dy,CELL_CHKNOPASS))
+ if (iMap->getcell(tbl->m,tbl->x-dx,tbl->y-dy,CELL_CHKNOPASS))
{ //Look for a suitable cell to place in.
- for(i=0;i<9 && map_getcell(tbl->m,tbl->x-dirx[i],tbl->y-diry[i],CELL_CHKNOPASS);i++);
+ for(i=0;i<9 && iMap->getcell(tbl->m,tbl->x-dirx[i],tbl->y-diry[i],CELL_CHKNOPASS);i++);
if (i==9) return false; //No valid cells.
dx = dirx[i];
dy = diry[i];
@@ -1782,7 +1786,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t
sd = BL_CAST(BL_PC, src);
md = BL_CAST(BL_MOB, src);
ud->attacktimer = INVALID_TIMER;
- target=map_id2bl(ud->target);
+ target=iMap->id2bl(ud->target);
if( src == NULL || src->prev == NULL || target==NULL || target->prev == NULL )
return 0;
@@ -1802,10 +1806,10 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t
return 0;
}
- if( ud->skilltimer != INVALID_TIMER && !(sd && pc_checkskill(sd,SA_FREECAST) > 0) )
+ if( ud->skilltimer != INVALID_TIMER && !(sd && pc->checkskill(sd,SA_FREECAST) > 0) )
return 0; // can't attack while casting
- if( !battle_config.sdelay_attack_enable && DIFF_TICK(ud->canact_tick,tick) > 0 && !(sd && pc_checkskill(sd,SA_FREECAST) > 0) )
+ if( !battle_config.sdelay_attack_enable && DIFF_TICK(ud->canact_tick,tick) > 0 && !(sd && pc->checkskill(sd,SA_FREECAST) > 0) )
{ // attacking when under cast delay has restrictions:
if( tid == INVALID_TIMER )
{ //requested attack.
@@ -1817,7 +1821,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t
{
if( DIFF_TICK(ud->canact_tick, ud->attackabletime) > 0 )
ud->attackabletime = ud->canact_tick;
- ud->attacktimer=add_timer(ud->attackabletime,unit_attack_timer,src->id,0);
+ ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit_attack_timer,src->id,0);
}
return 1;
}
@@ -1849,7 +1853,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t
if( DIFF_TICK(ud->attackabletime,tick) <= 0 )
{
if (battle_config.attack_direction_change && (src->type&battle_config.attack_direction_change)) {
- ud->dir = map_calc_dir(src, target->x,target->y );
+ ud->dir = iMap->calc_dir(src, target->x,target->y );
}
if(ud->walktimer != INVALID_TIMER)
unit_stop_walking(src,1);
@@ -1859,18 +1863,18 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t
if (sstatus->mode&MD_ASSIST && DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME)
{ // Link monsters nearby [Skotlex]
md->last_linktime = tick;
- map_foreachinrange(mob_linksearch, src, md->db->range2, BL_MOB, md->class_, target, tick);
+ iMap->foreachinrange(mob_linksearch, src, md->db->range2, BL_MOB, md->class_, target, tick);
}
}
if(src->type == BL_PET && pet_attackskill((TBL_PET*)src, target->id))
return 1;
- map_freeblock_lock();
+ iMap->freeblock_lock();
ud->attacktarget_lv = battle->weapon_attack(src,target,tick,0);
if(sd && sd->status.pet_id > 0 && sd->pd && battle_config.pet_attack_support)
pet_target_check(sd,target,0);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
/**
* Applied when you're unable to attack (e.g. out of ammo)
* We should stop here otherwise timer keeps on and this happens endlessly
@@ -1885,7 +1889,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t
}
if(ud->state.attack_continue)
- ud->attacktimer = add_timer(ud->attackabletime,unit_attack_timer,src->id,0);
+ ud->attacktimer = iTimer->add_timer(ud->attackabletime,unit_attack_timer,src->id,0);
return 1;
}
@@ -1893,7 +1897,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t
static int unit_attack_timer(int tid, unsigned int tick, int id, intptr_t data)
{
struct block_list *bl;
- bl = map_id2bl(id);
+ bl = iMap->id2bl(id);
if(bl && unit_attack_timer_sub(bl, tid, tick) == 0)
unit_unattackable(bl);
return 0;
@@ -1908,7 +1912,7 @@ int unit_skillcastcancel(struct block_list *bl,int type)
{
struct map_session_data *sd = NULL;
struct unit_data *ud = unit_bl2ud( bl);
- unsigned int tick=gettick();
+ unsigned int tick=iTimer->gettick();
int ret=0, skill_id;
nullpo_ret(bl);
@@ -1923,7 +1927,7 @@ int unit_skillcastcancel(struct block_list *bl,int type)
return 0;
if (sd && (sd->special_state.no_castcancel2 ||
- ((sd->sc.data[SC_UNLIMITEDHUMMINGVOICE] || sd->special_state.no_castcancel) && !map_flag_gvg(bl->m) && !map[bl->m].flag.battleground))) //fixed flags being read the wrong way around [blackhole89]
+ ((sd->sc.data[SC_UNLIMITED_HUMMING_VOICE] || sd->special_state.no_castcancel) && !map_flag_gvg(bl->m) && !map[bl->m].flag.battleground))) //fixed flags being read the wrong way around [blackhole89]
return 0;
}
@@ -1935,15 +1939,15 @@ int unit_skillcastcancel(struct block_list *bl,int type)
skill_id = ud->skill_id;
if (skill->get_inf(skill_id) & INF_GROUND_SKILL)
- ret = delete_timer( ud->skilltimer, skill->castend_pos );
+ ret = iTimer->delete_timer( ud->skilltimer, skill->castend_pos );
else
- ret = delete_timer( ud->skilltimer, skill->castend_id );
+ ret = iTimer->delete_timer( ud->skilltimer, skill->castend_id );
if( ret < 0 )
ShowError("delete timer error : skill_id : %d\n",ret);
ud->skilltimer = INVALID_TIMER;
- if( sd && pc_checkskill(sd,SA_FREECAST) > 0 )
+ if( sd && pc->checkskill(sd,SA_FREECAST) > 0 )
status_calc_bl(&sd->bl, SCB_SPEED);
if( sd ) {
@@ -1961,8 +1965,7 @@ int unit_skillcastcancel(struct block_list *bl,int type)
}
// unit_data initialization process
-void unit_dataset(struct block_list *bl)
-{
+void unit_dataset(struct block_list *bl) {
struct unit_data *ud;
nullpo_retv(ud = unit_bl2ud(bl));
@@ -1973,7 +1976,7 @@ void unit_dataset(struct block_list *bl)
ud->attacktimer = INVALID_TIMER;
ud->attackabletime =
ud->canact_tick =
- ud->canmove_tick = gettick();
+ ud->canmove_tick = iTimer->gettick();
}
/*==========================================
@@ -2036,7 +2039,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
if(bl->prev == NULL)
return 0; //Already removed?
- map_freeblock_lock();
+ iMap->freeblock_lock();
unit_set_target(ud, 0);
@@ -2048,21 +2051,21 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
unit_skillcastcancel(bl,0);
// Do not reset can-act delay. [Skotlex]
- ud->attackabletime = ud->canmove_tick /*= ud->canact_tick*/ = gettick();
+ ud->attackabletime = ud->canmove_tick /*= ud->canact_tick*/ = iTimer->gettick();
if(sc && sc->count ) { //map-change/warp dispells.
status_change_end(bl, SC_BLADESTOP, INVALID_TIMER);
status_change_end(bl, SC_BASILICA, INVALID_TIMER);
- status_change_end(bl, SC_ANKLE, INVALID_TIMER);
+ status_change_end(bl, SC_ANKLESNARE, INVALID_TIMER);
status_change_end(bl, SC_TRICKDEAD, INVALID_TIMER);
status_change_end(bl, SC_BLADESTOP_WAIT, INVALID_TIMER);
status_change_end(bl, SC_RUN, INVALID_TIMER);
status_change_end(bl, SC_DANCING, INVALID_TIMER);
status_change_end(bl, SC_WARM, INVALID_TIMER);
status_change_end(bl, SC_DEVOTION, INVALID_TIMER);
+ status_change_end(bl, SC_MARIONETTE_MASTER, INVALID_TIMER);
status_change_end(bl, SC_MARIONETTE, INVALID_TIMER);
- status_change_end(bl, SC_MARIONETTE2, INVALID_TIMER);
- status_change_end(bl, SC_CLOSECONFINE, INVALID_TIMER);
- status_change_end(bl, SC_CLOSECONFINE2, INVALID_TIMER);
+ status_change_end(bl, SC_RG_CCONFINE_M, INVALID_TIMER);
+ status_change_end(bl, SC_RG_CCONFINE_S, INVALID_TIMER);
status_change_end(bl, SC_HIDING, INVALID_TIMER);
// Ensure the bl is a PC; if so, we'll handle the removal of cloaking and cloaking exceed later
if ( bl->type != BL_PC )
@@ -2073,7 +2076,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
status_change_end(bl, SC_CHASEWALK, INVALID_TIMER);
if (sc->data[SC_GOSPEL] && sc->data[SC_GOSPEL]->val4 == BCT_SELF)
status_change_end(bl, SC_GOSPEL, INVALID_TIMER);
- status_change_end(bl, SC_CHANGE, INVALID_TIMER);
+ status_change_end(bl, SC_HLIF_CHANGE, INVALID_TIMER);
status_change_end(bl, SC_STOP, INVALID_TIMER);
status_change_end(bl, SC_WUGDASH, INVALID_TIMER);
status_change_end(bl, SC_CAMOUFLAGE, INVALID_TIMER);
@@ -2084,7 +2087,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
}
if (bl->type&(BL_CHAR|BL_PET)) {
- skill->unit_move(bl,gettick(),4);
+ skill->unit_move(bl,iTimer->gettick(),4);
skill->cleartimerskill(bl);
}
@@ -2093,7 +2096,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
struct map_session_data *sd = (struct map_session_data*)bl;
if(sd->shadowform_id){
- struct block_list *d_bl = map_id2bl(sd->shadowform_id);
+ struct block_list *d_bl = iMap->id2bl(sd->shadowform_id);
if( d_bl )
status_change_end(d_bl,SC__SHADOWFORM,INVALID_TIMER);
}
@@ -2101,16 +2104,16 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
if(sd->chatID)
chat_leavechat(sd,0);
if(sd->trade_partner)
- trade_tradecancel(sd);
+ trade->cancel(sd);
buyingstore->close(sd);
searchstore->close(sd);
if(sd->state.storage_flag == 1)
- storage_storage_quit(sd,0);
+ storage->pc_quit(sd,0);
else if (sd->state.storage_flag == 2)
- storage_guild_storage_quit(sd,0);
+ gstorage->pc_quit(sd,0);
sd->state.storage_flag = 0; //Force close it when being warped.
if(sd->party_invite>0)
- party_reply_invite(sd,sd->party_invite,0);
+ party->reply_invite(sd,sd->party_invite,0);
if(sd->guild_invite>0)
guild->reply_invite(sd,sd->guild_invite,0);
if(sd->guild_alliance>0)
@@ -2121,8 +2124,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
npc_touchnext_areanpc(sd,true);
// Check if warping and not changing the map.
- if ( sd->state.warping && !sd->state.changemap )
- {
+ if ( sd->state.warping && !sd->state.changemap ) {
status_change_end(bl, SC_CLOAKING, INVALID_TIMER);
status_change_end(bl, SC_CLOAKINGEXCEED, INVALID_TIMER);
}
@@ -2131,7 +2133,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
sd->adopt_invite = 0;
if(sd->pvp_timer != INVALID_TIMER) {
- delete_timer(sd->pvp_timer,pc_calc_pvprank_timer);
+ iTimer->delete_timer(sd->pvp_timer,pc->calc_pvprank_timer);
sd->pvp_timer = INVALID_TIMER;
sd->pvp_rank = 0;
}
@@ -2139,10 +2141,10 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
duel_leave(sd->duel_group, sd);
if(pc_issit(sd)) {
- pc_setstand(sd);
+ pc->setstand(sd);
skill->sit(sd,0);
}
- party_send_dot_remove(sd);//minimap dot fix [Kevin]
+ party->send_dot_remove(sd);//minimap dot fix [Kevin]
guild->send_dot_remove(sd);
bg_send_dot_remove(sd);
@@ -2163,18 +2165,15 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
sd->state.active, sd->state.connect_new, sd->state.rewarp, sd->state.changemap, sd->state.debug_remove_map,
map[bl->m].name, map[bl->m].users,
sd->debug_file, sd->debug_line, sd->debug_func, file, line, func);
- }
- else
- if (--map[bl->m].users == 0 && battle_config.dynamic_mobs) //[Skotlex]
- map_removemobs(bl->m);
+ } else if (--map[bl->m].users == 0 && battle_config.dynamic_mobs) //[Skotlex]
+ iMap->removemobs(bl->m);
if( !(sd->sc.option&OPTION_INVISIBLE) )
{// decrement the number of active pvp players on the map
--map[bl->m].users_pvp;
}
- if( map[bl->m].instance_id )
- {
- instance[map[bl->m].instance_id].users--;
- instance_check_idle(map[bl->m].instance_id);
+ if( map[bl->m].instance_id >= 0 ) {
+ instances[map[bl->m].instance_id].users--;
+ instance->check_idle(map[bl->m].instance_id);
}
sd->state.debug_remove_map = 1; // temporary state to track double remove_map's [FlavioJS]
sd->debug_file = file;
@@ -2199,9 +2198,9 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
if( pd->pet.intimate <= 0 && !(pd->msd && !pd->msd->state.active) )
{ //If logging out, this is deleted on unit_free
clif->clearunit_area(bl,clrtype);
- map_delblock(bl);
+ iMap->delblock(bl);
unit_free(bl,CLR_OUTSIGHT);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
@@ -2214,9 +2213,9 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
{ //If logging out, this is deleted on unit_free
clif->emotion(bl, E_SOB);
clif->clearunit_area(bl,clrtype);
- map_delblock(bl);
+ iMap->delblock(bl);
unit_free(bl,CLR_OUTSIGHT);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
break;
@@ -2227,9 +2226,9 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
if( mercenary_get_lifetime(md) <= 0 && !(md->master && !md->master->state.active) )
{
clif->clearunit_area(bl,clrtype);
- map_delblock(bl);
+ iMap->delblock(bl);
unit_free(bl,CLR_OUTSIGHT);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
break;
@@ -2240,9 +2239,9 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
if( elemental_get_lifetime(ed) <= 0 && !(ed->master && !ed->master->state.active) )
{
clif->clearunit_area(bl,clrtype);
- map_delblock(bl);
+ iMap->delblock(bl);
unit_free(bl,0);
- map_freeblock_unlock();
+ iMap->freeblock_unlock();
return 0;
}
break;
@@ -2254,8 +2253,8 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
**/
if( bl->type != BL_MOB || !status_isdead(bl) )
clif->clearunit_area(bl,clrtype);
- map_delblock(bl);
- map_freeblock_unlock();
+ iMap->delblock(bl);
+ iMap->freeblock_unlock();
return 1;
}
@@ -2293,7 +2292,7 @@ int unit_free(struct block_list *bl, clr_type clrtype)
struct unit_data *ud = unit_bl2ud( bl );
nullpo_ret(ud);
- map_freeblock_lock();
+ iMap->freeblock_lock();
if( bl->prev ) //Players are supposed to logout with a "warp" effect.
unit_remove_map(bl, clrtype);
@@ -2304,28 +2303,28 @@ int unit_free(struct block_list *bl, clr_type clrtype)
int i;
if( status_isdead(bl) )
- pc_setrestartvalue(sd,2);
+ pc->setrestartvalue(sd,2);
- pc_delinvincibletimer(sd);
- pc_delautobonus(sd,sd->autobonus,ARRAYLENGTH(sd->autobonus),false);
- pc_delautobonus(sd,sd->autobonus2,ARRAYLENGTH(sd->autobonus2),false);
- pc_delautobonus(sd,sd->autobonus3,ARRAYLENGTH(sd->autobonus3),false);
+ pc->delinvincibletimer(sd);
+ pc->delautobonus(sd,sd->autobonus,ARRAYLENGTH(sd->autobonus),false);
+ pc->delautobonus(sd,sd->autobonus2,ARRAYLENGTH(sd->autobonus2),false);
+ pc->delautobonus(sd,sd->autobonus3,ARRAYLENGTH(sd->autobonus3),false);
if( sd->followtimer != INVALID_TIMER )
- pc_stop_following(sd);
+ pc->stop_following(sd);
if( sd->duel_invite > 0 )
duel_reject(sd->duel_invite, sd);
// Notify friends that this char logged out. [Skotlex]
- map_foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 0);
- party_send_logout(sd);
+ iMap->map_foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 0);
+ party->send_logout(sd);
guild->send_memberinfoshort(sd,0);
- pc_cleareventtimer(sd);
- pc_inventory_rental_clear(sd);
- pc_delspiritball(sd,sd->spiritball,1);
+ pc->cleareventtimer(sd);
+ pc->inventory_rental_clear(sd);
+ pc->delspiritball(sd,sd->spiritball,1);
for(i = 1; i < 5; i++)
- pc_del_talisman(sd, sd->talisman[i], i);
+ pc->del_charm(sd, sd->charm[i], i);
if( sd->reg ) { //Double logout already freed pointer fix... [Skotlex]
aFree(sd->reg);
@@ -2356,9 +2355,19 @@ int unit_free(struct block_list *bl, clr_type clrtype)
ers_free(pc_sc_display_ers, sd->sc_display[i]);
}
sd->sc_display_count = 0;
+ }
+ if( sd->sc_display != NULL ) {
aFree(sd->sc_display);
sd->sc_display = NULL;
}
+ if( sd->instance != NULL ) {
+ aFree(sd->instance);
+ sd->instance = NULL;
+ }
+ if( sd->queues != NULL ) {
+ aFree(sd->queues);
+ sd->queues = NULL;
+ }
break;
}
case BL_PET:
@@ -2375,9 +2384,9 @@ int unit_free(struct block_list *bl, clr_type clrtype)
{
if (pd->s_skill->timer != INVALID_TIMER) {
if (pd->s_skill->id)
- delete_timer(pd->s_skill->timer, pet_skill_support_timer);
+ iTimer->delete_timer(pd->s_skill->timer, pet_skill_support_timer);
else
- delete_timer(pd->s_skill->timer, pet_heal_timer);
+ iTimer->delete_timer(pd->s_skill->timer, pet_heal_timer);
}
aFree(pd->s_skill);
pd->s_skill = NULL;
@@ -2385,14 +2394,14 @@ int unit_free(struct block_list *bl, clr_type clrtype)
if( pd->recovery )
{
if(pd->recovery->timer != INVALID_TIMER)
- delete_timer(pd->recovery->timer, pet_recovery_timer);
+ iTimer->delete_timer(pd->recovery->timer, pet_recovery_timer);
aFree(pd->recovery);
pd->recovery = NULL;
}
if( pd->bonus )
{
if (pd->bonus->timer != INVALID_TIMER)
- delete_timer(pd->bonus->timer, pet_skill_bonus_timer);
+ iTimer->delete_timer(pd->bonus->timer, pet_skill_bonus_timer);
aFree(pd->bonus);
pd->bonus = NULL;
}
@@ -2420,12 +2429,12 @@ int unit_free(struct block_list *bl, clr_type clrtype)
struct mob_data *md = (struct mob_data*)bl;
if( md->spawn_timer != INVALID_TIMER )
{
- delete_timer(md->spawn_timer,mob_delayspawn);
+ iTimer->delete_timer(md->spawn_timer,mob_delayspawn);
md->spawn_timer = INVALID_TIMER;
}
if( md->deletetimer != INVALID_TIMER )
{
- delete_timer(md->deletetimer,mob_timer_delete);
+ iTimer->delete_timer(md->deletetimer,mob_timer_delete);
md->deletetimer = INVALID_TIMER;
}
if( md->lootitem )
@@ -2527,19 +2536,19 @@ int unit_free(struct block_list *bl, clr_type clrtype)
skill->clear_unitgroup(bl);
status_change_clear(bl,1);
- map_deliddb(bl);
+ iMap->deliddb(bl);
if( bl->type != BL_PC ) //Players are handled by map_quit
- map_freeblock(bl);
- map_freeblock_unlock();
+ iMap->freeblock(bl);
+ iMap->freeblock_unlock();
return 0;
}
int do_init_unit(void)
{
- add_timer_func_list(unit_attack_timer, "unit_attack_timer");
- add_timer_func_list(unit_walktoxy_timer,"unit_walktoxy_timer");
- add_timer_func_list(unit_walktobl_sub, "unit_walktobl_sub");
- add_timer_func_list(unit_delay_walktoxy_timer,"unit_delay_walktoxy_timer");
+ iTimer->add_timer_func_list(unit_attack_timer, "unit_attack_timer");
+ iTimer->add_timer_func_list(unit_walktoxy_timer,"unit_walktoxy_timer");
+ iTimer->add_timer_func_list(unit_walktobl_sub, "unit_walktobl_sub");
+ iTimer->add_timer_func_list(unit_delay_walktoxy_timer,"unit_delay_walktoxy_timer");
return 0;
}
diff --git a/src/map/vending.c b/src/map/vending.c
index 1576b684e..b9575c8dd 100644
--- a/src/map/vending.c
+++ b/src/map/vending.c
@@ -46,12 +46,12 @@ void vending_vendinglistreq(struct map_session_data* sd, unsigned int id) {
struct map_session_data* vsd;
nullpo_retv(sd);
- if( (vsd = map_id2sd(id)) == NULL )
+ if( (vsd = iMap->id2sd(id)) == NULL )
return;
if( !vsd->state.vending )
return; // not vending
- if (!pc_can_give_items(sd) || !pc_can_give_items(vsd)) { //check if both GMs are allowed to trade
+ if (!pc->can_give_items(sd) || !pc->can_give_items(vsd)) { //check if both GMs are allowed to trade
// GM is not allowed to trade
clif->message(sd->fd, msg_txt(246));
return;
@@ -69,7 +69,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid,
int i, j, cursor, w, new_ = 0, blank, vend_list[MAX_VENDING];
double z;
struct s_vending vend[MAX_VENDING]; // against duplicate packets
- struct map_session_data* vsd = map_id2sd(aid);
+ struct map_session_data* vsd = iMap->id2sd(aid);
nullpo_retv(sd);
if( vsd == NULL || !vsd->state.vending || vsd->bl.id == sd->bl.id )
@@ -88,7 +88,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid,
if( count < 1 || count > MAX_VENDING || count > vsd->vend_num )
return; // invalid amount of purchased items
- blank = pc_inventoryblank(sd); //number of free cells in the buyer's inventory
+ blank = pc->inventoryblank(sd); //number of free cells in the buyer's inventory
// duplicate item in vending to check hacker with multiple packets
memcpy(&vend, &vsd->vending, sizeof(vsd->vending)); // copy vending list
@@ -144,7 +144,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid,
vend[j].amount -= amount;
- switch( pc_checkadditem(sd, vsd->status.cart[idx].nameid, amount) ) {
+ switch( pc->checkadditem(sd, vsd->status.cart[idx].nameid, amount) ) {
case ADDITEM_EXIST:
break; //We'd add this item to the existing one (in buyers inventory)
case ADDITEM_NEW:
@@ -157,10 +157,10 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid,
}
}
- pc_payzeny(sd, (int)z, LOG_TYPE_VENDING, vsd);
+ pc->payzeny(sd, (int)z, LOG_TYPE_VENDING, vsd);
if( battle_config.vending_tax )
z -= z * (battle_config.vending_tax/10000.);
- pc_getzeny(vsd, (int)z, LOG_TYPE_VENDING, sd);
+ pc->getzeny(vsd, (int)z, LOG_TYPE_VENDING, sd);
for( i = 0; i < count; i++ ) {
short amount = *(uint16*)(data + 4*i + 0);
@@ -168,9 +168,9 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid,
idx -= 2;
// vending item
- pc_additem(sd, &vsd->status.cart[idx], amount, LOG_TYPE_VENDING);
+ pc->additem(sd, &vsd->status.cart[idx], amount, LOG_TYPE_VENDING);
vsd->vending[vend_list[i]].amount -= amount;
- pc_cart_delitem(vsd, idx, amount, 0, LOG_TYPE_VENDING);
+ pc->cart_delitem(vsd, idx, amount, 0, LOG_TYPE_VENDING);
clif->vendingreport(vsd, idx, amount);
//print buyer's name
@@ -197,7 +197,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid,
vsd->vend_num = cursor;
//Always save BOTH: buyer and customer
- if( save_settings&2 ) {
+ if( iMap->save_settings&2 ) {
chrif_save(sd,0);
chrif_save(vsd,0);
}
@@ -209,7 +209,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid,
if( i == vsd->vend_num ) {
//Close Vending (this was automatically done by the client, we have to do it manually for autovenders) [Skotlex]
vending->close(vsd);
- map_quit(vsd); //They have no reason to stay around anymore, do they?
+ iMap->quit(vsd); //They have no reason to stay around anymore, do they?
}
}
}
@@ -226,7 +226,7 @@ void vending_openvending(struct map_session_data* sd, const char* message, const
if ( pc_isdead(sd) || !sd->state.prevend || pc_istrading(sd))
return; // can't open vendings lying dead || didn't use via the skill (wpe/hack) || can't have 2 shops at once
- vending_skill_lvl = pc_checkskill(sd, MC_VENDING);
+ vending_skill_lvl = pc->checkskill(sd, MC_VENDING);
// skill level and cart check
if( !vending_skill_lvl || !pc_iscarton(sd) ) {
clif->skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
@@ -250,12 +250,12 @@ void vending_openvending(struct map_session_data* sd, const char* message, const
index -= 2; // offset adjustment (client says that the first cart position is 2)
if( index < 0 || index >= MAX_CART // invalid position
- || pc_cartitem_amount(sd, index, amount) < 0 // invalid item or insufficient quantity
+ || pc->cartitem_amount(sd, index, amount) < 0 // invalid item or insufficient quantity
//NOTE: official server does not do any of the following checks!
|| !sd->status.cart[index].identify // unidentified item
|| sd->status.cart[index].attribute == 1 // broken item
|| sd->status.cart[index].expire_time // It should not be in the cart but just in case
- || !itemdb_cantrade(&sd->status.cart[index], pc_get_group_level(sd), pc_get_group_level(sd)) ) // untradeable item
+ || !itemdb_cantrade(&sd->status.cart[index], pc->get_group_level(sd), pc->get_group_level(sd)) ) // untradeable item
continue;
sd->vending[i].index = index;
@@ -272,7 +272,7 @@ void vending_openvending(struct map_session_data* sd, const char* message, const
clif->skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0); // custom reply packet
return;
}
- sd->state.prevend = 0;
+ sd->state.prevend = sd->state.workinprogress = 0;
sd->state.vending = true;
sd->vender_id = getid();
sd->vend_num = i;
diff --git a/src/plugins/Makefile.in b/src/plugins/Makefile.in
index 71b743dca..3c80fa0e1 100644
--- a/src/plugins/Makefile.in
+++ b/src/plugins/Makefile.in
@@ -1,17 +1,19 @@
COMMON_H = ../common/HPMi.h ../common/cbasetypes.h
-PLUGINS = sample
+PLUGINS = sample db2sql
@SET_MAKE@
#####################################################################
-.PHONY : all $(PLUGINS) sample clean help
+.PHONY : all $(PLUGINS) sample db2sql clean help
all: $(PLUGINS)
sample: sample@DLLEXT@
+db2sql: db2sql@DLLEXT@
+
clean:
@echo " CLEAN plugins"
@rm -rf *.o
diff --git a/src/plugins/db2sql.c b/src/plugins/db2sql.c
new file mode 100644
index 000000000..8db4a006f
--- /dev/null
+++ b/src/plugins/db2sql.c
@@ -0,0 +1,138 @@
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+
+#include "../common/cbasetypes.h"
+#include "../common/strlib.h"
+#include "../common/timer.h"
+#include "../common/HPMi.h"
+#include "../common/mmo.h"
+#include "../config/core.h"
+#include "../map/clif.h"
+#include "../map/pc.h"
+#include "../map/map.h"
+#include "../map/itemdb.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+HPExport struct hplugin_info pinfo = {
+ "DB2SQL", // Plugin name
+ SERVER_TYPE_MAP,// Which server types this plugin works with?
+ "0.4", // Plugin version
+ HPM_VERSION, // HPM Version (don't change, macro is automatically updated)
+};
+
+SqlStmt* stmt;
+
+int (*parse_dbrow)(char** str, const char* source, int line, int scriptopt);
+
+char* trimbraces(char* str) {
+ size_t start;
+ size_t end;
+
+ if( str == NULL )
+ return str;
+
+ for( start = 0; str[start] && str[start] == '{'; ++start )
+ ;
+ for( end = strlen(str); start < end && str[end-1] && (str[end-1] == '}' || str[end-1] == '\n'); --end )
+ ;
+ if( start == end )
+ *str = '\0';
+ else {
+ str[end] = '\0';
+ memmove(str,str+start,end-start+1);
+ trim(str);
+ }
+ return str;
+}
+int db2sql(char** str, const char* source, int line, int scriptopt) {
+ struct item_data *it = NULL;
+ unsigned char offset = 0;
+#ifdef RENEWAL
+ if( iMap->db_use_sqldbs ) offset = 1;
+#endif
+ if( (it = itemdb->exists(parse_dbrow(str,source,line,scriptopt))) ) {
+ /* renewal has the 'matk' and 'equip_level' is now 'equip_level_min', and there is a new 'equip_level_max' field */
+#ifdef RENEWAL
+ if( SQL_SUCCESS != SQL->StmtPrepare(stmt, "REPLACE INTO `%s` (`id`,`name_english`,`name_japanese`,`type`,`price_buy`,`price_sell`,`weight`,`atk`,`matk`,`defence`,`range`,`slots`,`equip_jobs`,`equip_upper`,`equip_genders`,`equip_locations`,`weapon_level`,`equip_level_min`,`equip_level_max`,`refineable`,`view`,`script`,`equip_script`,`unequip_script`) VALUES ('%u',?,?,'%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u',?,?,?)",iMap->item_db_re_db,
+ it->nameid,it->flag.delay_consume?IT_DELAYCONSUME:it->type,it->value_buy,it->value_sell,it->weight,it->atk,it->matk,it->def,it->range,it->slot,(unsigned int)strtoul(str[11+offset],NULL,0),atoi(str[12+offset]),atoi(str[13+offset]),atoi(str[14+offset]),it->wlv,it->elv,it->elvmax,atoi(str[17+offset]),it->look) )
+#else
+ if( SQL_SUCCESS != SQL->StmtPrepare(stmt, "REPLACE INTO `%s` (`id`,`name_english`,`name_japanese`,`type`,`price_buy`,`price_sell`,`weight`,`atk`,`defence`,`range`,`slots`,`equip_jobs`,`equip_upper`,`equip_genders`,`equip_locations`,`weapon_level`,`equip_level`,`refineable`,`view`,`script`,`equip_script`,`unequip_script`) VALUES ('%u',?,?,'%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u','%u',?,?,?)",iMap->item_db_db,
+ it->nameid,it->flag.delay_consume?IT_DELAYCONSUME:it->type,it->value_buy,it->value_sell,it->weight,it->atk,it->def,it->range,it->slot,(unsigned int)strtoul(str[11],NULL,0),atoi(str[12]),atoi(str[13]),atoi(str[14]),it->wlv,it->elv,atoi(str[17]),it->look) )
+#endif
+ SqlStmt_ShowDebug(stmt);
+ else {
+ if ( SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, it->name, strlen(it->name)) )
+ SqlStmt_ShowDebug(stmt);
+ else {
+ if ( SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, it->jname, strlen(it->jname)) )
+ SqlStmt_ShowDebug(stmt);
+ else {
+ #ifdef RENEWAL
+ if( iMap->db_use_sqldbs ) offset += 1;
+ #endif
+ if( it->script ) trimbraces(str[19+offset]);
+ if ( SQL_SUCCESS != SQL->StmtBindParam(stmt, 2, SQLDT_STRING, it->script?str[19+offset]:"", it->script?strlen(str[19+offset]):0) )
+ SqlStmt_ShowDebug(stmt);
+ else {
+ if( it->equip_script ) trimbraces(str[20+offset]);
+ if ( SQL_SUCCESS != SQL->StmtBindParam(stmt, 3, SQLDT_STRING, it->equip_script?str[20+offset]:"", it->equip_script?strlen(str[20+offset]):0) )
+ SqlStmt_ShowDebug(stmt);
+ else {
+ if( it->unequip_script ) trimbraces(str[21+offset]);
+ if ( SQL_SUCCESS != SQL->StmtBindParam(stmt, 4, SQLDT_STRING, it->unequip_script?str[21+offset]:"", it->unequip_script?strlen(str[21+offset]):0) )
+ SqlStmt_ShowDebug(stmt);
+ else {
+ if( SQL_SUCCESS != SQL->StmtExecute(stmt) )
+ SqlStmt_ShowDebug(stmt);
+ }
+ }
+ }
+ }
+ }
+ }
+ return it->nameid;
+ }
+ return 0;
+}
+
+CPCMD(db2sql) {
+
+ if( iMap->db_use_sqldbs ) {
+ ShowInfo("db2sql: this should not be used with 'db_use_sqldbs' enabled, skipping...\n");
+ return;
+ }
+
+ stmt = SQL->StmtMalloc(mysql_handle);
+ if( stmt == NULL ) {
+ SqlStmt_ShowDebug(stmt);
+ return;
+ }
+
+ /* link */
+ parse_dbrow = itemdb->parse_dbrow;
+ itemdb->parse_dbrow = db2sql;
+ /* empty table */
+#ifdef RENEWAL
+ if ( SQL_ERROR == SQL->Query(mysql_handle, "DELETE FROM `%s`", iMap->item_db_re_db ) )
+#else
+ if ( SQL_ERROR == SQL->Query(mysql_handle, "DELETE FROM `%s`", iMap->item_db_db) )
+#endif
+ Sql_ShowDebug(mysql_handle);
+ else {
+ itemdb->reload();
+ }
+ /* unlink */
+ itemdb->parse_dbrow = parse_dbrow;
+
+ SQL->StmtFree(stmt);
+}
+
+HPExport void plugin_init (void) {
+ SQL = GET_SYMBOL("SQL");
+ itemdb = GET_SYMBOL("itemdb");
+ iMap = GET_SYMBOL("iMap");
+ strlib = GET_SYMBOL("strlib");
+
+ HPMi->addCPCommand("server:tools:db2sql",CPCMD_A(db2sql));
+} \ No newline at end of file