-Add/upd basic documentation for script.c

-Fix some indentation and strange codestyle change to A-Style

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@16915 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
glighta 2012-11-12 00:35:48 +00:00
parent 752776e4cc
commit 94b8b02141
8 changed files with 637 additions and 578 deletions

File diff suppressed because it is too large Load Diff

View File

@ -4668,7 +4668,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
case HLIF_HEAL: //[orn] case HLIF_HEAL: //[orn]
if (bl->type != BL_HOM) { if (bl->type != BL_HOM) {
if (sd) clif_skill_fail(sd,skillid,USESKILL_FAIL_LEVEL,0) ; if (sd) clif_skill_fail(sd,skillid,USESKILL_FAIL_LEVEL,0) ;
break ; break ;
} }
case AL_HEAL: case AL_HEAL:
case ALL_RESURRECTION: case ALL_RESURRECTION:
@ -5994,7 +5994,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
break; break;
} }
if(!battle_config.duel_allow_teleport && sd->duel_group && skilllv <= 2) { // duel restriction [LuzZza] if(!battle_config.duel_allow_teleport && sd->duel_group && skilllv <= 2) { // duel restriction [LuzZza]
char output[128]; sprintf(output, msg_txt(365), skill_get_name(AL_TELEPORT)); char output[128]; sprintf(output, msg_txt(365), skill_get_name(AL_TELEPORT));
clif_displaymessage(sd->fd, output); //"Duel: Can't use %s in duel." clif_displaymessage(sd->fd, output); //"Duel: Can't use %s in duel."
break; break;
} }
@ -8382,7 +8382,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
if( src->id != bl->id && battle_check_target(src,bl,BCT_ENEMY) > 0 ) if( src->id != bl->id && battle_check_target(src,bl,BCT_ENEMY) > 0 )
status_fix_damage(src,bl,9999,clif_damage(src,bl,tick,0,0,9999,0,0,0)); status_fix_damage(src,bl,9999,clif_damage(src,bl,tick,0,0,9999,0,0,0));
} else if( sd ) { } else if( sd ) {
short chance = sstatus->int_/6 + sd->status.job_level/5 + skilllv*4; short chance = sstatus->int_/6 + sd->status.job_level/5 + skilllv*4;
if( !sd->status.party_id || (rnd()%100 > chance)) { if( !sd->status.party_id || (rnd()%100 > chance)) {
clif_skill_fail(sd,skillid,USESKILL_FAIL_NEED_HELPER,0); clif_skill_fail(sd,skillid,USESKILL_FAIL_NEED_HELPER,0);
break; break;
@ -9133,18 +9133,16 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data)
if( ((TBL_MOB*)target)->class_ == MOBID_EMPERIUM ) if( ((TBL_MOB*)target)->class_ == MOBID_EMPERIUM )
break; break;
} }
else else if (inf && battle_check_target(src, target, inf) <= 0){
if (inf && battle_check_target(src, target, inf) <= 0){
if (sd) clif_skill_fail(sd,ud->skillid,USESKILL_FAIL_LEVEL,0); if (sd) clif_skill_fail(sd,ud->skillid,USESKILL_FAIL_LEVEL,0);
break; break;
} }
if(inf&BCT_ENEMY && (sc = status_get_sc(target)) && if(inf&BCT_ENEMY && (sc = status_get_sc(target)) &&
sc->data[SC_FOGWALL] && sc->data[SC_FOGWALL] &&
rnd()%100 < 75) rnd() % 100 < 75) { //Fogwall makes all offensive-type targetted skills fail at 75%
{ //Fogwall makes all offensive-type targetted skills fail at 75% if (sd) clif_skill_fail(sd, ud->skillid, USESKILL_FAIL_LEVEL, 0);
if (sd) clif_skill_fail(sd,ud->skillid,USESKILL_FAIL_LEVEL,0); break;
break;
} }
} }
@ -10976,19 +10974,19 @@ static int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, un
if (!sce) if (!sce)
sc_start4(bl,type,100,sg->skill_lv,sg->group_id,0,0,sg->limit); sc_start4(bl,type,100,sg->skill_lv,sg->group_id,0,0,sg->limit);
break; break;
case UNT_BLOODYLUST: case UNT_BLOODYLUST:
if (sg->src_id == bl->id) if (sg->src_id == bl->id)
break; //Does not affect the caster. break; //Does not affect the caster.
if (!sce) { if (!sce) {
TBL_PC *sd = BL_CAST(BL_PC, bl); //prevent fullheal exploit 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(gettick(), sd->bloodylust_tick) < skill_get_time2(SC_BLOODYLUST, 1))
sc_start4(bl, type, 100, sg->skill_lv, 1, 0, 0, skill_get_time(LK_BERSERK, sg->skill_lv)); //do not refull heal sc_start4(bl, type, 100, sg->skill_lv, 1, 0, 0, skill_get_time(LK_BERSERK, sg->skill_lv)); //do not refull heal
else { else {
if (sd) sd->bloodylust_tick = gettick(); if (sd) sd->bloodylust_tick = gettick();
sc_start4(bl, type, 100, sg->skill_lv, 0, 0, 0, skill_get_time(LK_BERSERK, sg->skill_lv)); sc_start4(bl, type, 100, sg->skill_lv, 0, 0, 0, skill_get_time(LK_BERSERK, sg->skill_lv));
} }
} }
break; break;
case UNT_WARP_WAITING: { case UNT_WARP_WAITING: {
int working = sg->val1&0xffff; int working = sg->val1&0xffff;
@ -12428,7 +12426,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, short skill, sh
break; break;
case AL_WARP: case AL_WARP:
if(!battle_config.duel_allow_teleport && sd->duel_group) { // duel restriction [LuzZza] if(!battle_config.duel_allow_teleport && sd->duel_group) { // duel restriction [LuzZza]
char output[128]; sprintf(output, msg_txt(365), skill_get_name(AL_WARP)); char output[128]; sprintf(output, msg_txt(365), skill_get_name(AL_WARP));
clif_displaymessage(sd->fd, output); //"Duel: Can't use %s in duel." clif_displaymessage(sd->fd, output); //"Duel: Can't use %s in duel."
return 0; return 0;
} }
@ -13436,10 +13434,10 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, short
case SO_SUMMON_AQUA: case SO_SUMMON_AQUA:
case SO_SUMMON_VENTUS: case SO_SUMMON_VENTUS:
case SO_SUMMON_TERA: case SO_SUMMON_TERA:
case SO_WATER_INSIGNIA: case SO_WATER_INSIGNIA:
case SO_FIRE_INSIGNIA: case SO_FIRE_INSIGNIA:
case SO_WIND_INSIGNIA: case SO_WIND_INSIGNIA:
case SO_EARTH_INSIGNIA: case SO_EARTH_INSIGNIA:
if( i < 3 ) if( i < 3 )
continue; continue;
break; break;
@ -13480,10 +13478,10 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, short
case SO_SUMMON_AQUA: case SO_SUMMON_AQUA:
case SO_SUMMON_VENTUS: case SO_SUMMON_VENTUS:
case SO_SUMMON_TERA: case SO_SUMMON_TERA:
case SO_WATER_INSIGNIA: case SO_WATER_INSIGNIA:
case SO_FIRE_INSIGNIA: case SO_FIRE_INSIGNIA:
case SO_WIND_INSIGNIA: case SO_WIND_INSIGNIA:
case SO_EARTH_INSIGNIA: case SO_EARTH_INSIGNIA:
req.itemid[lv-1] = skill_db[j].itemid[lv-1]; req.itemid[lv-1] = skill_db[j].itemid[lv-1];
req.amount[lv-1] = skill_db[j].amount[lv-1]; req.amount[lv-1] = skill_db[j].amount[lv-1];
break; break;
@ -13708,8 +13706,8 @@ int skill_vfcastfix (struct block_list *bl, double time, int skill_id, int skill
VARCAST_REDUCTION(sc->data[SC_POEMBRAGI]->val2); VARCAST_REDUCTION(sc->data[SC_POEMBRAGI]->val2);
if (sc->data[SC_IZAYOI]) if (sc->data[SC_IZAYOI])
VARCAST_REDUCTION(50); 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)) 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. VARCAST_REDUCTION(30); //Reduces 30% Variable Cast Time of Water spells.
// Fixed cast reduction bonuses // Fixed cast reduction bonuses
if( sc->data[SC__LAZINESS] ) if( sc->data[SC__LAZINESS] )
fixcast_r = max(fixcast_r, sc->data[SC__LAZINESS]->val2); fixcast_r = max(fixcast_r, sc->data[SC__LAZINESS]->val2);
@ -13816,8 +13814,8 @@ int skill_delayfix (struct block_list *bl, int skill_id, int skill_lv)
if (sc && sc->count) { if (sc && sc->count) {
if (sc->data[SC_POEMBRAGI]) if (sc->data[SC_POEMBRAGI])
time -= time * sc->data[SC_POEMBRAGI]->val3 / 100; time -= time * sc->data[SC_POEMBRAGI]->val3 / 100;
if (sc->data[SC_WIND_INSIGNIA] && sc->data[SC_WIND_INSIGNIA]->val1 == 3 && (skill_get_ele(skill_id, skill_lv) == ELE_WIND)) if (sc->data[SC_WIND_INSIGNIA] && sc->data[SC_WIND_INSIGNIA]->val1 == 3 && (skill_get_ele(skill_id, skill_lv) == ELE_WIND))
time /= 2; // After Delay of Wind element spells reduced by 50%. time /= 2; // After Delay of Wind element spells reduced by 50%.
} }
} }
@ -13829,8 +13827,8 @@ int skill_delayfix (struct block_list *bl, int skill_id, int skill_lv)
time = time * battle_config.delay_rate / 100; time = time * battle_config.delay_rate / 100;
//min delay //min delay
time = max(time, status_get_amotion(bl)); // Delay can never be below amotion [Playtester] time = max(time, status_get_amotion(bl)); // Delay can never be below amotion [Playtester]
time = max(time, battle_config.min_skill_delay_limit); time = max(time, battle_config.min_skill_delay_limit);
// ShowInfo("Delay delayfix = %d\n",time); // ShowInfo("Delay delayfix = %d\n",time);
return time; return time;
@ -17445,7 +17443,7 @@ static bool skill_parse_row_requiredb(char* split[], int columns, int current)
else if( strcmpi(split[10],"mado")==0 ) skill_db[i].state = ST_MADO; else if( strcmpi(split[10],"mado")==0 ) skill_db[i].state = ST_MADO;
else if( strcmpi(split[10],"elementalspirit")==0 ) skill_db[i].state = ST_ELEMENTALSPIRIT; else if( strcmpi(split[10],"elementalspirit")==0 ) skill_db[i].state = ST_ELEMENTALSPIRIT;
else if (strcmpi(split[10], "poisonweapon") == 0) skill_db[i].state = ST_POISONINGWEAPON; else if (strcmpi(split[10], "poisonweapon") == 0) skill_db[i].state = ST_POISONINGWEAPON;
else if (strcmpi(split[10], "rollingcutter") == 0) skill_db[i].state = ST_ROLLINGCUTTER; else if (strcmpi(split[10], "rollingcutter") == 0) skill_db[i].state = ST_ROLLINGCUTTER;
/** /**
* Unknown or no state * Unknown or no state
@ -17456,7 +17454,7 @@ static bool skill_parse_row_requiredb(char* split[], int columns, int current)
for( j = 0; j < MAX_SKILL_ITEM_REQUIRE; j++ ) { for( j = 0; j < MAX_SKILL_ITEM_REQUIRE; j++ ) {
skill_db[i].itemid[j] = atoi(split[12+ 2*j]); skill_db[i].itemid[j] = atoi(split[12+ 2*j]);
skill_db[i].amount[j] = atoi(split[13+ 2*j]); skill_db[i].amount[j] = atoi(split[13+ 2*j]);
} }
return true; return true;
} }

View File

@ -400,8 +400,8 @@ enum {
ST_RIDINGWUG, ST_RIDINGWUG,
ST_MADO, ST_MADO,
ST_ELEMENTALSPIRIT, ST_ELEMENTALSPIRIT,
ST_POISONINGWEAPON, ST_POISONINGWEAPON,
ST_ROLLINGCUTTER, ST_ROLLINGCUTTER,
}; };
enum e_skill { enum e_skill {

View File

@ -1309,7 +1309,7 @@ int status_damage(struct block_list *src,struct block_list *target,int hp, int s
((TBL_MOB*)target)->state.rebirth = 1; ((TBL_MOB*)target)->state.rebirth = 1;
return hp+sp; return hp+sp;
} }
if(target->type == BL_PC){ if(target->type == BL_PC){
TBL_PC *sd = BL_CAST(BL_PC,target); TBL_PC *sd = BL_CAST(BL_PC,target);
TBL_HOM *hd = sd->hd; TBL_HOM *hd = sd->hd;
@ -1321,7 +1321,7 @@ int status_damage(struct block_list *src,struct block_list *target,int hp, int s
} }
} }
if (target->type == BL_MOB && sc && sc->data[SC_REBIRTH] && !((TBL_MOB*) target)->state.rebirth) {// Ensure the monster has not already rebirthed before doing so. if (target->type == BL_MOB && sc && sc->data[SC_REBIRTH] && !((TBL_MOB*) target)->state.rebirth) {// Ensure the monster has not already rebirthed before doing so.
status_revive(target, sc->data[SC_REBIRTH]->val2, 0); status_revive(target, sc->data[SC_REBIRTH]->val2, 0);
status_change_clear(target,0); status_change_clear(target,0);
((TBL_MOB*)target)->state.rebirth = 1; ((TBL_MOB*)target)->state.rebirth = 1;
@ -10443,7 +10443,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
sc_timer_next(1000+tick, status_change_timer, bl->id, data); sc_timer_next(1000+tick, status_change_timer, bl->id, data);
return 0; return 0;
} }
break; break;
case SC_ANGRIFFS_MODUS: 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; if( !status_charge(bl,100,20) ) break;

View File

@ -646,6 +646,7 @@ typedef enum sc_type {
SC_PARALYSIS, SC_PARALYSIS,
SC_PAIN_KILLER, SC_PAIN_KILLER,
#ifdef RENEWAL #ifdef RENEWAL
SC_EXTREMITYFIST2, SC_EXTREMITYFIST2,
#endif #endif

View File

@ -74,15 +74,15 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta
clif_displaymessage(sd->fd, msg_txt(246)); clif_displaymessage(sd->fd, msg_txt(246));
clif_tradestart(sd, 2); // GM is not allowed to trade clif_tradestart(sd, 2); // GM is not allowed to trade
return; return;
} }
// Players can not request trade from far away, unless they are allowed to use @trade. // Players can not request trade from far away, unless they are allowed to use @trade.
if (!pc_can_use_command(sd, "trade", COMMAND_ATCOMMAND) && if (!pc_can_use_command(sd, "trade", COMMAND_ATCOMMAND) &&
(sd->bl.m != target_sd->bl.m || !check_distance_bl(&sd->bl, &target_sd->bl, TRADE_DISTANCE))) { (sd->bl.m != target_sd->bl.m || !check_distance_bl(&sd->bl, &target_sd->bl, TRADE_DISTANCE))) {
clif_tradestart(sd, 0); // too far clif_tradestart(sd, 0); // too far
return ; return ;
} }
target_sd->trade_partner = sd->status.account_id; target_sd->trade_partner = sd->status.account_id;
sd->trade_partner = target_sd->status.account_id; sd->trade_partner = target_sd->status.account_id;
clif_traderequest(target_sd, sd->status.name); clif_traderequest(target_sd, sd->status.name);
@ -106,7 +106,7 @@ void trade_tradeack(struct map_session_data *sd, int type)
if (sd->state.trading || !sd->trade_partner) if (sd->state.trading || !sd->trade_partner)
return; //Already trading or no partner set. return; //Already trading or no partner set.
if ((tsd = map_id2sd(sd->trade_partner)) == NULL) { if ((tsd = map_id2sd(sd->trade_partner)) == NULL) {
clif_tradestart(sd, 1); // character does not exist clif_tradestart(sd, 1); // character does not exist
sd->trade_partner=0; sd->trade_partner=0;
@ -177,7 +177,7 @@ int impossible_trade_check(struct map_session_data *sd)
int i, index; int i, index;
nullpo_retr(1, sd); nullpo_retr(1, sd);
if(sd->deal.zeny > sd->status.zeny) if(sd->deal.zeny > sd->status.zeny)
{ {
pc_setglobalreg(sd,"ZENY_HACKER",1); pc_setglobalreg(sd,"ZENY_HACKER",1);
@ -220,7 +220,7 @@ int impossible_trade_check(struct map_session_data *sd)
} else } else
// message about the ban // message about the ban
strcpy(message_to_gm, msg_txt(508)); // This player hasn't been banned (Ban option is disabled). 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(wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm);
return 1; return 1;
} }
@ -257,7 +257,7 @@ int trade_check(struct map_session_data *sd, struct map_session_data *tsd)
n = sd->deal.item[trade_i].index; n = sd->deal.item[trade_i].index;
if (amount > inventory[n].amount) if (amount > inventory[n].amount)
return 0; //qty Exploit? return 0; //qty Exploit?
data = itemdb_search(inventory[n].nameid); data = itemdb_search(inventory[n].nameid);
i = MAX_INVENTORY; i = MAX_INVENTORY;
if (itemdb_isstackable2(data)) { //Stackable item. if (itemdb_isstackable2(data)) { //Stackable item.
@ -272,7 +272,7 @@ int trade_check(struct map_session_data *sd, struct map_session_data *tsd)
break; break;
} }
} }
if (i == MAX_INVENTORY) {// look for an empty slot. if (i == MAX_INVENTORY) {// look for an empty slot.
for(i = 0; i < MAX_INVENTORY && inventory2[i].nameid; i++); for(i = 0; i < MAX_INVENTORY && inventory2[i].nameid; i++);
if (i == MAX_INVENTORY) if (i == MAX_INVENTORY)
@ -439,7 +439,7 @@ void trade_tradeok(struct map_session_data *sd)
if(sd->state.deal_locked || !sd->state.trading) if(sd->state.deal_locked || !sd->state.trading)
return; return;
if ((target_sd = map_id2sd(sd->trade_partner)) == NULL) { if ((target_sd = map_id2sd(sd->trade_partner)) == NULL) {
trade_tradecancel(sd); trade_tradecancel(sd);
return; return;
@ -470,7 +470,7 @@ void trade_tradecancel(struct map_session_data *sd)
clif_tradecancelled(sd); clif_tradecancelled(sd);
return; return;
} }
for(trade_i = 0; trade_i < 10; trade_i++) { // give items back (only virtual) for(trade_i = 0; trade_i < 10; trade_i++) { // give items back (only virtual)
if (!sd->deal.item[trade_i].amount) if (!sd->deal.item[trade_i].amount)
continue; continue;
@ -498,7 +498,7 @@ void trade_tradecancel(struct map_session_data *sd)
target_sd->deal.item[trade_i].index = 0; target_sd->deal.item[trade_i].index = 0;
target_sd->deal.item[trade_i].amount = 0; target_sd->deal.item[trade_i].amount = 0;
} }
if (target_sd->deal.zeny) { if (target_sd->deal.zeny) {
clif_updatestatus(target_sd, SP_ZENY); clif_updatestatus(target_sd, SP_ZENY);
target_sd->deal.zeny = 0; target_sd->deal.zeny = 0;
@ -525,9 +525,9 @@ void trade_tradecommit(struct map_session_data *sd)
trade_tradecancel(sd); trade_tradecancel(sd);
return; return;
} }
sd->state.deal_locked = 2; sd->state.deal_locked = 2;
if (tsd->state.deal_locked < 2) if (tsd->state.deal_locked < 2)
return; //Not yet time for trading. return; //Not yet time for trading.
@ -547,7 +547,7 @@ void trade_tradecommit(struct map_session_data *sd)
trade_tradecancel(sd); trade_tradecancel(sd);
return; return;
} }
// trade is accepted and correct. // trade is accepted and correct.
for( trade_i = 0; trade_i < 10; trade_i++ ) for( trade_i = 0; trade_i < 10; trade_i++ )
{ {
@ -586,22 +586,22 @@ void trade_tradecommit(struct map_session_data *sd)
sd->deal.zeny = 0; sd->deal.zeny = 0;
tsd->deal.zeny = 0; tsd->deal.zeny = 0;
} }
sd->state.deal_locked = 0; sd->state.deal_locked = 0;
sd->trade_partner = 0; sd->trade_partner = 0;
sd->state.trading = 0; sd->state.trading = 0;
tsd->state.deal_locked = 0; tsd->state.deal_locked = 0;
tsd->trade_partner = 0; tsd->trade_partner = 0;
tsd->state.trading = 0; tsd->state.trading = 0;
clif_tradecompleted(sd, 0); clif_tradecompleted(sd, 0);
clif_tradecompleted(tsd, 0); clif_tradecompleted(tsd, 0);
// save both player to avoid crash: they always have no advantage/disadvantage between the 2 players // save both player to avoid crash: they always have no advantage/disadvantage between the 2 players
if (save_settings&1) if (save_settings&1)
{ {
chrif_save(sd,0); chrif_save(sd,0);
chrif_save(tsd,0); chrif_save(tsd,0);
} }
} }

View File

@ -73,7 +73,7 @@ int unit_walktoxy_sub(struct block_list *bl)
return 0; return 0;
memcpy(&ud->walkpath,&wpd,sizeof(wpd)); memcpy(&ud->walkpath,&wpd,sizeof(wpd));
if (ud->target_to && ud->chaserange>1) { if (ud->target_to && ud->chaserange>1) {
//Generally speaking, the walk path is already to an adjacent tile //Generally speaking, the walk path is already to an adjacent tile
//so we only need to shorten the path if the range is greater than 1. //so we only need to shorten the path if the range is greater than 1.
@ -129,7 +129,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
md = BL_CAST(BL_MOB, bl); md = BL_CAST(BL_MOB, bl);
mrd = BL_CAST(BL_MER, bl); mrd = BL_CAST(BL_MER, bl);
ud = unit_bl2ud(bl); ud = unit_bl2ud(bl);
if(ud == NULL) return 0; if(ud == NULL) return 0;
if(ud->walktimer != tid){ if(ud->walktimer != tid){
@ -155,7 +155,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
if(map_getcell(bl->m,x+dx,y+dy,CELL_CHKNOPASS)) if(map_getcell(bl->m,x+dx,y+dy,CELL_CHKNOPASS))
return unit_walktoxy_sub(bl); return unit_walktoxy_sub(bl);
//Refresh view for all those we lose sight //Refresh view for all those we lose sight
map_foreachinmovearea(clif_outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl); map_foreachinmovearea(clif_outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl);
@ -171,7 +171,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
ud->walktimer = -2; // arbitrary non-INVALID_TIMER value to make the clif code send walking packets 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); map_foreachinmovearea(clif_insight, bl, AREA_SIZE, -dx, -dy, sd?BL_ALL:BL_PC, bl);
ud->walktimer = INVALID_TIMER; ud->walktimer = INVALID_TIMER;
if(sd) { if(sd) {
if( sd->touching_id ) if( sd->touching_id )
npc_touchnext_areanpc(sd,false); npc_touchnext_areanpc(sd,false);
@ -244,7 +244,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
if(tid == INVALID_TIMER) //A directly invoked timer is from battle_stop_walking, therefore the rest is irrelevant. if(tid == INVALID_TIMER) //A directly invoked timer is from battle_stop_walking, therefore the rest is irrelevant.
return 0; return 0;
if(ud->state.change_walk_target) if(ud->state.change_walk_target)
return unit_walktoxy_sub(bl); return unit_walktoxy_sub(bl);
@ -318,9 +318,9 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag)
struct status_change* sc = NULL; struct status_change* sc = NULL;
nullpo_ret(bl); nullpo_ret(bl);
ud = unit_bl2ud(bl); ud = unit_bl2ud(bl);
if( ud == NULL) return 0; if( ud == NULL) return 0;
// disabled until we find the correct algorithm. [malufett] // disabled until we find the correct algorithm. [malufett]
//#ifdef OFFICIAL_WALKPATH //#ifdef OFFICIAL_WALKPATH
@ -335,12 +335,12 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag)
if(!(flag&2) && (!(status_get_mode(bl)&MD_CANMOVE) || !unit_can_move(bl))) if(!(flag&2) && (!(status_get_mode(bl)&MD_CANMOVE) || !unit_can_move(bl)))
return 0; return 0;
ud->state.walk_easy = flag&1; ud->state.walk_easy = flag&1;
ud->to_x = x; ud->to_x = x;
ud->to_y = y; ud->to_y = y;
unit_set_target(ud, 0); unit_set_target(ud, 0);
sc = status_get_sc(bl); sc = status_get_sc(bl);
if (sc && sc->data[SC_CONFUSION]) //Randomize the target position if (sc && sc->data[SC_CONFUSION]) //Randomize the target position
map_random_dir(bl, &ud->to_x, &ud->to_y); map_random_dir(bl, &ud->to_x, &ud->to_y);
@ -395,13 +395,13 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int
struct status_change *sc = NULL; struct status_change *sc = NULL;
nullpo_ret(bl); nullpo_ret(bl);
nullpo_ret(tbl); nullpo_ret(tbl);
ud = unit_bl2ud(bl); ud = unit_bl2ud(bl);
if( ud == NULL) return 0; if( ud == NULL) return 0;
if (!(status_get_mode(bl)&MD_CANMOVE)) if (!(status_get_mode(bl)&MD_CANMOVE))
return 0; return 0;
if (!unit_can_reach_bl(bl, tbl, distance_bl(bl, tbl)+1, flag&1, &ud->to_x, &ud->to_y)) { if (!unit_can_reach_bl(bl, tbl, distance_bl(bl, tbl)+1, flag&1, &ud->to_x, &ud->to_y)) {
ud->to_x = bl->x; ud->to_x = bl->x;
ud->to_y = bl->y; ud->to_y = bl->y;
@ -455,12 +455,12 @@ int unit_run(struct block_list *bl)
if (!(sc && sc->data[SC_RUN])) if (!(sc && sc->data[SC_RUN]))
return 0; return 0;
if (!unit_can_move(bl)) { if (!unit_can_move(bl)) {
status_change_end(bl, SC_RUN, INVALID_TIMER); status_change_end(bl, SC_RUN, INVALID_TIMER);
return 0; return 0;
} }
lv = sc->data[SC_RUN]->val1; lv = sc->data[SC_RUN]->val1;
dir_x = dirx[sc->data[SC_RUN]->val2]; dir_x = dirx[sc->data[SC_RUN]->val2];
dir_y = diry[sc->data[SC_RUN]->val2]; dir_y = diry[sc->data[SC_RUN]->val2];
@ -476,7 +476,7 @@ int unit_run(struct block_list *bl)
//if sprinting and there's a PC/Mob/NPC, block the path [Kevin] //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] && map_count_oncell(bl->m, to_x+dir_x, to_y+dir_y, BL_PC|BL_MOB|BL_NPC))
break; break;
to_x += dir_x; to_x += dir_x;
to_y += dir_y; to_y += dir_y;
} }
@ -525,7 +525,7 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) {
int i; int i;
if (!(sc && sc->data[SC_WUGDASH])) if (!(sc && sc->data[SC_WUGDASH]))
return 0; return 0;
nullpo_ret(sd); nullpo_ret(sd);
nullpo_ret(bl); nullpo_ret(bl);
@ -533,7 +533,7 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) {
status_change_end(bl,SC_WUGDASH,INVALID_TIMER); status_change_end(bl,SC_WUGDASH,INVALID_TIMER);
return 0; return 0;
} }
lv = sc->data[SC_WUGDASH]->val1; lv = sc->data[SC_WUGDASH]->val1;
dir_x = dirx[sc->data[SC_WUGDASH]->val2]; dir_x = dirx[sc->data[SC_WUGDASH]->val2];
dir_y = diry[sc->data[SC_WUGDASH]->val2]; dir_y = diry[sc->data[SC_WUGDASH]->val2];
@ -547,7 +547,7 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) {
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] && map_count_oncell(bl->m, to_x+dir_x, to_y+dir_y, BL_PC|BL_MOB|BL_NPC))
break; break;
to_x += dir_x; to_x += dir_x;
to_y += dir_y; to_y += dir_y;
} }
@ -573,7 +573,7 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) {
unit_bl2ud(bl)->state.running = 0; unit_bl2ud(bl)->state.running = 0;
status_change_end(bl,SC_WUGDASH,INVALID_TIMER); status_change_end(bl,SC_WUGDASH,INVALID_TIMER);
if( sd ){ if( sd ){
clif_fixpos(bl); 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, gettick(), SD_LEVEL);
@ -624,11 +624,11 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool
map_foreachinmovearea(clif_outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl); map_foreachinmovearea(clif_outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl);
map_moveblock(bl, dst_x, dst_y, gettick()); map_moveblock(bl, dst_x, dst_y, gettick());
ud->walktimer = -2; // arbitrary non-INVALID_TIMER value to make the clif code send walking packets 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); map_foreachinmovearea(clif_insight, bl, AREA_SIZE, -dx, -dy, sd?BL_ALL:BL_PC, bl);
ud->walktimer = INVALID_TIMER; ud->walktimer = INVALID_TIMER;
if(sd) { if(sd) {
if( sd->touching_id ) if( sd->touching_id )
npc_touchnext_areanpc(sd,false); npc_touchnext_areanpc(sd,false);
@ -664,7 +664,7 @@ int unit_setdir(struct block_list *bl,unsigned char dir)
ud = unit_bl2ud(bl); ud = unit_bl2ud(bl);
if (!ud) return 0; if (!ud) return 0;
ud->dir = dir; ud->dir = dir;
if (bl->type == BL_PC) if (bl->type == BL_PC)
((TBL_PC *)bl)->head_dir = 0; ((TBL_PC *)bl)->head_dir = 0;
clif_changed_dir(bl, AREA); clif_changed_dir(bl, AREA);
return 0; return 0;
@ -689,7 +689,7 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag)
struct map_session_data* sd; struct map_session_data* sd;
struct skill_unit* su = NULL; struct skill_unit* su = NULL;
int nx, ny, result; int nx, ny, result;
sd = BL_CAST(BL_PC, bl); sd = BL_CAST(BL_PC, bl);
su = BL_CAST(BL_SKILL, bl); su = BL_CAST(BL_SKILL, bl);
@ -701,12 +701,12 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag)
if(!su) { if(!su) {
unit_stop_walking(bl, 0); unit_stop_walking(bl, 0);
} }
if( sd ) { if( sd ) {
sd->ud.to_x = nx; sd->ud.to_x = nx;
sd->ud.to_y = ny; sd->ud.to_y = ny;
} }
dx = nx-bl->x; dx = nx-bl->x;
dy = ny-bl->y; dy = ny-bl->y;
@ -743,7 +743,7 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag)
return count; // return amount of knocked back cells return count; // return amount of knocked back cells
} }
//Warps a unit/ud to a given map/position. //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. //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) int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type)
@ -751,17 +751,17 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type)
struct unit_data *ud; struct unit_data *ud;
nullpo_ret(bl); nullpo_ret(bl);
ud = unit_bl2ud(bl); ud = unit_bl2ud(bl);
if(bl->prev==NULL || !ud) if(bl->prev==NULL || !ud)
return 1; return 1;
if (type == CLR_DEAD) if (type == CLR_DEAD)
//Type 1 is invalid, since you shouldn't warp a bl with the "death" //Type 1 is invalid, since you shouldn't warp a bl with the "death"
//animation, it messes up with unit_remove_map! [Skotlex] //animation, it messes up with unit_remove_map! [Skotlex]
return 1; return 1;
if( m<0 ) m=bl->m; if( m<0 ) m=bl->m;
switch (bl->type) { switch (bl->type) {
case BL_MOB: case BL_MOB:
if (map[bl->m].flag.monster_noteleport && ((TBL_MOB*)bl)->master_id == 0) if (map[bl->m].flag.monster_noteleport && ((TBL_MOB*)bl)->master_id == 0)
@ -774,18 +774,18 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type)
return 1; return 1;
break; break;
} }
if (x<0 || y<0) if (x<0 || y<0)
{ //Random map position. { //Random map position.
if (!map_search_freecell(NULL, m, &x, &y, -1, -1, 1)) { if (!map_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); 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; return 2;
} }
} else if (map_getcell(m,x,y,CELL_CHKNOREACH)) } else if (map_getcell(m,x,y,CELL_CHKNOREACH))
{ //Invalid target cell { //Invalid target cell
ShowWarning("unit_warp: Specified non-walkable target cell: %d (%s) at [%d,%d]\n", m, map[m].name, x,y); 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 (!map_search_freecell(NULL, m, &x, &y, 4, 4, 1))
{ //Can't find a nearby cell { //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); 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);
@ -795,10 +795,10 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type)
if (bl->type == BL_PC) //Use pc_setpos 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)) if (!unit_remove_map(bl, type))
return 3; return 3;
if (bl->m != m && battle_config.clear_unit_onwarp && if (bl->m != m && battle_config.clear_unit_onwarp &&
battle_config.clear_unit_onwarp&bl->type) battle_config.clear_unit_onwarp&bl->type)
skill_clear_unitgroup(bl); skill_clear_unitgroup(bl);
@ -832,8 +832,8 @@ int unit_stop_walking(struct block_list *bl,int type)
ud = unit_bl2ud(bl); ud = unit_bl2ud(bl);
if(!ud || ud->walktimer == INVALID_TIMER) if(!ud || ud->walktimer == INVALID_TIMER)
return 0; return 0;
//NOTE: We are using timer data after deleting it because we know the //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 //delete_timer function does not messes with it. If the function's
//behaviour changes in the future, this code could break! //behaviour changes in the future, this code could break!
td = get_timer(ud->walktimer); td = get_timer(ud->walktimer);
delete_timer(ud->walktimer, unit_walktoxy_timer); delete_timer(ud->walktimer, unit_walktoxy_timer);
@ -849,7 +849,7 @@ int unit_stop_walking(struct block_list *bl,int type)
if(type&0x01) if(type&0x01)
clif_fixpos(bl); clif_fixpos(bl);
ud->walkpath.path_len = 0; ud->walkpath.path_len = 0;
ud->walkpath.path_pos = 0; ud->walkpath.path_pos = 0;
ud->to_x = bl->x; ud->to_x = bl->x;
@ -892,21 +892,21 @@ int unit_can_move(struct block_list *bl)
struct map_session_data *sd; struct map_session_data *sd;
struct unit_data *ud; struct unit_data *ud;
struct status_change *sc; struct status_change *sc;
nullpo_ret(bl); nullpo_ret(bl);
ud = unit_bl2ud(bl); ud = unit_bl2ud(bl);
sc = status_get_sc(bl); sc = status_get_sc(bl);
sd = BL_CAST(BL_PC, bl); sd = BL_CAST(BL_PC, bl);
if (!ud) if (!ud)
return 0; return 0;
if (ud->skilltimer != INVALID_TIMER && ud->skillid != LG_EXEEDBREAK && (!sd || !pc_checkskill(sd, SA_FREECAST) || skill_get_inf2(ud->skillid)&INF2_GUILD_SKILL)) if (ud->skilltimer != INVALID_TIMER && ud->skillid != LG_EXEEDBREAK && (!sd || !pc_checkskill(sd, SA_FREECAST) || skill_get_inf2(ud->skillid)&INF2_GUILD_SKILL))
return 0; // prevent moving while casting return 0; // prevent moving while casting
if (DIFF_TICK(ud->canmove_tick, gettick()) > 0) if (DIFF_TICK(ud->canmove_tick, gettick()) > 0)
return 0; return 0;
if (sd && ( if (sd && (
pc_issit(sd) || pc_issit(sd) ||
sd->state.vending || sd->state.vending ||
@ -914,7 +914,7 @@ int unit_can_move(struct block_list *bl)
sd->state.blockedmove sd->state.blockedmove
)) ))
return 0; //Can't move return 0; //Can't move
if (sc) { if (sc) {
if( sc->cant.move /* status placed here are ones that cannot be cached by sc->cant.move for they depend on other conditions other than their availability */ if( sc->cant.move /* status placed here are ones that cannot be cached by sc->cant.move for they depend on other conditions other than their availability */
|| (sc->data[SC_FEAR] && sc->data[SC_FEAR]->val2 > 0) || (sc->data[SC_FEAR] && sc->data[SC_FEAR]->val2 > 0)
@ -928,7 +928,7 @@ int unit_can_move(struct block_list *bl)
sc->data[SC_CLOAKING]->val1 < 3 && !(sc->data[SC_CLOAKING]->val4&1)) sc->data[SC_CLOAKING]->val1 < 3 && !(sc->data[SC_CLOAKING]->val4&1))
) )
return 0; return 0;
if (sc->opt1 > 0 && sc->opt1 != OPT1_STONEWAIT && sc->opt1 != OPT1_BURNING && (sc->opt1 != OPT1_CRYSTALIZE && bl->type != BL_MOB)) if (sc->opt1 > 0 && sc->opt1 != OPT1_STONEWAIT && sc->opt1 != OPT1_BURNING && (sc->opt1 != OPT1_CRYSTALIZE && bl->type != BL_MOB))
return 0; return 0;
@ -964,7 +964,7 @@ int unit_resume_running(int tid, unsigned int tick, int id, intptr_t data)
/*========================================== /*==========================================
* Applies walk delay to character, considering that * Applies walk delay to character, considering that
* if type is 0, this is a damage induced delay: if previous delay is active, do not change it. * if type is 0, this is a damage induced delay: if previous delay is active, do not change it.
* if type is 1, this is a skill induced delay: walk-delay may only be increased, not decreased. * if type is 1, this is a skill induced delay: walk-delay may only be increased, not decreased.
*------------------------------------------*/ *------------------------------------------*/
@ -972,7 +972,7 @@ int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int
{ {
struct unit_data *ud = unit_bl2ud(bl); struct unit_data *ud = unit_bl2ud(bl);
if (delay <= 0 || !ud) return 0; if (delay <= 0 || !ud) return 0;
/** /**
* MvP mobs have no walk delay * MvP mobs have no walk delay
**/ **/
@ -1051,7 +1051,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, short skill_num, sh
target_id = ud->target; //Auto-select target. [Skotlex] target_id = ud->target; //Auto-select target. [Skotlex]
temp = 1; temp = 1;
} }
if (sd) { if (sd) {
//Target_id checking. //Target_id checking.
if(skillnotok(skill_num, sd)) // [MouseJstr] if(skillnotok(skill_num, sd)) // [MouseJstr]
@ -1121,7 +1121,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, short skill_num, sh
} }
break; break;
case BD_ENCORE: case BD_ENCORE:
//Prevent using the dance skill if you no longer have the skill in your tree. //Prevent using the dance skill if you no longer have the skill in your tree.
if(!sd->skillid_dance || pc_checkskill(sd,sd->skillid_dance)<=0){ if(!sd->skillid_dance || pc_checkskill(sd,sd->skillid_dance)<=0){
clif_skill_fail(sd,skill_num,USESKILL_FAIL_LEVEL,0); clif_skill_fail(sd,skill_num,USESKILL_FAIL_LEVEL,0);
return 0; return 0;
@ -1188,12 +1188,12 @@ int unit_skilluse_id2(struct block_list *src, int target_id, short skill_num, sh
unit_stop_attack(src); unit_stop_attack(src);
else if(ud->attacktimer != INVALID_TIMER) //Elsewise, delay current attack sequence else if(ud->attacktimer != INVALID_TIMER) //Elsewise, delay current attack sequence
ud->attackabletime = tick + status_get_adelay(src); ud->attackabletime = tick + status_get_adelay(src);
ud->state.skillcastcancel = castcancel; ud->state.skillcastcancel = castcancel;
//temp: Used to signal force cast now. //temp: Used to signal force cast now.
temp = 0; temp = 0;
switch(skill_num){ switch(skill_num){
case ALL_RESURRECTION: case ALL_RESURRECTION:
if(battle_check_undead(tstatus->race,tstatus->def_ele)) { if(battle_check_undead(tstatus->race,tstatus->def_ele)) {
@ -1239,7 +1239,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, short skill_num, sh
{ {
unsigned int k = (distance_bl(src,target)-1)/3; //+100% every 3 cells of distance unsigned int k = (distance_bl(src,target)-1)/3; //+100% every 3 cells of distance
if( k > 2 ) k = 2; // ...but hard-limited to 300%. if( k > 2 ) k = 2; // ...but hard-limited to 300%.
casttime += casttime * k; casttime += casttime * k;
} }
break; break;
case GD_EMERGENCYCALL: //Emergency Call double cast when the user has learned Leap [Daegaladh] case GD_EMERGENCYCALL: //Emergency Call double cast when the user has learned Leap [Daegaladh]
@ -1251,19 +1251,19 @@ int unit_skilluse_id2(struct block_list *src, int target_id, short skill_num, sh
casttime = -1; casttime = -1;
break; break;
} }
// moved here to prevent Suffragium from ending if skill fails // moved here to prevent Suffragium from ending if skill fails
#ifndef RENEWAL_CAST #ifndef RENEWAL_CAST
if (!(skill_get_castnodex(skill_num, skill_lv)&2)) if (!(skill_get_castnodex(skill_num, skill_lv)&2))
casttime = skill_castfix_sc(src, casttime); casttime = skill_castfix_sc(src, casttime);
#else #else
casttime = skill_vfcastfix(src, casttime, skill_num, skill_lv); casttime = skill_vfcastfix(src, casttime, skill_num, skill_lv);
#endif #endif
// in official this is triggered even if no cast time. // in official this is triggered even if no cast time.
clif_skillcasting(src, src->id, target_id, 0,0, skill_num, skill_get_ele(skill_num, skill_lv), casttime); clif_skillcasting(src, src->id, target_id, 0,0, skill_num, skill_get_ele(skill_num, skill_lv), casttime);
if( casttime > 0 || temp ) if( casttime > 0 || temp )
{ {
unit_stop_walking(src,1); unit_stop_walking(src,1);
if (sd && target->type == BL_MOB) if (sd && target->type == BL_MOB)
@ -1371,11 +1371,11 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, sh
if(ud->skilltimer != INVALID_TIMER) //Normally not needed since clif.c checks for it, but at/char/script commands don't! [Skotlex] if(ud->skilltimer != INVALID_TIMER) //Normally not needed since clif.c checks for it, but at/char/script commands don't! [Skotlex]
return 0; return 0;
sc = status_get_sc(src); sc = status_get_sc(src);
if (sc && !sc->count) if (sc && !sc->count)
sc = NULL; sc = NULL;
if( sd ) if( sd )
{ {
if( skillnotok(skill_num, sd) || !skill_check_condition_castbegin(sd, skill_num, skill_lv) ) if( skillnotok(skill_num, sd) || !skill_check_condition_castbegin(sd, skill_num, skill_lv) )
@ -1422,7 +1422,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, sh
#else #else
casttime = skill_vfcastfix(src, casttime, skill_num, skill_lv ); casttime = skill_vfcastfix(src, casttime, skill_num, skill_lv );
#endif #endif
ud->state.skillcastcancel = castcancel&&casttime>0?1:0; ud->state.skillcastcancel = castcancel&&casttime>0?1:0;
if( !sd || sd->skillitem != skill_num || skill_get_cast(skill_num,skill_lv) ) if( !sd || sd->skillitem != skill_num || skill_get_cast(skill_num,skill_lv) )
@ -1513,7 +1513,7 @@ int unit_unattackable(struct block_list *bl)
ud->state.attack_continue = 0; ud->state.attack_continue = 0;
unit_set_target(ud, 0); unit_set_target(ud, 0);
} }
if(bl->type == BL_MOB) if(bl->type == BL_MOB)
mob_unlocktarget((struct mob_data*)bl, gettick()) ; mob_unlocktarget((struct mob_data*)bl, gettick()) ;
else if(bl->type == BL_PET) else if(bl->type == BL_PET)
@ -1576,7 +1576,7 @@ int unit_attack(struct block_list *src,int target_id,int continuous)
return 0; return 0;
} }
//Cancels an ongoing combo, resets attackable time and restarts the //Cancels an ongoing combo, resets attackable time and restarts the
//attack timer to resume attacking after amotion time. [Skotlex] //attack timer to resume attacking after amotion time. [Skotlex]
int unit_cancel_combo(struct block_list *bl) int unit_cancel_combo(struct block_list *bl)
{ {
@ -1592,7 +1592,7 @@ int unit_cancel_combo(struct block_list *bl)
if (ud->attacktimer == INVALID_TIMER) if (ud->attacktimer == INVALID_TIMER)
return 1; //Nothing more to do. return 1; //Nothing more to do.
delete_timer(ud->attacktimer, unit_attack_timer); delete_timer(ud->attacktimer, unit_attack_timer);
ud->attacktimer=add_timer(ud->attackabletime,unit_attack_timer,bl->id,0); ud->attacktimer=add_timer(ud->attackabletime,unit_attack_timer,bl->id,0);
return 1; return 1;
@ -1622,7 +1622,7 @@ bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range,
if( bl->m != tbl->m) if( bl->m != tbl->m)
return false; return false;
if( bl->x==tbl->x && bl->y==tbl->y ) if( bl->x==tbl->x && bl->y==tbl->y )
return true; return true;
@ -1634,7 +1634,7 @@ bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range,
dy=tbl->y - bl->y; dy=tbl->y - bl->y;
dx=(dx>0)?1:((dx<0)?-1:0); dx=(dx>0)?1:((dx<0)?-1:0);
dy=(dy>0)?1:((dy<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 (map_getcell(tbl->m,tbl->x-dx,tbl->y-dy,CELL_CHKNOPASS))
{ //Look for a suitable cell to place in. { //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 && map_getcell(tbl->m,tbl->x-dirx[i],tbl->y-diry[i],CELL_CHKNOPASS);i++);
@ -1701,7 +1701,7 @@ int unit_calc_pos(struct block_list *bl, int tx, int ty, int dir)
} }
ud->to_x = x; ud->to_x = x;
ud->to_y = y; ud->to_y = y;
return 0; return 0;
} }
@ -1716,7 +1716,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t
struct map_session_data *sd = NULL; struct map_session_data *sd = NULL;
struct mob_data *md = NULL; struct mob_data *md = NULL;
int range; int range;
if( (ud=unit_bl2ud(src))==NULL ) if( (ud=unit_bl2ud(src))==NULL )
return 0; return 0;
if( ud->attacktimer != tid ) if( ud->attacktimer != tid )
@ -1750,7 +1750,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t
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 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: { // attacking when under cast delay has restrictions:
if( tid == INVALID_TIMER ) if( tid == INVALID_TIMER )
@ -1810,7 +1810,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t
} }
if(src->type == BL_PET && pet_attackskill((TBL_PET*)src, target->id)) if(src->type == BL_PET && pet_attackskill((TBL_PET*)src, target->id))
return 1; return 1;
map_freeblock_lock(); map_freeblock_lock();
ud->attacktarget_lv = battle_weapon_attack(src,target,tick,0); ud->attacktarget_lv = battle_weapon_attack(src,target,tick,0);
@ -1823,7 +1823,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t
**/ **/
if( ud->attacktarget_lv == ATK_NONE ) if( ud->attacktarget_lv == ATK_NONE )
return 1; return 1;
ud->attackabletime = tick + sstatus->adelay; ud->attackabletime = tick + sstatus->adelay;
// You can't move if you can't attack neither. // You can't move if you can't attack neither.
if (src->type&battle_config.attack_walk_delay) if (src->type&battle_config.attack_walk_delay)
@ -1856,7 +1856,7 @@ int unit_skillcastcancel(struct block_list *bl,int type)
struct unit_data *ud = unit_bl2ud( bl); struct unit_data *ud = unit_bl2ud( bl);
unsigned int tick=gettick(); unsigned int tick=gettick();
int ret=0, skill; int ret=0, skill;
nullpo_ret(bl); nullpo_ret(bl);
if (!ud || ud->skilltimer == INVALID_TIMER) if (!ud || ud->skilltimer == INVALID_TIMER)
return 0; //Nothing to cancel. return 0; //Nothing to cancel.
@ -1872,14 +1872,14 @@ int unit_skillcastcancel(struct block_list *bl,int type)
(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->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; return 0;
} }
ud->canact_tick = tick; ud->canact_tick = tick;
if(type&1 && sd) if(type&1 && sd)
skill = sd->skillid_old; skill = sd->skillid_old;
else else
skill = ud->skillid; skill = ud->skillid;
if (skill_get_inf(skill) & INF_GROUND_SKILL) if (skill_get_inf(skill) & INF_GROUND_SKILL)
ret=delete_timer( ud->skilltimer, skill_castend_pos ); ret=delete_timer( ud->skilltimer, skill_castend_pos );
else else
@ -1919,8 +1919,8 @@ void unit_dataset(struct block_list *bl)
ud->walktimer = INVALID_TIMER; ud->walktimer = INVALID_TIMER;
ud->skilltimer = INVALID_TIMER; ud->skilltimer = INVALID_TIMER;
ud->attacktimer = INVALID_TIMER; ud->attacktimer = INVALID_TIMER;
ud->attackabletime = ud->attackabletime =
ud->canact_tick = ud->canact_tick =
ud->canmove_tick = gettick(); ud->canmove_tick = gettick();
} }
@ -1944,7 +1944,7 @@ int unit_fixdamage(struct block_list *src,struct block_list *target,unsigned int
if(damage+damage2 <= 0) if(damage+damage2 <= 0)
return 0; return 0;
return status_fix_damage(src,target,damage+damage2,clif_damage(target,target,tick,sdelay,ddelay,damage,div,type,damage2)); return status_fix_damage(src,target,damage+damage2,clif_damage(target,target,tick,sdelay,ddelay,damage,div,type,damage2));
} }
@ -1971,7 +1971,7 @@ int unit_changeviewsize(struct block_list *bl,short size)
/*========================================== /*==========================================
* Removes a bl/ud from the map. * Removes a bl/ud from the map.
* Returns 1 on success. 0 if it couldn't be removed or the bl was free'd * Returns 1 on success. 0 if it couldn't be removed or the bl was free'd
* if clrtype is 1 (death), appropiate cleanup is performed. * if clrtype is 1 (death), appropiate cleanup is performed.
* Otherwise it is assumed bl is being warped. * Otherwise it is assumed bl is being warped.
* On-Kill specific stuff is not performed here, look at status_damage for that. * On-Kill specific stuff is not performed here, look at status_damage for that.
*------------------------------------------*/ *------------------------------------------*/
@ -2187,7 +2187,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
return 0; return 0;
} }
break; break;
} }
default: break;// do nothing default: break;// do nothing
} }
/** /**
@ -2252,13 +2252,13 @@ int unit_free(struct block_list *bl, clr_type clrtype)
pc_delautobonus(sd,sd->autobonus,ARRAYLENGTH(sd->autobonus),false); pc_delautobonus(sd,sd->autobonus,ARRAYLENGTH(sd->autobonus),false);
pc_delautobonus(sd,sd->autobonus2,ARRAYLENGTH(sd->autobonus2),false); pc_delautobonus(sd,sd->autobonus2,ARRAYLENGTH(sd->autobonus2),false);
pc_delautobonus(sd,sd->autobonus3,ARRAYLENGTH(sd->autobonus3),false); pc_delautobonus(sd,sd->autobonus3,ARRAYLENGTH(sd->autobonus3),false);
if( sd->followtimer != INVALID_TIMER ) if( sd->followtimer != INVALID_TIMER )
pc_stop_following(sd); pc_stop_following(sd);
if( sd->duel_invite > 0 ) if( sd->duel_invite > 0 )
duel_reject(sd->duel_invite, sd); duel_reject(sd->duel_invite, sd);
// Notify friends that this char logged out. [Skotlex] // Notify friends that this char logged out. [Skotlex]
map_foreachpc(clif_friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 0); map_foreachpc(clif_friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 0);
party_send_logout(sd); party_send_logout(sd);
@ -2454,10 +2454,10 @@ int unit_free(struct block_list *bl, clr_type clrtype)
} }
if( sd ) if( sd )
sd->ed = NULL; sd->ed = NULL;
elemental_summon_stop(ed); elemental_summon_stop(ed);
break; break;
} }
} }
skill_clear_unitgroup(bl); skill_clear_unitgroup(bl);

View File

@ -59,7 +59,7 @@ void vending_vendinglistreq(struct map_session_data* sd, int id)
{ // GM is not allowed to trade { // GM is not allowed to trade
clif_displaymessage(sd->fd, msg_txt(246)); clif_displaymessage(sd->fd, msg_txt(246));
return; return;
} }
sd->vended_id = vsd->vender_id; // register vending uid sd->vended_id = vsd->vender_id; // register vending uid
@ -139,11 +139,11 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui
clif_buyvending(sd, idx, amount, 2); // you can not buy, because overweight clif_buyvending(sd, idx, amount, 2); // you can not buy, because overweight
return; return;
} }
//Check to see if cart/vend info is in sync. //Check to see if cart/vend info is in sync.
if( vending[j].amount > vsd->status.cart[idx].amount ) if( vending[j].amount > vsd->status.cart[idx].amount )
vending[j].amount = vsd->status.cart[idx].amount; vending[j].amount = vsd->status.cart[idx].amount;
// if they try to add packets (example: get twice or more 2 apples if marchand has only 3 apples). // if they try to add packets (example: get twice or more 2 apples if marchand has only 3 apples).
// here, we check cumulative amounts // here, we check cumulative amounts
if( vending[j].amount < amount ) if( vending[j].amount < amount )
@ -152,7 +152,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui
clif_buyvending(sd, idx, vsd->vending[j].amount, 4); // not enough quantity clif_buyvending(sd, idx, vsd->vending[j].amount, 4); // not enough quantity
return; return;
} }
vending[j].amount -= amount; vending[j].amount -= amount;
switch( pc_checkadditem(sd, vsd->status.cart[idx].nameid, amount) ) { switch( pc_checkadditem(sd, vsd->status.cart[idx].nameid, amount) ) {
@ -199,7 +199,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui
{ {
if( vsd->vending[i].amount == 0 ) if( vsd->vending[i].amount == 0 )
continue; continue;
if( cursor != i ) // speedup if( cursor != i ) // speedup
{ {
vsd->vending[cursor].index = vsd->vending[i].index; vsd->vending[cursor].index = vsd->vending[i].index;
@ -233,18 +233,18 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui
} }
static int vending_checknearnpc_sub(struct block_list* bl, va_list args) { static int vending_checknearnpc_sub(struct block_list* bl, va_list args) {
struct npc_data *nd = (struct npc_data*)bl; struct npc_data *nd = (struct npc_data*)bl;
if( nd->sc.option & (OPTION_HIDE|OPTION_INVISIBLE) ) if( nd->sc.option & (OPTION_HIDE|OPTION_INVISIBLE) )
return 0; return 0;
return 1; return 1;
} }
bool vending_checknearnpc(struct block_list * bl) { bool vending_checknearnpc(struct block_list * bl) {
if( battle_config.min_npc_vending_distance > 0 && if( battle_config.min_npc_vending_distance > 0 &&
map_foreachinrange(vending_checknearnpc_sub,bl, battle_config.min_npc_vending_distance, BL_NPC) ) map_foreachinrange(vending_checknearnpc_sub,bl, battle_config.min_npc_vending_distance, BL_NPC) )
return true; return true;
return false; return false;
} }
/*========================================== /*==========================================
@ -284,8 +284,8 @@ void vending_openvending(struct map_session_data* sd, const char* message, bool
clif_skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0); clif_skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
return; return;
} }
// filter out invalid items // filter out invalid items
i = 0; i = 0;
for( j = 0; j < count; j++ ) for( j = 0; j < count; j++ )